diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d849950b874becb75d79728053cb9cfe5579735..02a58c25d1495a701db1f4dbeb665546d4eb9599 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,11 +49,11 @@ test:all: - echo "REPO_USER=${REPO_USER}" > $CI_PROJECT_DIR/reporc - echo "REPO_PASS=${REPO_PASS}" >> $CI_PROJECT_DIR/reporc - sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR -c all - - sudo mkdir /var/lib/lxd/containers/test-runner/rootfs/vagrant/build - - sudo cp build/clmctest-1.3.0.tar.gz /var/lib/lxd/containers/test-runner/rootfs/vagrant/build - - sudo cp build/clmcservice-1.3.0.tar.gz /var/lib/lxd/containers/test-runner/rootfs/vagrant/build - - sudo lxc exec test-runner -- pip3 install /vagrant/build/clmctest-1.3.0.tar.gz - - sudo lxc exec test-runner -- pip3 install /vagrant/build/clmcservice-1.3.0.tar.gz + - sudo mkdir /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build + - sudo cp build/clmctest-1.3.0.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build + - sudo cp build/clmcservice-1.3.0.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build + - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-1.3.0.tar.gz + - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmcservice-1.3.0.tar.gz - sudo lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs clmctest when: on_success diff --git a/scripts/clmc-service/install.sh b/scripts/clmc-service/install.sh index f1a7aa1c828632351940b2ff5362e1c4650335a0..e3e059135cbfde46f5ceeb5babe66c0e384025fd 100755 --- a/scripts/clmc-service/install.sh +++ b/scripts/clmc-service/install.sh @@ -37,6 +37,8 @@ cd `dirname $0` echo "Provisioning CLMC service" +export REPO_ROOT=${REPO_ROOT} + ./install-tick-stack.sh ./install-neo4j.sh ./install-clmc-service.sh \ No newline at end of file diff --git a/scripts/test/fixture.sh b/scripts/test/fixture.sh index 8c568ff2dc1ae36294af8484850bf3d79da9decd..72f3de47e9194256cbb629146a0d391017e47854 100755 --- a/scripts/test/fixture.sh +++ b/scripts/test/fixture.sh @@ -1,6 +1,7 @@ #!/bin/bash repo_root="/vagrant" +target_root="/opt/clmc" config_file="rspec.json" usage() { @@ -31,12 +32,12 @@ create() { # copy flame clmc files into the root container echo "Copying files to rootfs" container_dir="/var/lib/lxd/containers/"${service_name}"/rootfs" - container_vagrant_dir=${container_dir}"/vagrant" - mkdir -p ${container_vagrant_dir} - cp -f ${repo_root}/reporc ${container_vagrant_dir} - cp -rf ${repo_root}/scripts ${container_vagrant_dir} - cp -rf ${repo_root}/src ${container_vagrant_dir} - chown -R 100000:100000 ${container_vagrant_dir} + container_repo_root=${container_dir}${target_root} + mkdir -p ${container_repo_root} + cp -f ${repo_root}/reporc ${container_repo_root} + cp -rf ${repo_root}/scripts ${container_repo_root} + cp -rf ${repo_root}/src ${container_repo_root} + chown -R 100000:100000 ${container_repo_root} # start the container echo "Starting: ${service_name}" @@ -50,9 +51,9 @@ create() { # provision software into each container echo "Provisioning: ${service_name}" if [ ${service_name} == "clmc-service" ]; then - cmd="/vagrant/scripts/clmc-service/install.sh" + cmd="${target_root}/scripts/clmc-service/install.sh" echo "Provisioning command ${cmd}" - lxc exec ${service_name} --env REPO_ROOT="/vagrant" --env SFEMC_FQDN="sfemc.localhost" -- ${cmd} + lxc exec ${service_name} --env REPO_ROOT=${target_root} --env SFEMC_FQDN="sfemc.localhost" -- ${cmd} exit_code=$? if [ $exit_code != 0 ]; then echo "clmc-service installation failed with exit code ${exit_code}" @@ -60,7 +61,7 @@ create() { fi elif [ ${service_name} == "test-runner" ] then - cmd=/vagrant/src/test/clmctest/services/pytest/install.sh + cmd="${target_root}/src/test/clmctest/services/pytest/install.sh" lxc exec ${service_name} -- ${cmd} exit_code=$? if [ $exit_code != 0 ]; then @@ -78,16 +79,16 @@ create() { influxdb_url=$(echo $SERVICE | jq -r '.influxdb_url') # install service function specific software - cmd=/vagrant/src/test/clmctest/services/${sf_package_id}/install.sh - lxc exec ${service_name} --env REPO_ROOT="/vagrant" -- ${cmd} + cmd="${target_root}/src/test/clmctest/services/${sf_package_id}/install.sh" + lxc exec ${service_name} --env REPO_ROOT="${target_root}" -- ${cmd} exit_code=$? if [ $exit_code != 0 ]; then echo "${sf_package_id} installation failed with exit code ${exit_code}" exit 1 fi # install telegraf - cmd=/vagrant/scripts/clmc-agent/install.sh - lxc exec ${service_name} --env REPO_ROOT="/vagrant" -- /vagrant/scripts/clmc-agent/install.sh + cmd="${target_root}/scripts/clmc-agent/install.sh" + lxc exec ${service_name} --env REPO_ROOT="${target_root}" -- ${cmd} # check that telegraf installed (it may not have if the reporc file was not present or Nexus server was down) if lxc-attach -n ${service_name} -- ls /etc/telegraf |& grep 'ls: cannot access'; then @@ -108,7 +109,7 @@ create() { chown -R 100000:100000 ${container_dir}/etc/telegraf/ # replace telegraf template with container parameters - cmd="/vagrant/scripts/clmc-agent/configure.sh ${location} ${sfc_id} ${sfc_instance_id} ${sf_package_id} ${sf_id} ${sf_endpoint_id} ${influxdb_url}" + cmd="${target_root}/scripts/clmc-agent/configure.sh ${location} ${sfc_id} ${sfc_instance_id} ${sf_package_id} ${sf_id} ${sf_endpoint_id} ${influxdb_url}" lxc exec ${service_name} -- ${cmd} # start telegraf diff --git a/src/service/production.ini b/src/service/production.ini index 5acb36aa9855c249cd45d988d8d3598e4075da61..4d9613152f2ad78fe7bdab6c811a18b3fc8f3cec 100644 --- a/src/service/production.ini +++ b/src/service/production.ini @@ -15,7 +15,7 @@ pyramid.includes = pyramid_exclog exclog.ignore = -network_configuration_path = /vagrant/src/service/resources/GraphAPI/network_config.json +network_configuration_path = /opt/clmc/src/service/resources/GraphAPI/network_config.json # PostgreSQL connection url sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb diff --git a/src/test/clmctest/scripts/test_config_telegraf.py b/src/test/clmctest/scripts/test_config_telegraf.py index ca23772481d256e5b3974319c649ee3becbe1240..c85b508c7e09910b2f760e9f43bc3d2b56be6065 100644 --- a/src/test/clmctest/scripts/test_config_telegraf.py +++ b/src/test/clmctest/scripts/test_config_telegraf.py @@ -29,6 +29,7 @@ import subprocess def test_write_telegraf_conf(): # test telegraf monitoring configuration + TARGET_ROOT = "/opt/clmc" TELEGRAF_CONF_DIR = "/etc/telegraf" LOCATION = "DC1" SFC_ID = "media_service_A" @@ -49,21 +50,21 @@ def test_write_telegraf_conf(): assert code == 0, "Failed to create telegraf include dir : " + str(code) + ", cmd=" + cmd # run write config template script with no telegraf.d directory - cmd = 'sudo cp /vagrant/scripts/clmc-agent/telegraf.conf /etc/telegraf/' + cmd = 'sudo cp ' + TARGET_ROOT + '/scripts/clmc-agent/telegraf.conf /etc/telegraf/' (out, err, code) = run_command(cmd) assert code == 0, "Failed to copy telegraf.conf : " + str(code) + ", cmd=" + cmd - cmd = 'sudo cp /vagrant/scripts/clmc-agent/telegraf_output.conf /etc/telegraf/telegraf.d/' + cmd = 'sudo cp ' + TARGET_ROOT + '/scripts/clmc-agent/telegraf_output.conf /etc/telegraf/telegraf.d/' (out, err, code) = run_command(cmd) assert code == 0, "Failed to copy telegraf_output.conf : " + str(code) + ", cmd=" + cmd # run template relacement script with incorrect arguments - cmd = 'sudo /vagrant/scripts/clmc-agent/configure.sh' + cmd = 'sudo ' + TARGET_ROOT + '/scripts/clmc-agent/configure.sh' (out, err, code) = run_command(cmd) assert code == 1, "Failed to return error on incorrect arguments : " + str(code) + ", cmd=" + cmd # run template relacement script with all arguments - cmd = 'sudo /vagrant/scripts/clmc-agent/configure.sh ' + LOCATION + ' ' + SFC_ID + ' ' + SFC_INSTANCE_ID + ' ' + SF_PACKAGE_ID + ' ' + SF_ID + ' ' + SF_ENDPOINT_ID + ' ' + INFLUXDB_URL + cmd = 'sudo ' + TARGET_ROOT + '/scripts/clmc-agent/configure.sh ' + LOCATION + ' ' + SFC_ID + ' ' + SFC_INSTANCE_ID + ' ' + SF_PACKAGE_ID + ' ' + SF_ID + ' ' + SF_ENDPOINT_ID + ' ' + INFLUXDB_URL (out, err, code) = run_command(cmd) assert code == 0, "Configure command returned error, output=" + str(out) + ", cmd=" + cmd