diff options
author | Tommy Carpenter <tommy@research.att.com> | 2017-09-25 16:28:17 -0400 |
---|---|---|
committer | Tommy Carpenter <tommy@research.att.com> | 2017-09-25 16:29:11 -0400 |
commit | 4d68a25267d0173b13e6238d76274dc874967872 (patch) | |
tree | 5a79bdd8b8c58f548a43ec6e6f1a3fbb6169b462 /src/util.erl | |
parent | aebd63152eec0fc8eff7b8757330c27a90849f49 (diff) |
Greatly increase unit tests
Issue-ID: DCAEGEN2-99
Change-Id: I03b62d8a54b8a6eb443f5ce648a92ff1f9953ade
Signed-off-by: Tommy Carpenter <tommy@research.att.com>
Diffstat (limited to 'src/util.erl')
-rw-r--r-- | src/util.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util.erl b/src/util.erl index 520b071..76f8bbf 100644 --- a/src/util.erl +++ b/src/util.erl @@ -34,7 +34,8 @@ to_str/1, ip_to_str/1, update_with_new_config_map/2, - ejson_to_map/1 + ejson_to_map/1, + get_envs/0 ]). %http://stackoverflow.com/questions/39757020/erlang-drying-up-stringbinary-concatenation @@ -48,11 +49,14 @@ resolve_cbs(XER, ConsulURL) -> {IP, Port} = consul_interface:consul_get_service_ip_port(XER, "config_binding_service", ConsulURL), concat(["http://", IP, ":", integer_to_binary(Port)]). +get_envs() -> + %breaking this out for mock testing of get_platform_envs_and_config() + {os:getenv("HOSTNAME"), os:getenv("CONSUL_HOST"), os:getenv("CDAP_CLUSTER_TO_MANAGE")}. + get_platform_envs_and_config() -> %Get platform envs needed for broker operation, then fetch my config. %If something critical fails, returns [], else [ConsulURL, CDAPUrl, BoundConfigMap] - MyName = os:getenv("HOSTNAME"), - ConsulHost = os:getenv("CONSUL_HOST"), + {MyName, ConsulHost, CDAPEnvName} = ?MODULE:get_envs(), case MyName == false orelse ConsulHost == false of true -> []; false -> @@ -69,7 +73,7 @@ get_platform_envs_and_config() -> %First, we will check for environmnental variables for a cluster *NAME* %If that is not found, then we will check out bound config for a fully bound URL %If that is also not found, let it crash baby. - CDAPURL = case os:getenv("CDAP_CLUSTER_TO_MANAGE") of + CDAPURL = case CDAPEnvName of false -> list_to_binary(concat(["http://", lists:nth(1, maps:get(<<"cdap_cluster_to_manage">>, BoundConfigMap))])); %cbs returns ip:port. need http:// or will get "no adaptors found" error CDAPName -> |