From a8bbad4c4370b57b1c8285d661bdcd6620c884f8 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Tue, 13 Mar 2018 12:25:28 -0700 Subject: [PATCH] Circle 2.0 (#4650) * move circle config to 2.0 location * fail if error log has errors * address concern * echo it then exit --- .circleci/config.yml | 125 ++++++++++++++++++ Makefile | 6 +- .../crossbar/src/crossbar_maintenance.erl | 5 +- circle.yml | 65 --------- core/kazoo_apps/src/kapps_controller.erl | 14 +- core/kazoo_apps/src/kapps_maintenance.erl | 59 +++++++++ core/sup/Makefile | 2 +- core/sup/src/sup.erl | 60 ++++++--- rel/ci.relx.config | 3 +- rel/ci.vm.args | 2 + scripts/README.md | 6 - scripts/check-release-startup.sh | 73 ---------- scripts/circleci-build-erlang.sh | 9 ++ scripts/dev/kazoo.sh | 10 +- 14 files changed, 263 insertions(+), 176 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml delete mode 100755 scripts/check-release-startup.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..0b683217aca --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,125 @@ +# This configuration was automatically generated from a CircleCI 1.0 config. +# It should include any build commands you had along with commands that CircleCI +# inferred from your project structure. We strongly recommend you read all the +# comments in this file to understand the structure of CircleCI 2.0, as the idiom +# for configuration has changed substantially in 2.0 to allow arbitrary jobs rather +# than the prescribed lifecycle of 1.0. In general, we recommend using this generated +# configuration as a reference rather than using it in production, though in most +# cases it should duplicate the execution of your original 1.0 config. +version: 2 +jobs: + build: + working_directory: ~/2600hz/kazoo + shell: /bin/bash --login + # CircleCI 2.0 does not support environment variables that refer to each other the same way as 1.0 did. + # If any of these refer to each other, rewrite them so that they don't or see https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables . + environment: + CIRCLE_ARTIFACTS: /tmp/circleci-artifacts + CIRCLE_TEST_REPORTS: /tmp/circleci-test-results + TZ: "/usr/share/zoneinfo/UTC" + # In CircleCI 1.0 we used a pre-configured image with a large number of languages and other packages. + # In CircleCI 2.0 you can now specify your own image, or use one of our pre-configured images. + # The following configuration line tells CircleCI to use the specified docker image as the runtime environment for you job. + # We have selected a pre-built image that mirrors the build environment we use on + # the 1.0 platform, but we recommend you choose an image more tailored to the needs + # of each job. For more information on choosing an image (or alternatively using a + # VM instead of a container) see https://circleci.com/docs/2.0/executor-types/ + # To see the list of pre-built images that CircleCI provides for most common languages see + # https://circleci.com/docs/2.0/circleci-images/ + docker: + - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37 + command: /sbin/init + - image: couchdb:2.1.1 + - image: rabbitmq:3.7 + - image: circleci/python:3.6.1 + + steps: + # Machine Setup + # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each + # The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out. + - checkout + # Prepare for artifact and test results collection equivalent to how it was done on 1.0. + # In many cases you can simplify this from what is generated here. + # 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/' + - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS + # This is based on your 1.0 configuration file or project settings + - run: + working_directory: ~/2600hz/kazoo + command: echo -e "export OTP_VERSION=$(<~/2600hz/kazoo/make/erlang_version)\nexport PATH=${HOME}/.kerl/$OTP_VERSION/bin:${PATH}\n" >> $BASH_ENV + # - run: + # working_directory: ~/2600hz/kazoo + # command: 'sudo service rabbitmq-server status || sudo service rabbitmq-server + # start; sudo docker info >/dev/null 2>&1 || sudo service docker start; ' + # Dependencies + # This would typically go in either a build or a build-and-test job when using workflows + # Restore the dependency cache + - restore_cache: + keys: + # This branch if available + - v1-dep-{{ .Branch }}- + # Default branch if not + - v1-dep-master- + # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly + - v1-dep- + # This is based on your 1.0 configuration file or project settings + - run: echo -e "\n. ~/.kerl/$OTP_VERSION/activate\n" >> $BASH_ENV + - run: + command: bash ./scripts/circleci-build-erlang.sh + no_output_timeout: 1800s + - run: which ag >/dev/null 2>&1 || sudo apt-get update; sudo apt-get install silversearcher-ag + - run: sudo pip install --upgrade pip + - run: sudo pip install PyYAML mkdocs pyembed-markdown jsonschema + # Save dependency cache + - save_cache: + key: v1-dep-{{ .Branch }}-{{ epoch }} + paths: + # These cache paths were specified in the 1.0 config + - ~/.kerl + - ~/.local/ + # Test + # This would typically be a build job when using workflows, possibly combined with build + # This is based on your 1.0 configuration file or project settings + - run: echo -e "\nexport CHANGED=\"$(git --no-pager diff --name-only HEAD origin/master -- applications core)\"\nexport CHANGED_SWAGGER=\"$(git --no-pager diff --name-only HEAD origin/master -- applications/crossbar/priv/api/swagger.json)\"\n" >> $BASH_ENV + - run: echo $CHANGED + - run: ./scripts/state-of-docs.sh || true + - run: ./scripts/code_checks.bash $($CHANGED) + - run: make fmt + - run: JOBS="2" make + - run: make code_checks + - run: make app_applications + - run: ./scripts/validate-js.sh $($CHANGED) + - run: make apis + - run: make docs + - run: make validate-schemas + - run: ./scripts/state-of-edoc.escript + - run: make xref + - run: make sup_completion + - run: | + if [[ ! -z "$($CHANGED)" ]]; then + make build-plt + TO_DIALYZE="$(echo $($CHANGED))" make dialyze + fi + - run: make elvis + - run: make build-ci-release + - run: ${PWD}/scripts/check-unstaged.bash + - run: KAZOO_CONFIG=${PWD}/rel/ci.config.ini REL="kazoo_apps" ACT="console" NODE_NAME_TYPE="-sname" make release + - run: | + if [[ $(grep -c -v -F 'exit with reason shutdown' ${PWD}/_rel/kazoo/log/error.log) -gt 0 ]]; then + cat ${PWD}/_rel/kazoo/log/error.log + exit 1 + fi + # This is based on your 1.0 configuration file or project settings + - run: mkdir $CIRCLE_ARTIFACTS/logs + - run: mv ${PWD}/_rel/kazoo/log/* $CIRCLE_ARTIFACTS/logs/ + - run: cp ${PWD}/rel/ci.relx.config $CIRCLE_ARTIFACTS/ + - run: find ${PWD}/_rel/kazoo/releases -name kazoo.rel -exec cp {} $CIRCLE_ARTIFACTS/ \; + # Teardown + # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each + # Save test results + - store_test_results: + path: /tmp/circleci-test-results + # Save artifacts + - store_artifacts: + path: /tmp/circleci-artifacts + - store_artifacts: + path: /tmp/circleci-test-results diff --git a/Makefile b/Makefile index 8fa58c6446a..c7b681be875 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ release: ACT ?= console # start | attach | stop | console | foreground release: REL ?= kazoo_apps # kazoo_apps | ecallmgr | … release: COOKIE ?= change_me release: - @NODE_NAME="$(REL)" COOKIE="$(COOKIE)" $(ROOT)/scripts/dev/kazoo.sh $(ACT) "$$@" + NODE_NAME="$(REL)" COOKIE="$(COOKIE)" $(ROOT)/scripts/dev/kazoo.sh $(ACT) "$$@" install: compile build-release cp -a _rel/kazoo /opt @@ -150,14 +150,12 @@ xref_release: TO_XREF = $(shell find $(ROOT)/_rel/kazoo/lib -name ebin) xref_release: @$(ROOT)/scripts/check-xref.escript $(TO_XREF) - sup_completion: sup_completion_file = $(ROOT)/sup.bash -sup_completion: kazoo +sup_completion: @$(if $(wildcard $(sup_completion_file)), rm $(sup_completion_file)) @$(ROOT)/core/sup/priv/build-autocomplete.escript $(sup_completion_file) applications/ core/ @echo SUP Bash completion file written at $(sup_completion_file) - $(ELVIS): wget 'https://github.com/inaka/elvis/releases/download/0.2.12/elvis' -O $@ chmod +x $@ diff --git a/applications/crossbar/src/crossbar_maintenance.erl b/applications/crossbar/src/crossbar_maintenance.erl index 716c7999a02..c6fa0c9a04a 100644 --- a/applications/crossbar/src/crossbar_maintenance.erl +++ b/applications/crossbar/src/crossbar_maintenance.erl @@ -340,7 +340,10 @@ demote_account(AccountId) -> %%------------------------------------------------------------------------------ -spec create_account(input_term(), input_term(), input_term(), input_term()) -> 'ok' | 'failed'. create_account(AccountName, Realm, Username, Password) - when is_binary(AccountName), is_binary(Realm), is_binary(Username), is_binary(Password) -> + when is_binary(AccountName), + is_binary(Realm), + is_binary(Username), + is_binary(Password) -> Account = kz_json:from_list([{<<"_id">>, kz_datamgr:get_uuid()} ,{<<"name">>, AccountName} ,{<<"realm">>, Realm} diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 5e046de48f9..00000000000 --- a/circle.yml +++ /dev/null @@ -1,65 +0,0 @@ -machine: - environment: - OTP_VERSION: 19.3 - PATH: ${HOME}/.kerl/$OTP_VERSION/bin:${PATH} - CHANGED: 'git --no-pager diff --name-only HEAD origin/master -- applications core' - CHANGED_SWAGGER: 'git --no-pager diff --name-only HEAD origin/master -- applications/crossbar/priv/api/swagger.json' - services: - - rabbitmq-server - - docker -# - couchdb-server - -general: - branches: - ignore: - - /3\.[0-9]+/ - - 4.0 - -dependencies: - cache_directories: - - ~/.kerl - pre: - - bash ./scripts/circleci-build-erlang.sh: - timeout: 1800 - - which ag >/dev/null 2>&1 || sudo apt-get update; sudo apt-get install silversearcher-ag - - pip install --upgrade pip - - pip install PyYAML mkdocs pyembed-markdown jsonschema - -test: - pre: - - $CHANGED - - ./scripts/state-of-docs.sh || true - - ./scripts/code_checks.bash $($CHANGED) - - make fmt - # - if [[ "$CIRCLE_BRANCH" = 'master' ]]; then make bump-copyright; fi - - . ~/.kerl/$OTP_VERSION/activate && JOBS="1" make - - . ~/.kerl/$OTP_VERSION/activate && make code_checks - - . ~/.kerl/$OTP_VERSION/activate && make app_applications - - ./scripts/validate-js.sh $($CHANGED) - - . ~/.kerl/$OTP_VERSION/activate && make apis - - make docs - - make validate-schemas - - . ~/.kerl/$OTP_VERSION/activate && ./scripts/state-of-edoc.escript - # - | - # if [[ ! -z "$($CHANGED_SWAGGER)" ]]; then - # make validate-swagger - # npm install swagger-tools && time ./node_modules/swagger-tools/bin/swagger-tools validate applications/crossbar/priv/api/swagger.json - # make sdks - # fi - - ./scripts/check-unstaged.bash - - . ~/.kerl/$OTP_VERSION/activate && make xref - - . ~/.kerl/$OTP_VERSION/activate && make sup_completion - - | - . ~/.kerl/$OTP_VERSION/activate - if [[ ! -z "$($CHANGED)" ]]; then - make build-plt - TO_DIALYZE="$(echo $($CHANGED))" make dialyze - fi - - . ~/.kerl/$OTP_VERSION/activate && make elvis - - . ~/.kerl/$OTP_VERSION/activate && make build-ci-release - - . ~/.kerl/$OTP_VERSION/activate && ./scripts/check-release-startup.sh - post: - - mkdir $CIRCLE_ARTIFACTS/logs - - mv ./_rel/kazoo/log/* $CIRCLE_ARTIFACTS/logs/ - - cp ./rel/ci.relx.config $CIRCLE_ARTIFACTS/ - - find ./_rel/kazoo/releases -name kazoo.rel -exec cp {} $CIRCLE_ARTIFACTS/ \; diff --git a/core/kazoo_apps/src/kapps_controller.erl b/core/kazoo_apps/src/kapps_controller.erl index 7663299d1b1..89788748bd4 100644 --- a/core/kazoo_apps/src/kapps_controller.erl +++ b/core/kazoo_apps/src/kapps_controller.erl @@ -36,9 +36,14 @@ start_link() -> -spec ready() -> boolean(). ready() -> - Configured = start_which_kapps(), - Running = [kz_term:to_binary(App) || App <- running_apps()], - lists:subtract(Configured, Running) =:= []. + Configured = [kz_term:to_binary(App) || App <- start_which_kapps()], + Running = [kz_term:to_binary(App) || App <- running_apps(), is_atom(App)], + + 0 =:= sets:size( + sets:subtract(sets:from_list(Configured) + ,sets:from_list(Running) + ) + ). -spec start_default_apps() -> [{atom(), 'ok' | {'error', any()}}]. start_default_apps() -> @@ -151,7 +156,8 @@ maybe_start_from_env() -> "noenv" -> 'false'; KazooApps -> lager:info("starting applications specified in environment variable KAZOO_APPS: ~s" - ,[KazooApps]), + ,[KazooApps] + ), string:tokens(KazooApps, ", ") end. diff --git a/core/kazoo_apps/src/kapps_maintenance.erl b/core/kazoo_apps/src/kapps_maintenance.erl index f1616c3bda5..045d1d38605 100644 --- a/core/kazoo_apps/src/kapps_maintenance.erl +++ b/core/kazoo_apps/src/kapps_maintenance.erl @@ -58,6 +58,8 @@ -export([init_system/0, init_dbs/0]). +-export([check_release/0]). + -include_lib("kazoo_caches/include/kazoo_caches.hrl"). -include("kazoo_apps.hrl"). @@ -1081,3 +1083,60 @@ init_system() -> init_dbs(), register_account_views(), lager:notice("system initialized"). + +-spec check_release() -> 'ok' | 'error'. +check_release() -> + Checks = [fun kapps_started/0 + ,fun master_account_created/0 + ,fun migration_4_0_ran/0 + ,fun migration_ran/0 + ], + try lists:foreach(fun(F) -> F() end, Checks) of + 'ok' -> lager:info("check_release/0 succeeded"), init:stop() + catch + 'throw':Error -> + lager:error("check_release/0 failed: ~p", [Error]), + halt(1); + _E:_R -> + lager:error("check_release/0 crashed: ~s: ~p", [_E, _R]), + halt(1) + end. + +-spec kapps_started() -> boolean(). +kapps_started() -> + kapps_started(180 * ?MILLISECONDS_IN_SECOND). + +-spec kapps_started(integer()) -> 'true'. +kapps_started(Timeout) when Timeout > 0 -> + kapps_controller:ready() + orelse begin + timer:sleep(100), + kapps_started(Timeout - 100) + end; +kapps_started(_Timeout) -> + lager:error("timed out waiting for kapps to start"), + throw({'error', 'timeout'}). + +-spec master_account_created() -> 'true'. +master_account_created() -> + case rpc:call(node() + ,'crossbar_maintenance' + ,'create_account' + ,[<<"compte_maitre">> + ,<<"royaume">> + ,<<"superduperuser">> + ,<<"pwd!">> + ] + ) + of + 'ok' -> 'true'; + 'failed' -> throw({'error', 'create_account'}) + end. + +-spec migration_4_0_ran() -> boolean(). +migration_4_0_ran() -> + 'no_return' =:= migrate_to_4_0(). + +-spec migration_ran() -> boolean(). +migration_ran() -> + 'no_return' =:= migrate(). diff --git a/core/sup/Makefile b/core/sup/Makefile index 9033ea5ab2c..6b2102b2905 100644 --- a/core/sup/Makefile +++ b/core/sup/Makefile @@ -6,7 +6,7 @@ CLEAN_MOAR = clean-escript all: compile $(ESCRIPT) -$(ESCRIPT): +$(ESCRIPT): src/sup.erl @$(REBAR) escriptize clean-escript: diff --git a/core/sup/src/sup.erl b/core/sup/src/sup.erl index 52859cd4fe6..17d5e31098d 100644 --- a/core/sup/src/sup.erl +++ b/core/sup/src/sup.erl @@ -27,15 +27,19 @@ main(CommandLineArgs) -> main(CommandLineArgs, Loops) -> _ = os:cmd("epmd -daemon"), _ = net_kernel:stop(), - SUPName = my_name(), - case net_kernel:start([SUPName, long_or_short_name()]) of - {'error', _} when Loops < 3 -> - stderr("Unable to start command bridge network kernel, try again", []), + + {'ok', Options, Args} = parse_args(CommandLineArgs), + + SUPName = my_name(use_short(Options)), + + case net_kernel:start([SUPName, long_or_short_name(use_short(Options))]) of + {'error', _E} when Loops < 3 -> + stderr("Unable to start command bridge network kernel (~p), try again", [_E]), halt(1); - {'error', _} -> + {'error', _E} -> + io:format("failed to start command bridge network kernel (~p), trying again (~p)~n", [_E, Loops]), main(CommandLineArgs, Loops + 1); {'ok', _} -> - {'ok', Options, Args} = parse_args(CommandLineArgs), lists:member('help', Options) andalso print_help(), IsVerbose = props:get_value('verbose', Options) =/= 'undefined', @@ -111,10 +115,8 @@ print_result(Result, 'false') -> -spec get_target(kz_term:proplist(), boolean()) -> atom(). get_target(Options, Verbose) -> - Node = props:get_value('node', Options), - Host = get_host(), - Cookie = get_cookie(Options, list_to_atom(Node)), - Target = list_to_atom(Node ++ "@" ++ Host), + Cookie = get_cookie(Options, list_to_atom(props:get_value('node', Options))), + Target = get_target(Options), case net_adm:ping(Target) of 'pong' -> Verbose @@ -125,11 +127,26 @@ get_target(Options, Verbose) -> print_ping_failed(Target, Cookie) end. +-spec get_target(kz_term:proplist()) -> atom(). +get_target(Options) -> + build_target(Options, use_short(Options)). + +-spec build_target(kz_term:proplist(), kz_term:api_boolean()) -> atom(). +build_target(Options, 'true') -> + Node = props:get_value('node', Options), + [First | _] = string:tokens(get_host(), "."), + + kz_term:to_atom(Node ++ [$@ | First], 'true'); +build_target(Options, _) -> + Node = props:get_value('node', Options), + Host = get_host(), + list_to_atom(Node ++ "@" ++ Host). + -spec get_cookie(kz_term:proplist(), atom()) -> atom(). get_cookie(Options, Node) -> CookieStr = - case { props:get_value('cookie', Options, "") - , kazoo_config_init:read_cookie(Node) + case {props:get_value('cookie', Options, "") + ,kazoo_config_init:read_cookie(Node) } of {C, []} when C =/= "" -> C; @@ -153,17 +170,21 @@ get_host() -> print_unresolvable_host(Host) end. --spec my_name() -> node(). -my_name() -> +-spec my_name(kz_term:api_boolean()) -> node(). +my_name('true') -> + kz_term:to_atom(iolist_to_binary(["sup_", kz_binary:rand_hex(2)]), 'true'); +my_name(_) -> Name = iolist_to_binary(["sup_", kz_binary:rand_hex(2), $@, localhost()]), - kz_term:to_atom(Name, true). + kz_term:to_atom(Name, 'true'). -spec localhost() -> nonempty_string(). localhost() -> net_adm:localhost(). --spec long_or_short_name() -> 'longnames' | 'shortnames'. -long_or_short_name() -> +-spec long_or_short_name(kz_term:api_boolean()) -> 'longnames' | 'shortnames'. +long_or_short_name('true') -> + 'shortnames'; +long_or_short_name(_) -> IsDot = fun ($.) -> 'true'; (_) -> 'false' end, case lists:any(IsDot, localhost()) of 'true' -> 'longnames'; @@ -232,6 +253,7 @@ option_spec_list() -> ,{'verbose', $v, "verbose", 'undefined', "Be verbose"} ,{'module', 'undefined', 'undefined', 'string', "The name of the remote module"} ,{'function', 'undefined', 'undefined', 'string', "The name of the remote module's function"} + ,{'use_short', $s, "use_short", {'boolean', 'undefined'}, "Force using shortnames"} ]. -spec from_env(list(), list()) -> list(). @@ -241,4 +263,8 @@ from_env(Name, Default) -> Value -> Value end. +-spec use_short(kz_term:proplist()) -> kz_term:api_boolean(). +use_short(Options) -> + props:get_value('use_short', Options). + %%% End of Module diff --git a/rel/ci.relx.config b/rel/ci.relx.config index bee45738be0..cbe1441a9c9 100644 --- a/rel/ci.relx.config +++ b/rel/ci.relx.config @@ -13,8 +13,7 @@ {sys_config, "rel/ci.sys.config"}. {vm_args, "rel/ci.vm.args"}. -{overlay, [{copy, "../core/sup/priv/sup", "{{output_dir}}/bin/"} +{overlay, [{copy, "../core/sup/sup", "{{output_dir}}/bin/"} ,{copy, "nodetool", "{{output_dir}}/bin/"} ,{template, "kazoo", "{{output_dir}}/bin/kazoo"} ]}. - diff --git a/rel/ci.vm.args b/rel/ci.vm.args index 578428192e6..49e5682fac4 100644 --- a/rel/ci.vm.args +++ b/rel/ci.vm.args @@ -30,3 +30,5 @@ -env ERL_CRASH_DUMP_NICE 1 -s kazoo_apps_app + +-s kapps_maintenance check_release \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md index 1dd5818988a..ce93776d2e0 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -65,11 +65,6 @@ Typically \`TO\_DIALYZE\` would be a generated list of files. Do note: this will only check the file itself for issues. To really leverage Dialyzer, you'll want to include remote project modules for Dialyzer to use as well. -## check-release-startup.sh - -Creates a release, starts it, and issues some commands to test that the release starts up and appears to be running - - ## check-scripts-readme.bash A quick script to check that all scripts in `$(ROOT)/scripts` are documented in this file! @@ -813,4 +808,3 @@ returns next release based on branch & tags. ## `increment_version.bash` routine to increment a version - diff --git a/scripts/check-release-startup.sh b/scripts/check-release-startup.sh deleted file mode 100755 index 417ff5e023c..00000000000 --- a/scripts/check-release-startup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -e -[[ ! -d _rel ]] && echo 'Cannot find _rel/ Is the release built?' && exit -1 - -echo "Checking release startup..." - -REL_DIR=$(dirname $(readlink -f $0))/../_rel/kazoo -PATH=$PATH:$(dirname $0):${REL_DIR}/bin -export PATH -LOG_DIR=${REL_DIR}/log -export LOG_DIR -mkdir -p ${LOG_DIR} - -shutdown() { - sup init stop - exit 0 -} - -waitfor() { -TIMEOUT=${1:-"120"} -SEARCH_TERM=${2:-"nada"} -echo "waiting for '$SEARCH_TERM'" -(timeout --foreground $TIMEOUT tail -f ${LOG_DIR}/debug.log 2>&1 &) | grep -q "$SEARCH_TERM" && echo "found '$SEARCH_TERM'" && return 0 -echo "timeout waiting for '$SEARCH_TERM'" > ${LOG_DIR}/error.log -echo "timeout waiting for '$SEARCH_TERM'" -return 1 -} - - -script() { - touch ${LOG_DIR}/debug.log - touch ${LOG_DIR}/error.log - waitfor 180 "auto-started kapps" || shutdown - echo "creating account" - sup crossbar_maintenance create_account 'compte_maitre' 'royaume' 'superduperuser' 'pwd!' || shutdown - echo "running account created" - sleep 3 - echo "running migrate" - sup kapps_maintenance migrate || shutdown - sleep 3 - echo "running migrate to 4" - sup kapps_maintenance migrate_to_4_0 || shutdown - sleep 9 - shutdown -} - -export KAZOO_NODE=apps -export KAZOO_COOKIE=change_me - -script > _rel/kazoo/log/sup.log 2>${LOG_DIR}/error.log & - -export KAZOO_CONFIG=$(dirname $(readlink -f $0))/../rel/ci.config.ini -kazoo console - -code=$? - -if [[ -f erl_crash.dump ]]; then - echo A crash dump was generated! - code=3 -fi - -error_log="${LOG_DIR}/error.log" -if [[ -f $error_log ]]; then - echo - echo Error log: - cat "$error_log" - if [[ $(grep -c -v -F 'exit with reason shutdown' "$error_log") -gt 0 ]]; then - echo - echo "Found errors in $error_log" - code=4 - fi -fi - -exit $code diff --git a/scripts/circleci-build-erlang.sh b/scripts/circleci-build-erlang.sh index 085c48f18d9..a924b46d247 100644 --- a/scripts/circleci-build-erlang.sh +++ b/scripts/circleci-build-erlang.sh @@ -1,6 +1,13 @@ #!/bin/bash set -x set -e + +pushd $(dirname $0) > /dev/null +cd $(pwd -P)/.. + +KAZOO_OTP_VERSION=$(<./make/erlang_version) +OTP_VERSION=${OTP_VERSION:-$KAZOO_OTP_VERSION} + if [[ ! -d ~/.kerl/$OTP_VERSION ]]; then if [[ ! -d ~/.kerl ]]; then mkdir ~/.kerl @@ -11,3 +18,5 @@ if [[ ! -d ~/.kerl/$OTP_VERSION ]]; then ~/.kerl/kerl build $OTP_VERSION $OTP_VERSION ~/.kerl/kerl install $OTP_VERSION ~/.kerl/$OTP_VERSION fi + +popd > /dev/null diff --git a/scripts/dev/kazoo.sh b/scripts/dev/kazoo.sh index 439fbe51860..a3e08fc6d51 100755 --- a/scripts/dev/kazoo.sh +++ b/scripts/dev/kazoo.sh @@ -1,7 +1,11 @@ #!/bin/bash +pushd "$(dirname "$0")" >/dev/null + +ROOT="$(pwd -P)"/../.. + # look for kazoo release root directory -DEFAULT_ROOT=${KAZOO_ROOT:-_rel/kazoo} +DEFAULT_ROOT=${KAZOO_ROOT:-${ROOT}/_rel/kazoo} if [ -d "$DEFAULT_ROOT/_rel/kazoo" ]; then DEFAULT_ROOT="$DEFAULT_ROOT/_rel/kazoo" elif [ -d "$DEFAULT_ROOT/bin" ]; then @@ -12,6 +16,7 @@ elif [ -d /opt/kazoo/bin ]; then DEFAULT_ROOT="/opt/kazoo" else echo "Can't find Kazoo release root directory, is the release built?" + echo "Checked ${DEFAULT_ROOT} for release and bin dir" exit -1 fi echo "Release path: $DEFAULT_ROOT" @@ -31,8 +36,7 @@ else fi echo "Kazoo config file path: $KAZOO_CONFIG" -HOSTNAME="$(hostname -f)" -NODE_NAME=${NODE_NAME:-"kazoo_apps@$HOSTNAME"} +NODE_NAME=${NODE_NAME:-"kazoo_apps"} echo "Node name: $NODE_NAME" COOKIE=${COOKIE:-"change_me"}