From 2f973f4930e47765149b5c7e183e86ab31b35ba9 Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Tue, 10 Sep 2013 11:54:17 -0700 Subject: [PATCH 1/6] Added test and dialyzer targets to makefile --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Makefile b/Makefile index ca8f1a92..1eae6ca1 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ + public_key mnesia syntax_tools compiler +COMBO_PLT = $(HOME)/.cuttlefish_combo_dialyzer_plt + .PHONY: deps all: deps compile @@ -20,3 +24,24 @@ clean: distclean: clean @rm -rf cuttlefish deps + +test: all + ./rebar skip_deps=true eunit + +docs: deps + ./rebar skip_deps=true doc + +build_plt: compile + dialyzer --build_plt --output_plt $(COMBO_PLT) --apps $(APPS) \ + deps/*/ebin + +check_plt: compile + dialyzer --check_plt --plt $(COMBO_PLT) --apps $(APPS) \ + deps/*/ebin + +dialyzer: compile + @echo + @echo Use "'make check_plt'" to check PLT prior to using this target. + @echo Use "'make build_plt'" to build PLT prior to using this target. + @echo + dialyzer --plt $(COMBO_PLT) ebin From dacac2c1e8408f950d7759bd38c0c7c7ad0def5a Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Wed, 11 Sep 2013 12:55:17 -0700 Subject: [PATCH 2/6] Added schema changes for lager 2.0 to test --- Makefile | 3 -- src/cuttlefish_generator.erl | 8 +-- test/cuttlefish_integration_test.erl | 2 +- test/default.config | 17 ++++-- test/riak.schema | 78 ++++++++++++++++++++-------- 5 files changed, 75 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 1eae6ca1..f79d62b7 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,6 @@ all: deps compile deps: ./rebar get-deps -docs: - ./rebar skip_deps=true doc - docsclean: @rm -rf doc/*.png doc/*.html doc/*.css edoc-info diff --git a/src/cuttlefish_generator.erl b/src/cuttlefish_generator.erl index 707b17d6..9da61129 100644 --- a/src/cuttlefish_generator.erl +++ b/src/cuttlefish_generator.erl @@ -93,13 +93,13 @@ map({Translations, Mappings, Validators} = Schema, Config) -> end, {[], {[],[]}}, Mappings), - lager:info("Applying 1:1 Mappings"), + lager:info("Applied 1:1 Mappings"), TranslationsToDrop = TranslationsToMaybeDrop -- TranslationsToKeep, %% The fold handles the translations. After we've build the DirecetMappings, %% we use that to seed this fold's accumulator. As we go through each translation %% we write that to the `app.config` that lives in the accumutator. - lists:foldl( + Return = lists:foldl( fun(TranslationRecord, Acc) -> Mapping = cuttlefish_translation:mapping(TranslationRecord), Xlat = cuttlefish_translation:func(TranslationRecord), @@ -124,7 +124,9 @@ map({Translations, Mappings, Validators} = Schema, Config) -> end end, DirectMappings, - Translations). + Translations), + lager:info("Applied Translations"), + Return. %for each token, is it special? % diff --git a/test/cuttlefish_integration_test.erl b/test/cuttlefish_integration_test.erl index 4a32dfc9..89c3cb85 100644 --- a/test/cuttlefish_integration_test.erl +++ b/test/cuttlefish_integration_test.erl @@ -125,7 +125,7 @@ proplist_equals(Expected, Actual) -> {false, false} -> ?assertEqual({EKey, ExpectedValue}, {EKey, ActualValue}); _ -> - ?assert(false) + ?assertEqual({EKey, ExpectedValue}, {EKey, ActualValue}) end end || EKey <- ExpectedKeys]. diff --git a/test/default.config b/test/default.config index ee9fb4ee..37cef120 100644 --- a/test/default.config +++ b/test/default.config @@ -280,10 +280,19 @@ %% like this: %% {lager_syslog_backend, ["riak", daemon, info]}, %% - {handlers, [ - {lager_file_backend, [{file, "./log/error.log"}, {level, error}]}, - {lager_file_backend, [{file, "./log/console.log"}, {level, info}]} - ] }, + {handlers, + [{lager_file_backend, + [{file,"./log/console.log"}, + {level,info}, + {size,10485760}, + {date,"$D0"}, + {count,5}]}, + {lager_file_backend, + [{file,"./log/error.log"}, + {level,error}, + {size,10485760}, + {date,"$D0"}, + {count,5}]}]}, %% Whether to write a crash log, and where. %% Commented/omitted/undefined means no crash logger. diff --git a/test/riak.schema b/test/riak.schema index 9cdce574..e4facade 100644 --- a/test/riak.schema +++ b/test/riak.schema @@ -23,17 +23,33 @@ { translation, "riak_kv.anti_entropy", fun(Conf) -> - Setting = cuttlefish_util:conf_get_value("anti_entropy", Conf), - case Setting of - on -> {on, []}; - debug -> {on, [debug]}; - off -> {off, []}; - _Default -> {on, []} - end + Setting = cuttlefish_util:conf_get_value("anti_entropy", Conf), + case Setting of + on -> {on, []}; + debug -> {on, [debug]}; + off -> {off, []}; + _Default -> {on, []} + end end }. %% complex lager example +%% @doc where do you want the console.log output: +%% off : nowhere +%% file: the file specified by log.console.file +%% console : standard out +%% both : log.console.file and standard out. +{mapping, "log.console", "lager.handlers", [ + {default, file}, + {datatype, {enum, [off, file, console, both]}} +]}. + +%% @doc the log level of the console log +{mapping, "log.console.level", "lager.handlers", [ + {default, info}, + {datatype, {enum, [debug, info, warning, error]}} +]}. + %% @doc location of the console log {mapping, "log.console.file", "lager.handlers", [ {default, "./log/console.log"} @@ -54,21 +70,39 @@ { translation, "lager.handlers", - fun(Conf) -> - SyslogHandler = case cuttlefish_util:conf_get_value("log.syslog", Conf) of - on -> {lager_syslog_backend, ["riak", daemon, info]}; - _ -> undefined - end, - ErrorHandler = case cuttlefish_util:conf_get_value("log.error.file", Conf) of - undefined -> undefined; - ErrorFilename -> {lager_file_backend, [{file, ErrorFilename}, {level, error}]} - end, - ConsoleHandler = case cuttlefish_util:conf_get_value("log.console.file", Conf) of - undefined -> undefined; - ConsoleFilename -> {lager_file_backend, [{file, ConsoleFilename}, {level, info}]} - end, - lists:filter(fun(X) -> X =/= undefined end, [SyslogHandler, ErrorHandler, ConsoleHandler]) - end + fun(Conf) -> + SyslogHandler = case cuttlefish_util:conf_get_value("log.syslog", Conf) of + on -> [{lager_syslog_backend, ["riak", daemon, info]}]; + _ -> [] + end, + ErrorHandler = case cuttlefish_util:conf_get_value("log.error.file", Conf) of + undefined -> []; + ErrorFilename -> [{lager_file_backend, [{file, ErrorFilename}, + {level, error}, + {size, 10485760}, + {date, "$D0"}, + {count, 5}]}] + end, + + ConsoleLogLevel = cuttlefish_util:conf_get_value("log.console.level", Conf), + ConsoleLogFile = cuttlefish_util:conf_get_value("log.console.file", Conf), + + ConsoleHandler = {lager_console_handler, ConsoleLogLevel}, + ConsoleFileHandler = {lager_file_backend, [{file, ConsoleLogFile}, + {level, ConsoleLogLevel}, + {size, 10485760}, + {date, "$D0"}, + {count, 5}]}, + + ConsoleHandlers = case cuttlefish_util:conf_get_value("log.console", Conf) of + off -> []; + file -> [ConsoleFileHandler]; + console -> [ConsoleHandler]; + both -> [ConsoleHandler, ConsoleFileHandler]; + _ -> [] + end, + SyslogHandler ++ ConsoleHandlers ++ ErrorHandler + end }. %% SASL From b77db418bdb3843a4e23f2aa8847637fb5c4e45c Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Wed, 11 Sep 2013 14:08:08 -0700 Subject: [PATCH 3/6] added riak_control bits to schema --- test/riak.schema | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/riak.schema b/test/riak.schema index e4facade..c0401bcd 100644 --- a/test/riak.schema +++ b/test/riak.schema @@ -658,12 +658,22 @@ end}. end}. %% @doc Authentication style used for access to the admin -%% panel. Valid styles are 'userlist' . +%% panel. Valid styles are: off, userlist {mapping, "riak_control.auth", "riak_control.auth", [ {default, userlist}, - {datatype, {enum, [userlist]}} + {datatype, {enum, [off, userlist]}} ]}. +{translation, +"riak_control.auth", +fun(Conf) -> + case cuttlefish_util:conf_get_value("riak_control.auth", Conf) of + userlist -> userlist; + off -> none; + _ -> none + end +end}. + %% @doc If auth is set to 'userlist' then this is the %% list of usernames and passwords for access to the %% admin panel. From 89de2199000eb57c7ed4d2cd99069e17b0ade1f0 Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Wed, 11 Sep 2013 16:44:35 -0700 Subject: [PATCH 4/6] dialyzer fixes --- src/cuttlefish_conf.erl | 4 ++++ src/cuttlefish_datatypes.erl | 2 +- src/cuttlefish_generator.erl | 9 +++++---- src/cuttlefish_mapping.erl | 6 +++--- src/cuttlefish_schema.erl | 16 ++++++++-------- src/cuttlefish_util.erl | 2 +- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/cuttlefish_conf.erl b/src/cuttlefish_conf.erl index 352fcb2e..713aebcf 100644 --- a/src/cuttlefish_conf.erl +++ b/src/cuttlefish_conf.erl @@ -21,6 +21,9 @@ %% ------------------------------------------------------------------- -module(cuttlefish_conf). +-type conf() :: [{ [string()], any() }]. +-export_type([conf/0]). + -export([ generate/1, generate_file/2, @@ -59,6 +62,7 @@ generate(Schema) -> ConfFile ++ generate_element(SchemaElement) end, [], Schema). +-spec generate_file(cuttlefish_schema:schema(), string()) -> ok. generate_file(Schema, Filename) -> ConfFileLines = generate(Schema), diff --git a/src/cuttlefish_datatypes.erl b/src/cuttlefish_datatypes.erl index 1bbf8a88..7cbcdbe3 100644 --- a/src/cuttlefish_datatypes.erl +++ b/src/cuttlefish_datatypes.erl @@ -26,7 +26,7 @@ -compile(export_all). -endif. --opaque datatype() :: integer | string | {enum, [atom()]} | ip | {duration, cuttlefish_duration:time_unit() } | bytesize. +-type datatype() :: integer | string | {enum, [atom()]} | ip | {duration, cuttlefish_duration:time_unit() } | bytesize. -export_type([datatype/0]). -export([is_supported/1, from_string/2, to_string/2]). diff --git a/src/cuttlefish_generator.erl b/src/cuttlefish_generator.erl index 9da61129..d1b0fb4a 100644 --- a/src/cuttlefish_generator.erl +++ b/src/cuttlefish_generator.erl @@ -217,6 +217,7 @@ add_defaults(Conf, Mappings) -> %% {"multi_backend", %% ["bitcask_mult","leveldb_mult","leveldb_mult2","memory_mult"}] %%%%%%%%%%%%%%%%%%%%%%%% +-spec get_possible_values_for_fuzzy_matches(cuttlefish_conf:conf(), [cuttlefish_mapping:mapping()]) -> [{string(), [string()]}]. get_possible_values_for_fuzzy_matches(Conf, Mappings) -> %% Get a list of all the key definitions from the schema %% that involve a pattern match @@ -231,10 +232,9 @@ get_possible_values_for_fuzzy_matches(Conf, Mappings) -> cuttlefish_util:fuzzy_variable_match(Variable, VariableDef) end, FuzzyVariableDefs), - case length(Fuzz) of - 0 -> FuzzyMatches; - _ -> - VD = hd(Fuzz), + case Fuzz of + [] -> FuzzyMatches; + [VD|_] -> ListOfVars = [ Var || {_, Var } <- cuttlefish_util:matches_for_variable_def(VD, [{Variable, 0}])], orddict:append_list(VD, ListOfVars, FuzzyMatches) end @@ -289,6 +289,7 @@ get_possible_values_for_fuzzy_matches(Conf, Mappings) -> PrefixesWithoutDefaults, DefaultsNeeded). +-spec transform_datatypes(cuttlefish_conf:conf(), [cuttlefish_mapping:mapping()]) -> cuttlefish_conf:conf(). transform_datatypes(Conf, Mappings) -> lists:foldl( fun({Variable, Value}, Acc) -> diff --git a/src/cuttlefish_mapping.erl b/src/cuttlefish_mapping.erl index a4f3b6dd..624cfa9d 100644 --- a/src/cuttlefish_mapping.erl +++ b/src/cuttlefish_mapping.erl @@ -35,11 +35,11 @@ datatype_options :: any(), level = basic :: basic | intermediate | advanced, doc = [] :: list(), - include_default::string(), + include_default = undefined :: string() | undefined, validators = [] :: [string()] }). --opaque mapping() :: #mapping{}. +-type mapping() :: #mapping{}. -export_type([mapping/0]). -export([ @@ -112,7 +112,7 @@ level(M) -> M#mapping.level. -spec doc(mapping()) -> [string()]. doc(M) -> M#mapping.doc. --spec include_default(mapping()) -> string(). +-spec include_default(mapping()) -> string() | undefined. include_default(M) -> M#mapping.include_default. -spec validators(mapping()) -> [string()]. diff --git a/src/cuttlefish_schema.erl b/src/cuttlefish_schema.erl index 080eb17b..19a66528 100644 --- a/src/cuttlefish_schema.erl +++ b/src/cuttlefish_schema.erl @@ -29,7 +29,9 @@ -compile(export_all). -endif. --type errorlist() :: {error, [string()]}. +-type errorlist() :: {error, string()|[string()]}. +-type schema() :: {[cuttlefish_translation:translation()], [cuttlefish_mapping:mapping()], [cuttlefish_validator:validator()]}. +-export_type([schema/0]). files(ListOfSchemaFiles) -> lists:foldl( @@ -62,9 +64,7 @@ files(ListOfSchemaFiles) -> ValidatorAcc, Validators), - {NewTranslations, NewMappings, NewValidators}; - _ -> - lager:error("Unknown error parsing schema file: ~p", [SchemaFile]) + {NewTranslations, NewMappings, NewValidators} end end, {[], [], []}, @@ -74,7 +74,7 @@ files(ListOfSchemaFiles) -> [cuttlefish_translation:translation()], [cuttlefish_mapping:mapping()], [cuttlefish_validator:validator()] -} | error. +} | errorlist(). file(Filename) -> {ok, B} = file:read_file(Filename), %% TODO: Hardcoded utf8 @@ -145,9 +145,9 @@ parse_schema(Tokens, Comments) -> -spec parse_schema( [any()], [any()], - [cuttlefish_translation:translation() | cuttlefish_mapping:mapping() | cuttlefish_validator:validator()] + [cuttlefish_translation:translation() | cuttlefish_mapping:mapping() | cuttlefish_validator:validator() | errorlist()] ) -> - [cuttlefish_translation:translation() | cuttlefish_mapping:mapping() | cuttlefish_validator:validator()]. + [cuttlefish_translation:translation() | cuttlefish_mapping:mapping() | cuttlefish_validator:validator() | errorlist()]. parse_schema([], _LeftoverComments, Acc) -> lists:reverse(Acc); parse_schema(ScannedTokens, CommentTokens, Acc) -> @@ -187,7 +187,7 @@ parse_schema_tokens(Scanned, Acc=[{dot, LineNo}|_]) -> parse_schema_tokens([H|Scanned], Acc) -> parse_schema_tokens(Scanned, [H|Acc]). --spec parse(list()) -> { mapping | translation, tuple()} | errorlist(). +-spec parse(list()) -> { mapping | translation | validator, tuple()} | errorlist(). parse(Scanned) -> case erl_parse:parse_exprs(Scanned) of {ok, Parsed} -> diff --git a/src/cuttlefish_util.erl b/src/cuttlefish_util.erl index 2cf9fbfb..113c031b 100644 --- a/src/cuttlefish_util.erl +++ b/src/cuttlefish_util.erl @@ -48,7 +48,7 @@ conf_get_value(Variable, ConfigProplist) -> conf_get_value(tokenize_variable_key(Variable), ConfigProplist). %% @doc replace the element in a proplist --spec replace_proplist_value(string(), any(), [{string(), any()}]) -> [{string(), any()}]. +-spec replace_proplist_value(atom() | string(), any(), [{string(), any()}]) -> [{string(), any()}]. replace_proplist_value(Key, Value, Proplist) -> proplists:delete(Key, Proplist) ++ [{Key, Value}]. From 6dc5849789cfe033bdafdb7be3a2f158b0ab2c5b Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Wed, 11 Sep 2013 16:59:12 -0700 Subject: [PATCH 5/6] moar dialyzer fixes --- src/cuttlefish_conf.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cuttlefish_conf.erl b/src/cuttlefish_conf.erl index 713aebcf..d4a611de 100644 --- a/src/cuttlefish_conf.erl +++ b/src/cuttlefish_conf.erl @@ -56,6 +56,7 @@ file(Filename) -> remove_duplicates(Conf) end. +-spec generate(cuttlefish_schema:schema()) -> [string()]. generate(Schema) -> lists:foldl( fun(SchemaElement, ConfFile) -> @@ -66,7 +67,7 @@ generate(Schema) -> generate_file(Schema, Filename) -> ConfFileLines = generate(Schema), - {ok, S} = file:open(Filename, write), + {ok, S} = file:open(Filename, [write]), [ begin io:format(S, "~s~n", [lists:flatten(Line)]) end || Line <- ConfFileLines], From 48178fa742b1458689e7963924c980c492ae3d08 Mon Sep 17 00:00:00 2001 From: Joe DeVivo Date: Thu, 12 Sep 2013 09:31:13 -0700 Subject: [PATCH 6/6] final dialyzer fixes and some whitespace --- src/cuttlefish_advanced.erl | 2 +- src/cuttlefish_bytesize.erl | 2 +- src/cuttlefish_conf.erl | 20 +- src/cuttlefish_datatypes.erl | 2 +- src/cuttlefish_duration.erl | 2 +- src/cuttlefish_mapping.erl | 11 +- src/cuttlefish_rebar_plugin.erl | 1 - src/cuttlefish_schema.erl | 2 +- src/cuttlefish_translation.erl | 4 +- src/cuttlefish_util.erl | 2 +- src/cuttlefish_validator.erl | 2 +- src/cuttlefish_vmargs.erl | 2 +- test/advanced.config | 2 +- test/bad_erlang.schema | 2 +- test/cuttlefish_integration_test.erl | 2 +- test/cuttlefish_lager_test_backend.erl | 7 +- test/default.conf | 296 ------------------------- test/multi1.schema | 2 +- test/multi2.schema | 2 +- test/multi_backend.schema | 2 +- test/riak.conf | 2 +- test/riak.schema | 2 +- 22 files changed, 40 insertions(+), 331 deletions(-) delete mode 100644 test/default.conf diff --git a/src/cuttlefish_advanced.erl b/src/cuttlefish_advanced.erl index 0090fa50..9a663ff6 100644 --- a/src/cuttlefish_advanced.erl +++ b/src/cuttlefish_advanced.erl @@ -71,4 +71,4 @@ overlay_test() -> ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_bytesize.erl b/src/cuttlefish_bytesize.erl index 151a8c16..ae7baf4b 100644 --- a/src/cuttlefish_bytesize.erl +++ b/src/cuttlefish_bytesize.erl @@ -84,4 +84,4 @@ parse_test() -> ?assertEqual(error, parse("10MB10kb")), ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_conf.erl b/src/cuttlefish_conf.erl index d4a611de..f2b064c0 100644 --- a/src/cuttlefish_conf.erl +++ b/src/cuttlefish_conf.erl @@ -56,16 +56,16 @@ file(Filename) -> remove_duplicates(Conf) end. --spec generate(cuttlefish_schema:schema()) -> [string()]. -generate(Schema) -> +-spec generate([cuttlefish_mapping:mapping()]) -> [string()]. +generate(Mappings) -> lists:foldl( - fun(SchemaElement, ConfFile) -> - ConfFile ++ generate_element(SchemaElement) - end, [], Schema). + fun(Mapping, ConfFile) -> + ConfFile ++ generate_element(Mapping) + end, [], Mappings). --spec generate_file(cuttlefish_schema:schema(), string()) -> ok. -generate_file(Schema, Filename) -> - ConfFileLines = generate(Schema), +-spec generate_file([cuttlefish_mapping:mapping()], string()) -> ok. +generate_file(Mappings, Filename) -> + ConfFileLines = generate(Mappings), {ok, S} = file:open(Filename, [write]), [ begin @@ -74,6 +74,7 @@ generate_file(Schema, Filename) -> file:close(S), ok. +-spec generate_element(cuttlefish_mapping:mapping()) -> [string()]. generate_element(MappingRecord) -> Default = cuttlefish_mapping:default(MappingRecord), Key = cuttlefish_mapping:variable(MappingRecord), @@ -105,6 +106,7 @@ generate_element(basic, _Default, undefined) -> default; generate_element(basic, _, _Comment) -> commented; generate_element(_Level, _Default, _Commented) -> no. +-spec generate_comments(cuttlefish_mapping:mapping()) -> [string()]. generate_comments(MappingRecord) -> Doc = cuttlefish_mapping:doc(MappingRecord), [ "## " ++ D || D <- Doc]. @@ -198,4 +200,4 @@ files_one_nonent() -> ?assertEqual("1", proplists:get_value(["a","b","d"], Conf)), ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_datatypes.erl b/src/cuttlefish_datatypes.erl index 7cbcdbe3..f4d587a6 100644 --- a/src/cuttlefish_datatypes.erl +++ b/src/cuttlefish_datatypes.erl @@ -166,4 +166,4 @@ from_string_duration_secs_test() -> from_string_string_test() -> ?assertEqual("string", from_string("string", string)). --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_duration.erl b/src/cuttlefish_duration.erl index 8207aaaf..5575d00b 100644 --- a/src/cuttlefish_duration.erl +++ b/src/cuttlefish_duration.erl @@ -204,4 +204,4 @@ parse_2_test() -> ?assertEqual(1, parse("1ms", f)), ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_mapping.erl b/src/cuttlefish_mapping.erl index 624cfa9d..3b0f147d 100644 --- a/src/cuttlefish_mapping.erl +++ b/src/cuttlefish_mapping.erl @@ -91,7 +91,7 @@ parse(X) -> {error, io_lib:format("poorly formatted input to cuttlefish_mapping: is_mapping(M) -> is_tuple(M) andalso element(1, M) =:= mapping. --spec variable(mapping()) -> string(). +-spec variable(mapping()) -> [string()]. variable(M) -> M#mapping.variable. -spec mapping(mapping()) -> string(). @@ -120,7 +120,12 @@ validators(M) -> M#mapping.validators. -spec validators(mapping(), [cuttlefish_validator:validator()]) -> [cuttlefish_validator:validator()]. validators(M, Validators) -> - [ lists:keyfind(VName, 2, Validators) || VName <- M#mapping.validators]. + lists:foldr(fun(VName, Vs) -> + case lists:keyfind(VName, 2, Validators) of + false -> Vs; + V -> [V|Vs] + end + end, [], M#mapping.validators). -spec replace(mapping(), [mapping()]) -> [mapping()]. replace(Mapping, ListOfMappings) -> @@ -303,4 +308,4 @@ validators_test() -> ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_rebar_plugin.erl b/src/cuttlefish_rebar_plugin.erl index c738a170..513ae4ed 100644 --- a/src/cuttlefish_rebar_plugin.erl +++ b/src/cuttlefish_rebar_plugin.erl @@ -81,4 +81,3 @@ should_i_run(ReltoolConfig) -> false -> no end. - diff --git a/src/cuttlefish_schema.erl b/src/cuttlefish_schema.erl index 19a66528..94e2ff91 100644 --- a/src/cuttlefish_schema.erl +++ b/src/cuttlefish_schema.erl @@ -342,4 +342,4 @@ files_test() -> ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_translation.erl b/src/cuttlefish_translation.erl index 1809a230..f6a2a048 100644 --- a/src/cuttlefish_translation.erl +++ b/src/cuttlefish_translation.erl @@ -30,7 +30,7 @@ mapping::string(), func::fun() }). --opaque translation() :: #translation{}. +-type translation() :: #translation{}. -export_type([translation/0]). -export([ @@ -146,4 +146,4 @@ remove_duplicates_test() -> ?assertEqual(Expected, NewTranslations), ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_util.erl b/src/cuttlefish_util.erl index 113c031b..9e84e97f 100644 --- a/src/cuttlefish_util.erl +++ b/src/cuttlefish_util.erl @@ -131,7 +131,7 @@ tokenize_variable_key([Char|Rest], Part, Acc) -> %% @doc given a KeyDef "a.b.$c.d", what are the possible values for $c %% in the set of Keys in Conf = [{Key, Value}]? --spec matches_for_variable_def([string()], [{[string()], any()}]) -> [string()]. +-spec matches_for_variable_def([string()], [{[string()], any()}]) -> [{string(), any()}]. matches_for_variable_def(VariableDef, Conf) -> lists:foldl( fun({Variable, _}, Acc) -> diff --git a/src/cuttlefish_validator.erl b/src/cuttlefish_validator.erl index ea91bc59..af001b4c 100644 --- a/src/cuttlefish_validator.erl +++ b/src/cuttlefish_validator.erl @@ -162,4 +162,4 @@ remove_duplicates_test() -> ?assertEqual(Expected, NewValidators), ok. --endif. \ No newline at end of file +-endif. diff --git a/src/cuttlefish_vmargs.erl b/src/cuttlefish_vmargs.erl index ad9e36c0..aa94100a 100644 --- a/src/cuttlefish_vmargs.erl +++ b/src/cuttlefish_vmargs.erl @@ -47,4 +47,4 @@ stringify_test() -> [ ?assertEqual(E, V) || {E, V} <- lists:zip(Expected, VMArgs)], ok. --endif. \ No newline at end of file +-endif. diff --git a/test/advanced.config b/test/advanced.config index d75e9691..6908693e 100644 --- a/test/advanced.config +++ b/test/advanced.config @@ -11,4 +11,4 @@ %% Default is 1 build per hour. {anti_entropy_build_limit, {1, 3600000}} ]} -]. \ No newline at end of file +]. diff --git a/test/bad_erlang.schema b/test/bad_erlang.schema index 0044328b..ccfc3a8e 100644 --- a/test/bad_erlang.schema +++ b/test/bad_erlang.schema @@ -9,4 +9,4 @@ %% @doc bad setting {mapping, "setting2, "nested.nesting", [ {datatype, string} -}. \ No newline at end of file +}. diff --git a/test/cuttlefish_integration_test.erl b/test/cuttlefish_integration_test.erl index 89c3cb85..ae150e27 100644 --- a/test/cuttlefish_integration_test.erl +++ b/test/cuttlefish_integration_test.erl @@ -135,4 +135,4 @@ is_proplist(Proplist) when is_list(Proplist) -> is_tuple(X) andalso tuple_size(X) =:= 2 end, Proplist); -is_proplist(_) -> false. \ No newline at end of file +is_proplist(_) -> false. diff --git a/test/cuttlefish_lager_test_backend.erl b/test/cuttlefish_lager_test_backend.erl index 9b0b4511..e24f3994 100644 --- a/test/cuttlefish_lager_test_backend.erl +++ b/test/cuttlefish_lager_test_backend.erl @@ -10,7 +10,7 @@ terminate/2, code_change/3]). -export([get_logs/0, - bounce/0]). + bounce/0]). %% holds the log messages for retreival on terminate -record(state, {level, verbose, log = []}). @@ -22,9 +22,9 @@ get_logs() -> gen_event:call(lager_event, ?MODULE, get_logs, infinity). bounce() -> - application:stop(lager), + application:stop(lager), lager:start(), - gen_event:add_handler(lager_event, cuttlefish_lager_test_backend, [error, false]), + gen_event:add_handler(lager_event, cuttlefish_lager_test_backend, [error, false]), lager:set_loglevel(cuttlefish_lager_test_backend, error), ok. @@ -122,4 +122,3 @@ code_change(_OldVsn, State, _Extra) -> %% @doc gen_event callback, does nothing. terminate(_Reason, #state{log=Logs}) -> {ok, lists:reverse(Logs)}. - diff --git a/test/default.conf b/test/default.conf deleted file mode 100644 index f87027cb..00000000 --- a/test/default.conf +++ /dev/null @@ -1,296 +0,0 @@ -#jd# Hi! Welcome to my draft of the riak.conf file! -#jd# Comments with ## will be included in the default file -#jd# Comments with #jd# are notes to keep in mind while reading it -#jd# Metacomments? lol ETOODEEP - - - - - - -## pb_backlog is the maximum length to which the queue of pending -## connections may grow. If set, it must be an integer >= 0. -## By default the value is 5. If you anticipate a huge number of -## connections being initialised *simultaneously*, set this number -## higher. -#jd# this is an example of a setting that is included in the .conf -#jd# file, but intitially commented out. Note that the "sample" -#jd# value is *NOT* the actual default -## protobuf.backlog = 64 - -## pb is a list of IP addresses and TCP ports that the Riak -## Protocol Buffers interface will bind. -#jd# I'm uncertain about how I'd like to handles lists of things -protobuf.ip[0] = 127.0.0.1:8087 - -## Default location of ringstate -#jd# we need to think about this setting. Is it here because -#jd# a) it makes packaging easier for Jared -#jd# b) it shows the user how to change it -#jd# c) bolth -ring_dir = ./data/ring - -## Default ring creation size. Make sure it is a power of 2, -## e.g. 16, 32, 64, 128, 256, 512 etc -#jd# this one is commented out, but also the default. -#jd# why comment it at all then? -## ring_size = 64 - -## http is a list of IP addresses and TCP ports that the Riak -## HTTP interface will bind. -#jd# again, list syntax -http.ip[0] = 127.0.0.1:8098 - -## https is a list of IP addresses and TCP ports that the Riak -## HTTPS interface will bind. -#jd# again, list syntax. Is it odd that http and https default -#jd# to the same port? -## https.ip[0] = 127.0.0.1:8098 - -## Default cert and key locations for https can be overridden -## with the ssl config variable, for example: -## ssl.certfile = ./etc/cert.pem -## ssl.keyfile = ./etc/key.pem - -## riak_handoff_port is the TCP port that Riak uses for -## intra-cluster data handoff. -handoff.port = 8099 - -## To encrypt riak_core intra-cluster data handoff traffic, -## uncomment the following line and edit its path to an -## appropriate certfile and keyfile. (This example uses a -## single file with both items concatenated together.) -# handoff.ssl.certfile = /tmp/erlserver.pem - -## DTrace support -## Do not enable 'dtrace_support' unless your Erlang/OTP -## runtime is compiled to support DTrace. DTrace is -## available in R15B01 (supported by the Erlang/OTP -## official source package) and in R14B04 via a custom -## source repository & branch. -dtrace = false - -## Platform-specific installation paths (substituted by rebar) -platform_bin_dir = ./bin -platform_data_dir = ./data -platform_etc_dir = ./etc -platform_lib_dir = ./lib -platform_log_dir = ./log - -## Storage_backend specifies the Erlang module defining the storage -## mechanism that will be used on this node. -storage_backend = bitcask - -## raw_name is the first part of all URLS used by the Riak raw HTTP -## interface. See riak_web.erl and raw_http_resource.erl for -## details. -## raw_name = riak - -## Enable active anti-entropy subsystem + optional debug messages: -## {anti_entropy, {on|off, []}}, -## {anti_entropy, {on|off, [debug]}}, -anti_entropy = on - -## Restrict how fast AAE can build hash trees. Building the tree -## for a given partition requires a full scan over that partition's -## data. Once built, trees stay built until they are expired. -## Config is of the form: -## {num-builds, per-timespan-in-milliseconds} -## Default is 1 build per hour. -anti_entropy.build_limit.num_builds = 1 -anti_entropy.build_limit.per_milliseconds = 3600000 - -## Determine how often hash trees are expired after being built. -## Periodically expiring a hash tree ensures the on-disk hash tree -## data stays consistent with the actual k/v backend data. It also -## helps Riak identify silent disk failures and bit rot. However, -## expiration is not needed for normal AAE operation and should be -## infrequent for performance reasons. The time is specified in -## milliseconds. The default is 1 week. -anti_entropy.expire = 604800000 - -## Limit how many AAE exchanges/builds can happen concurrently. -anti_entropy.concurrency = 2 - -## The tick determines how often the AAE manager looks for work -## to do (building/expiring trees, triggering exchanges, etc). -## The default is every 15 seconds. Lowering this value will -## speedup the rate that all replicas are synced across the cluster. -## Increasing the value is not recommended. -anti_entropy.tick = 15000 - -## The directory where AAE hash trees are stored. -anti_entropy.data_dir = ./data/anti_entropy - -## The LevelDB options used by AAE to generate the LevelDB-backed -## on-disk hashtrees. -anti_entropy.leveldb.write_buffer_size = 4194304 -anti_entropy.leveldb.max_open_files = 20 - -## mapred_name is URL used to submit map/reduce requests to Riak. -mapred_name = mapred - -## mapred_2i_pipe indicates whether secondary-index -## MapReduce inputs are queued in parallel via their own -## pipe ('true'), or serially via a helper process -## ('false' or undefined). Set to 'false' or leave -## undefined during a rolling upgrade from 1.0. -mapred_2i_pipe = true - -## Each of the following entries control how many Javascript -## virtual machines are available for executing map, reduce, -## pre- and post-commit hook functions. -javascript_vm_count.map = 8 -javascript_vm_count.reduce = 6 -javascript_vm_count.hook = 2 - -## js_max_vm_mem is the maximum amount of memory, in megabytes, -## allocated to the Javascript VMs. If unset, the default is -## 8MB. -javascript_vm.max_mem = 8 - -## js_thread_stack is the maximum amount of thread stack, in megabyes, -## allocate to the Javascript VMs. If unset, the default is 16MB. -## NOTE: This is not the same as the C thread stack. -javascript_vm.thread_stack = 16 - -## js_source_dir should point to a directory containing Javascript -## source files which will be loaded by Riak when it initializes -## Javascript VMs. -javascript_vm.source_dir = /tmp/js_source - -## http_url_encoding determines how Riak treats URL encoded -## buckets, keys, and links over the REST API. When set to 'on' -## Riak always decodes encoded values sent as URLs and Headers. -## Otherwise, Riak defaults to compatibility mode where links -## are decoded, but buckets and keys are not. The compatibility -## mode will be removed in a future release. -http.url_encoding = on - -## Switch to vnode-based vclocks rather than client ids. This -## significantly reduces the number of vclock entries. -## Only set true if *all* nodes in the cluster are upgraded to 1.0 -vnode_vclocks = true - -## This option toggles compatibility of keylisting with 1.0 -## and earlier versions. Once a rolling upgrade to a version -## > 1.0 is completed for a cluster, this should be set to -## true for better control of memory usage during key listing -## operations -listkeys_backpressure = true - -## This option specifies how many of each type of fsm may exist -## concurrently. This is for overload protection and is a new -## mechanism that obsoletes 1.3's health checks. Note that this number -## represents two potential processes, so +P in vm.args should be at -## least 3X the fsm_limit. -fsm_limit = 50000 - -## object_format controls which binary representation of a riak_object -## is stored on disk. -## Current options are: v0, v1. -## v0: Original erlang:term_to_binary format. Higher space overhead. -## v1: New format for more compact storage of small values. -object_format = v1 - -## Riak Search Config -riak_search = disabled - -## Merge Index Config -#The root dir to store search merge_index data -merge_index.data_root = ./data/merge_index - -## Size, in bytes, of the in-memory buffer. When this -## threshold has been reached the data is transformed -## into a segment file which resides on disk. -merge_index.buffer_rollover_size = 1048576 - -## Overtime the segment files need to be compacted. -## This is the maximum number of segments that will be -## compacted at once. A lower value will lead to -## quicker but more frequent compactions. -merge_index.max_compact_segments = 20 - -## Configure how Bitcask writes data to disk. -## erlang: Erlang's built-in file API -## nif: Direct calls to the POSIX C API -## -## The NIF mode provides higher throughput for certain -## workloads, but has the potential to negatively impact -## the Erlang VM, leading to higher worst-case latencies -## and possible throughput collapse. -bitcask.io_mode = erlang - -bistcask.data_root = ./data/bitcask - -## eLevelDB Config -eleveldb.data_root = ./data/leveldb - -## log.syslog = on -log.error.file = /var/log/error.log -log.console.file = /var/log/console.log - -## Whether to write a crash log, and where. -## Commented/omitted/undefined means no crash logger. -log.crash.file = ./log/crash.log - -## Maximum size in bytes of events in the crash log - defaults to 65536 -log.crash.msg_size = 65536 - -## Maximum size of the crash log in bytes, before its rotated, set -## to 0 to disable rotation - default is 0 -log.crash.size = 10485760 - -## What time to rotate the crash log - default is no time -## rotation. See the lager README for a description of this format: -## https://github.com/basho/lager/blob/master/README.org -log.crash.date = $D0 - -## Number of rotated crash logs to keep, 0 means keep only the -## current one - default is 0 -log.crash.count = 5 - -## Whether to redirect error_logger messages into lager - defaults to true -log.error_logger_redirect = true - -## maximum number of error_logger messages to handle in a second -## lager 2.0.0 shipped with a limit of 50, which is a little low for riak's startup -log.error_logger_hwm = 100 - -## riak_sysmon will not be included in this file, but if you wanted to configure it from here, -## it would look a little something like this... hit it! - -## To disable forwarding events of a particular type, use a -## limit of 0. -riak.sysmon.process_limit = 30 -riak.sysmon.port_limit = 2 - -## Finding reasonable limits for a given workload is a matter -## of experimentation. -## NOTE: Enabling the 'gc_ms_limit' monitor (by setting non-zero) -## can cause performance problems on multi-CPU systems. -riak.sysmon.gc_ms_limit = 0 -riak.sysmon.heap_word_limit = 40111000 - -## Configure the following items to 'false' to disable logging -## of that event type. -riak.sysmon.busy_port = true -riak.sysmon.busy_dist_port = true - - -## SASL config -#jd# it's always off 'cause lager should handle this. we'll hide it. -sasl = off - -## riak_control -riak_control = disabled -riak_control.auth = userlist -#jd# this is like a proplist with the key as a subset of the -#jd# conf key, (e.g. 'user' and 'joe') -riak_control.user.user.password = pass -riak_control.user.joe.password = 12345 - -#jd# this should always be on, so why expose it? we're not going it! -riak_control.admin = true - -## should riak_control user/pass be in a different file? diff --git a/test/multi1.schema b/test/multi1.schema index a0491513..205be9ea 100644 --- a/test/multi1.schema +++ b/test/multi1.schema @@ -8,4 +8,4 @@ {translation, "what.ev2", fun(X) -> 1 end}. {translation, "what.ev1", fun(X) -> 3 end}. -{validator, "my.little.validator", "has the sweetest... smile", fun(_AlwaysTrue) -> true end}. \ No newline at end of file +{validator, "my.little.validator", "has the sweetest... smile", fun(_AlwaysTrue) -> true end}. diff --git a/test/multi2.schema b/test/multi2.schema index 425402c1..c019221f 100644 --- a/test/multi2.schema +++ b/test/multi2.schema @@ -1,3 +1,3 @@ {mapping, "a.b.c", "what.ev4", []}. -{translation, "what.ev1", fun(X) -> 4 end}. \ No newline at end of file +{translation, "what.ev1", fun(X) -> 4 end}. diff --git a/test/multi_backend.schema b/test/multi_backend.schema index 637ea8bc..03870af6 100644 --- a/test/multi_backend.schema +++ b/test/multi_backend.schema @@ -397,4 +397,4 @@ {datatype, {duration, s}}, {commented, "1d"}, %% no default, it's undefined. {level, advanced} -]}. \ No newline at end of file +]}. diff --git a/test/riak.conf b/test/riak.conf index 8ba60bad..259b49ab 100644 --- a/test/riak.conf +++ b/test/riak.conf @@ -4,4 +4,4 @@ log.error.file = /var/log/error.log log.console.file = /var/log/console.log log.syslog = on listener.http.internal = 127.0.0.1:8098 -listener.http.external = 10.0.0.1:80 \ No newline at end of file +listener.http.external = 10.0.0.1:80 diff --git a/test/riak.schema b/test/riak.schema index c0401bcd..858df7e6 100644 --- a/test/riak.schema +++ b/test/riak.schema @@ -1199,4 +1199,4 @@ end}. %% https://gist.github.com/evanmcc/a599f4c6374338ed672e {mapping, "erlang.swiffy", "vm_args.+sfwi", [ {commented, "500"} -]}. \ No newline at end of file +]}.