diff options
author | Ulf Wiger <ulf@wiger.net> | 2015-07-03 19:50:41 +0200 |
---|---|---|
committer | Ulf Wiger <ulf@wiger.net> | 2015-07-03 19:50:41 +0200 |
commit | 2b6beaeedad7be6d1047efa2293ef7941f7752d0 (patch) | |
tree | 45879a772d92e3bf7361e643bf68bc6def43c354 | |
parent | 2351d9db1eb0216bbc169a632e7686da6e1964ae (diff) | |
download | rvi_core-2b6beaeedad7be6d1047efa2293ef7941f7752d0.tar.gz |
first stab at test suite
-rw-r--r-- | Makefile | 5 | ||||
-rwxr-xr-x | scripts/setup_rvi_node.sh | 59 | ||||
-rw-r--r-- | test/rvi_core_SUITE.erl | 79 |
3 files changed, 116 insertions, 27 deletions
@@ -10,7 +10,7 @@ # Makefile for the RVI node. # -.PHONY: all deps compile clean rpm rpmclean +.PHONY: all deps compile clean rpm rpmclean test VERSION=0.4.0 @@ -39,6 +39,9 @@ rpmclean: ./rpm/SOURCES/* \ ./rpm/SRPMS/* +test: compile + rebar ct + # Create a SOURCES tarball for RPM rpm_tarball: rpmclean clean tar czf /tmp/rvi_core-$(VERSION).tgz BUILD.md CONFIGURE.md doc \ diff --git a/scripts/setup_rvi_node.sh b/scripts/setup_rvi_node.sh index e49a2bc..c7c93ba 100755 --- a/scripts/setup_rvi_node.sh +++ b/scripts/setup_rvi_node.sh @@ -26,6 +26,7 @@ alias realpath="python -c 'import os, sys; print os.path.realpath(sys.argv[1])'" SELF_DIR=$(dirname $(realpath "$0")) +TOP_DIR=$(dirname $SELF_DIR) SETUP_GEN=$SELF_DIR/setup_gen # Ulf's kitchen sink setup utility @@ -93,36 +94,42 @@ if [ -z "${CONFIG_NAME}" ] ; then fi -export ERL_LIBS=$PWD/components:$PWD/deps:$ERL_LIBS:$PWD +export ERL_LIBS=$TOP_DIR/components:$TOP_DIR/deps: +echo "ERL_LIBS=$ERL_LIBS" echo "Setting up node $NODE_NAME." rm -rf $NODE_NAME -$SETUP_GEN $NODE_NAME $CONFIG_NAME $NODE_NAME - -if [ "${build_type}" = "dev" ] +setupres=$( $SETUP_GEN $NODE_NAME $CONFIG_NAME $NODE_NAME -pa $TOP_DIR/ebin ) +if [ -z "${setupres}" ] then - echo "RVI Node $NODE_NAME has been setup." - echo "Launch with $SELF_DIR/rvi_node.sh -n $NODE_NAME" - exit -else - echo "Building stand alone release for $NODE_NAME" - # Copy the newly created config file. - rm -rf rel/$NODE_NAME - cp $NODE_NAME/sys.config rel/files/sys.config - ./rebar generate - # Rename the release after the node name - mv rel/rvi_core rel/$NODE_NAME - echo "Stand alone release for $NODE_NAME created under project " - echo "root directory's ./rel/$NODE_NAME." - echo - echo "Start: ./rel/$NODE_NAME/bin/rvi start" - echo "Attach console: ./rel/$NODE_NAME/bin/rvi attach" - echo "Stop: ./rel/$NODE_NAME/bin/rvi stop" - echo "Start console mode: ./rel/$NODE_NAME/bin/rvi console" - echo - echo "Start dev mode: ./rvi_node.sh -n $NODE_NAME" - echo - echo "./rel/$NODE_NAME can be copied and installed on its destination host." + if [ "${build_type}" = "dev" ] + then + echo "RVI Node $NODE_NAME has been setup." + echo "Launch with $SELF_DIR/rvi_node.sh -n $NODE_NAME" + exit + else + echo "Building stand alone release for $NODE_NAME" + # Copy the newly created config file. + rm -rf rel/$NODE_NAME + cp $NODE_NAME/sys.config rel/files/sys.config + ./rebar generate + # Rename the release after the node name + mv rel/rvi_core rel/$NODE_NAME + echo "Stand alone release for $NODE_NAME created under project " + echo "root directory's ./rel/$NODE_NAME." + echo + echo "Start: ./rel/$NODE_NAME/bin/rvi start" + echo "Attach console: ./rel/$NODE_NAME/bin/rvi attach" + echo "Stop: ./rel/$NODE_NAME/bin/rvi stop" + echo "Start console mode: ./rel/$NODE_NAME/bin/rvi console" + echo + echo "Start dev mode: ./rvi_node.sh -n $NODE_NAME" + echo + echo "./rel/$NODE_NAME can be copied and installed on its destination host." + fi +else + >&2 echo $setupres + exit 1 fi exit 0 diff --git a/test/rvi_core_SUITE.erl b/test/rvi_core_SUITE.erl new file mode 100644 index 0000000..3b1f666 --- /dev/null +++ b/test/rvi_core_SUITE.erl @@ -0,0 +1,79 @@ +-module(rvi_core_SUITE). + +%% common_test exports +-export( + [ + all/0, groups/0, suite/0, + init_per_suite/1, end_per_suite/1, + init_per_testcase/2, end_per_testcase/2 + ]). + +%% test case exports +-export( + [ + test_install_backend_node/1 + ]). + +-include_lib("common_test/include/ct.hrl"). + +all() -> + [ + {group, test_install} + ]. + +groups() -> + [ + {test_install, [shuffle], + [ + test_install_backend_node + ]} + ]. + +suite() -> + []. + +init_per_suite(Config) -> + Config. + +end_per_suite(_Config) -> + ok. + +init_per_testcase(_Case, Config) -> + Config. + +end_per_testcase(_Case, _Config) -> + ok. + +%% ====================================================================== +%% Test cases +%% ====================================================================== + +test_install_backend_node(Config) -> + ct:log("Current working dir: ~p", [file:get_cwd()]), + ct:log("Config = ~p", [Config]), + PrivDir = ?config(priv_dir, Config), + ct:log("PrivDir = ~p", [PrivDir]), + in_dir(PrivDir, fun(Cfg) -> install_backend_node_(Cfg) end, Config), + ok. + +install_backend_node_(_Config) -> + Root = code:lib_dir(rvi_core), + Scripts = filename:join(Root, "scripts"), + ct:log("Root = ~p", [Root]), + Cmd = lists:flatten( + ["RVI_LOGLEVEL=debug RVI_MYIP=127.0.0.1 ", + Scripts, "/setup_rvi_node.sh -d -n backend -c ", + Root, "/rvi_backend.config"]), + ct:log("Cmd = `~s`", [Cmd]), + Res = os:cmd(Cmd), + ct:log("install_backend_node/1 -> ~s", [Res]), + Res. + +in_dir(D, F, Cfg) -> + {ok, Cur} = file:get_cwd(), + try + ok = file:set_cwd(D), + F(Cfg) + after + file:set_cwd(Cur) + end. |