From d22fbfbdc7a7b5dd7d9a9be8f333f187e85d453c Mon Sep 17 00:00:00 2001 From: Russell Brown Date: Tue, 27 Jan 2015 09:53:15 +0000 Subject: [PATCH] Persuade rtdev harness to set advanced.config variables In the case that no advanced.config file exists (everycase!) rt would not add any advanced config settings to the conf. This PR teaches rtdev to create an advanced.comfig file if none exists so that tests may set advanced config. In this case we set ring_size and also the `crdt_mixed_versions` app env --- src/rtdev.erl | 25 ++++++++++++++++++++++++- tests/riak667_mixed.erl | 9 ++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/rtdev.erl b/src/rtdev.erl index cd620b8f..5147917e 100644 --- a/src/rtdev.erl +++ b/src/rtdev.erl @@ -178,9 +178,32 @@ set_advanced_conf(Node, NameValuePairs) when is_atom(Node) -> append_to_conf_file(get_advanced_riak_conf(Node), NameValuePairs), ok; set_advanced_conf(DevPath, NameValuePairs) -> - [update_app_config_file(RiakConf, NameValuePairs) || RiakConf <- all_the_files(DevPath, "etc/advanced.config")], + AdvancedConfs = case all_the_files(DevPath, "etc/advanced.config") of + [] -> + %% no advanced conf? But we _need_ them, so make 'em + make_advanced_confs(DevPath); + Confs -> + Confs + end, + [update_app_config_file(RiakConf, NameValuePairs) || RiakConf <- AdvancedConfs], ok. +make_advanced_confs(DevPath) -> + case filelib:is_dir(DevPath) of + false -> + lager:debug("Failed generating advanced.conf ~p is not a directory.", [DevPath]); + true -> + Wildcard = io_lib:format("~s/dev/dev*/etc", [DevPath]), + ConfDirs = filelib:wildcard(Wildcard), + [ + begin + AC = filename:join(Path, "advanced.config"), + lager:debug("writing advanced.conf to ~p", [AC]), + file:write_file(AC, io_lib:fwrite("~p.\n",[[]])), + AC + end || Path <- ConfDirs] + end. + get_riak_conf(Node) -> N = node_id(Node), Path = relpath(node_version(N)), diff --git a/tests/riak667_mixed.erl b/tests/riak667_mixed.erl index 197609fe..dc5a50c6 100644 --- a/tests/riak667_mixed.erl +++ b/tests/riak667_mixed.erl @@ -46,6 +46,8 @@ confirm() -> CurrentVer = rt:get_version(), + lager:info("crdt_mixed_versions? ~p", [rpc:multicall(Nodes, application, get_env, [riak_kv, crdt_mixed_versions])]), + %% Create PB connection. Pid = rt:pbc(Node1), riakc_pb_socket:set_options(Pid, [queue_if_disconnected]), @@ -216,10 +218,15 @@ confirm() -> ?assert(map_contents_are_lists(Robj1)), {ok, Robj2} = riakc_pb_socket:get(Pid4, ?BUCKET, ?KEY2), + + lager:info("crdt_mixed_versions? ~p", [rpc:multicall(Nodes, application, get_env, [riak_kv, crdt_mixed_versions])]), + ?assert(map_contents_are_lists(Robj2)), %% unset env var rpc:multicall(Nodes, application, set_env, [riak_kv, crdt_mixed_versions, false]), + lager:info("crdt_mixed_versions? ~p", [rpc:multicall(Nodes, application, get_env, [riak_kv, crdt_mixed_versions])]), + %% read and write maps {ok, Up1N1} = riakc_pb_socket:fetch_type(Pid4, ?BUCKET, ?KEY), {ok, Up1N2} = riakc_pb_socket:fetch_type(Pid3, ?BUCKET, ?KEY), @@ -309,7 +316,7 @@ nested_are_dicts(Entries) -> end, true, CRDTs); (_) -> true - end, Entries). + end, dict:to_list(Entries)). set_is_dict({_Clock, Entries, Deferred}) -> is_dict(Entries) andalso is_dict(Deferred).