Erlang cuttlefish schema for nested list of configuration items - erlang

I am trying to generate cuttlefish schema ( github cuttlefish) for the following proplist configuration structure.
I have several machine entries and under each machine entry there
are several ip entries.
[{machines,
[{machine1, [
{mach_id, "BeeHive"},
{ram, "2G"},
{ips, [
{ip1, [
{ip, "IP1"},
{sessions, 10}
]},
----,
---- ]}
]},
{machine2, [
{mach_id, "BeeHive2"},
{ram, "2G"},
{ips, [
{ip1, [
{ip, "IP1"},
{sessions, 11}
]},
----,
---- ]}
]}
]
}].
In cuttlefish mapping configuration, this requires multiple $ variables and for nested listing like several ip entries inside machine entry .
Please provide any pointers towards making a schema for the
above listed proplist structure.

Related

Strange behaviour with SpecflowPlusRunner using an older version of Newtonsoft,Json - how do you update it?

I have a dotnet core 3.1 class library, providing some service implementations. I wanted to use Specflow to create some BDD tests to test various scenarios with my service.
I created a Specflow tests project which uses the SpecflowPlus Test Runner. If I inspect my "deps.json" file present in my bin folder, all references to NewtonSoft.Json are set to version 12.0.3 - currently the latest version.
However, when the solution is built, some files are copied to this location \Specflow.Tests\bin\Debug\netcoreapp3.1\SpecFlowPlusRunner\ - one of them being \Specflow.Tests\bin\Debug\netcoreapp3.1\SpecFlowPlusRunner\netcoreapp3.1\Newtonsoft.Json.dll
This version of Newtonsoft.Json is only 11.0.2
If I look at "Manage Nuget Packages for Solution" and switch to the Consolidation tab, all versions referenced are 12.0.3 - I manually added Newtonsoft.Json to all projects in an attempt to equal up the versions.
When I run the tests, I get this error:
System.InvalidCastException: '[A]Newtonsoft.Json.Linq.JObject cannot be cast to [B]Newtonsoft.Json.Linq.JObject.
Type A originates from 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' in the context 'Default' at location 'C:\Source\Repos\BSP_Infrastructure\deployment\CleanUp\src\WTW.ICT.BSP.CleanUp.Specflow.Tests\bin\Debug\netcoreapp3.1\SpecFlowPlusRunner\netcoreapp3.1\Newtonsoft.Json.dll'.
Type B originates from 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' in the context 'Default' at location 'C:\Users\ian64639\.nuget\packages\newtonsoft.json\12.0.3\lib\netstandard2.0\Newtonsoft.Json.dll'.'
My code does some casting, internal to the class library:
public async Task<string[]> GetSpaUris(string id)
{
var app = await GetApplicationRegistrationAsync(id).ConfigureAwait(false);
return GetSpaUris(app);
}
public string[] GetSpaUris(Application application) => ((JArray)((JObject)application.AdditionalData["spa"])["redirectUris"]).ToObject<string[]>();
And returns a string array. I dont return any JArray or JObject objects/references, so this should not "leak" any Newtonsoft.Json dependencies. I am not trying to cast JObject to JObject across projects, so no casting should occur.
I created a small console app
var hostBuilder = new HostBuilder();
var svc = hostBuilder.MyHost.Services.GetService<ApplicationRegistrationService>();
var uris = await svc.GetSpaUris("b3340c1e-c37a-471f-8c90-4e25f27990e8");
And this has no such casting issues. So it seems its the version of Newtonsoft.Json that the SpecflowPlus Runner utilises that is likely to the be the issue.
I return a string[] to try and avoid having dependency crossover issues though.
I looked at the Specflow docs, and it says you can create a specflow.json config file, and you can specify "Custom" dependencies.
dependencies custom dependencies Specifies custom dependencies for the SpecFlow runtime. See Plugins for details. Default: not specified
https://docs.specflow.org/projects/specflow/en/latest/Extend/Plugins.md
However this link returns
\ SORRY /
\ /
\ This page does /
] not exist yet. [ ,'|
] [ / |
]___ ___[ ,' |
] ]\ /[ [ |: |
] ] \ / [ [ |: |
] ] ] [ [ [ |: |
] ] ]__ __[ [ [ |: |
] ] ] ]\ _ /[ [ [ [ |: |
] ] ] ] (#) [ [ [ [ :===='
] ] ]_].nHn.[_[ [ [
] ] ] HHHHH. [ [ [
] ] / `HH("N \ [ [
]__]/ HHH " \[__[
] NNN [
] N/" [
] N H [
/ N \
/ q, \
/ \
Anyone got any ideas how I can resolve it? Is custom dependencies my salvation? If so, does anyone know how?
Custom dependencies are only for changing the behavior of SpecFlow. They have nothing to do with this.
Newtonsoft.Json 11 is used by the SpecFlow+ Runner internally. As dependencies in test runners are not resolved with normal NuGet dependencies and need to be shipped with the test runner NuGet package. That's why you are seeing the v11 assembly also if you update all projects to v12.
And because of assembly loading in .NET, this is getting complicated and you get this error.
At the moment the only thing I can think of, that will unblock you is that you are using also Newtonsoft.Json v11. I hope this is possible.
Please open an issue at https://github.com/SpecFlowOSS/SpecFlow/ about this, so we can have a look at it and fix this.
Full disclosure: I am the community manager of SpecFlow and SpecFlow+

What is the "application configuration file" in a rebar3 app?

The inets httpd server docs say,
The following is to be put in the Erlang node application
configuration file to start an HTTP server at application startup:
[{inets, [{services, [{httpd, [{proplist_file,
"/var/tmp/server_root/conf/8888_props.conf"}]},
{httpd, [{proplist_file,
"/var/tmp/server_root/conf/8080_props.conf"}]}]}]}].
Where does that go in an app created by rebar3?
The OTP Application docs say,
7.8 Configuring an Application
An application can be configured using configuration parameters. These
are a list of {Par,Val} tuples specified by a key env in the .app
file:
{application, ch_app,
[{description, "Channel allocator"},
{vsn, "1"},
{modules, [ch_app, ch_sup, ch3]},
{registered, [ch3]},
{applications, [kernel, stdlib, sasl]},
{mod, {ch_app,[]}},
{env, [{file, "/usr/local/log"}]}
]}.
Par is to be an atom. Val is any term.
That seems to suggest that you create environment variables with {Name, Value} tuples. However, the required code specified in the httpd server docs does not seem to be in that format.
Just drop this into the sys.config file which is in config folder of your release. If you have anything there already, it will be in the format of:
[
{some_app, [{env_var, value},{...}]},
{another_app, [{env_var, value},{...}]},
% add here without outer[]...,
{kernel,
[{distributed, [{app_name, 5000,
['node#10.0.211.153', 'node_failover#10.8.222.15']}]},
{sync_nodes_mandatory, []},
{sync_nodes_optional, ['node_failover#10.8.222.15']},
{sync_nodes_timeout, 5000}]}
]

erlang lager_syslog driver failure

I'm trying to use lager_syslog in my project but it seems like a driver is missing.
This is in my rebar.conf:
{deps, [
...
{lager_syslog, {git, "https://github.com/basho/lager_syslog.git", {branch, master}}}
]}.
My test handler:
{lager_syslog_backend, ["test", local1, info]},
The error:
19:29:09.981 [error] Lager failed to install handler {lager_syslog_backend,{"test",local1}} into lager_event, retrying later : {error,
{{shutdown,
{failed_to_start_child,
syslog,
"could not load driver syslog_drv: \"cannot open shared object file: No such file or directory\""}},
{syslog_app,
start,
[normal,
[]]}}}
Any suggestion?
thanks to Kenneth Lakin who answered my question in mailing list
IIRC, rebar3 moved the port compiler out to a rebar3 plugin, rather than
packing it in with the core project. From what I've seen, rebar2
projects that relied on it will fail to load their port drivers.
Add
{overrides,
[{override, syslog, [
{plugins, [pc]},
{artifacts, ["priv/syslog_drv.so"]},
{provider_hooks, [
{post,
[
{compile, {pc, compile}},
{clean, {pc, clean}}
]
}]
}
]}
]}.
to a rebar.conf in your project, clean, and rebuild. (The syslog project
is where lager_syslog's port driver lives.)
See also: https://github.com/blt/port_compiler#use-with-existing-dependency

Elasticsearch error when creating index possibly due to module Kuromoji not installed properly

I am trying to setup my local environment for a Rails application I just gained access to that uses Elasticsearch 1.3 along with two modules (kuromoji and smartcn)
I have followed instructions to install Elasticsearch along with the modules and when I start elasticsearch I get the following output: (note the plugins line which makes me believe they have been loaded)
$ elasticsearch
[2015-07-10 09:56:05,887][INFO ][node ] [Rune] version[1.3.9], pid[4364], build[0915c73/2015-02-19T12:34:48Z]
[2015-07-10 09:56:05,887][INFO ][node ] [Rune] initializing ...
[2015-07-10 09:56:05,930][INFO ][plugins ] [Rune] loaded [analysis-smartcn, analysis-kuromoji], sites []
[2015-07-10 09:56:08,469][INFO ][node ] [Rune] initialized
[2015-07-10 09:56:08,469][INFO ][node ] [Rune] starting ...
[2015-07-10 09:56:08,577][INFO ][transport ] [Rune] bound_address {inet[/127.0.0.1:9301]}, publish_address {inet[/127.0.0.1:9301]}
[2015-07-10 09:56:08,596][INFO ][discovery ] [Rune] elasticsearch_brew/X-HUXjxxT6CtRblL2zANSg
[2015-07-10 09:56:11,611][INFO ][cluster.service ] [Rune] new_master [Rune][X-HUXjxxT6CtRblL2zANSg][boobooninja.local][inet[/127.0.0.1:9301]], reason: zen-disco-join (elected_as_master)
[2015-07-10 09:56:11,633][INFO ][http ] [Rune] bound_address {inet[/127.0.0.1:9201]}, publish_address {inet[/127.0.0.1:9201]}
[2015-07-10 09:56:11,634][INFO ][node ] [Rune] started
[2015-07-10 09:56:11,647][INFO ][gateway ] [Rune] recovered [0] indices into cluster_state
However when I try to run a rake task to index and import the data I get the following error that makes me believe Kuromoji was not loaded or perhaps something else is going on.
[!!!] Error when creating the index: Elasticsearch::Transport::Transport::Errors::BadRequest
[400] {"error":"IndexCreationException[[development-activities] failed to create index]; nested: ElasticsearchIllegalArgumentException[failed to find token filter type [kuromoji_readingform] for [katakana_readingform]]; nested: NoClassSettingsException[Failed to load class setting [type] with value [kuromoji_readingform]]; nested: ClassNotFoundException[org.elasticsearch.index.analysis.kuromojireadingform.KuromojiReadingformTokenFilterFactory]; ","status":400}
[IMPORT] Done
I appreciate any help in determining the issue here.
The message seems about kuromoji plugin. Try to install the plugin.
cd path/to/yourelasticsearch
bin/plugin install elasticsearch/elasticsearch-analysis-kuromoji/2.7.0
Note that you need to install a proper version of kuromoji plugion depending on the version of elasticsearch you installed. See here.

Chicagoboss - How to update lager_file_backend config?

I have updated ChicagoBoss to my latest version. When I'm compiling it, I'm getting a notice as
Deprecated lager_file_backend config detected, please consider updating it
I'm compiling it using following command:
./rebar get-deps clean compile
So, the questions are:
What is lager_file_backend config?
Why it is deprecated?
How to update it.?
lager_file_backend config simply refers to the 'lager_file_backend' section of your configuration file (boss.config)
I don't know why it is being deprecated, sorry.
I had trouble finding release notes detailing the differences. I figured out how to update by looking at the example here: https://github.com/basho/lager
Here's what the old style looks like:
{lager, [
{handlers, [
{lager_console_backend, info},
{lager_file_backend, [
{"/var/log/foo/boss_error.log", error, 10485760, "$D0", 5},
{"/var/log/foo/boss_console.log", info, 10485760, "$D0", 5}
]}
]}
]},
Here's what the new style looks like:
{lager, [
{handlers, [
{lager_console_backend, info},
{lager_file_backend, [{file, "/var/log/foo/boss_error.log"}, {level, error}]},
{lager_file_backend, [{file, "/var/log/foo/boss_console.log"}, {level, info}]}
]}
]},

Resources