Skip to content
Snippets Groups Projects
Commit 5288d5fc authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Merge remote-tracking branch 'origin' into clmc-service

parents edc17300 d3f8e2f9
No related branches found
No related tags found
No related merge requests found
...@@ -49,11 +49,11 @@ test:all: ...@@ -49,11 +49,11 @@ test:all:
- echo "REPO_USER=${REPO_USER}" > $CI_PROJECT_DIR/reporc - echo "REPO_USER=${REPO_USER}" > $CI_PROJECT_DIR/reporc
- echo "REPO_PASS=${REPO_PASS}" >> $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 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 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/vagrant/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/vagrant/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 /vagrant/build/clmctest-1.3.0.tar.gz - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-1.3.0.tar.gz
- sudo lxc exec test-runner -- pip3 install /vagrant/build/clmcservice-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 - sudo lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs clmctest
when: on_success when: on_success
......
...@@ -37,6 +37,8 @@ cd `dirname $0` ...@@ -37,6 +37,8 @@ cd `dirname $0`
echo "Provisioning CLMC service" echo "Provisioning CLMC service"
export REPO_ROOT=${REPO_ROOT}
./install-tick-stack.sh ./install-tick-stack.sh
./install-neo4j.sh ./install-neo4j.sh
./install-clmc-service.sh ./install-clmc-service.sh
\ No newline at end of file
#!/bin/bash #!/bin/bash
repo_root="/vagrant" repo_root="/vagrant"
target_root="/opt/clmc"
config_file="rspec.json" config_file="rspec.json"
usage() { usage() {
...@@ -31,12 +32,12 @@ create() { ...@@ -31,12 +32,12 @@ create() {
# copy flame clmc files into the root container # copy flame clmc files into the root container
echo "Copying files to rootfs" echo "Copying files to rootfs"
container_dir="/var/lib/lxd/containers/"${service_name}"/rootfs" container_dir="/var/lib/lxd/containers/"${service_name}"/rootfs"
container_vagrant_dir=${container_dir}"/vagrant" container_repo_root=${container_dir}${target_root}
mkdir -p ${container_vagrant_dir} mkdir -p ${container_repo_root}
cp -f ${repo_root}/reporc ${container_vagrant_dir} cp -f ${repo_root}/reporc ${container_repo_root}
cp -rf ${repo_root}/scripts ${container_vagrant_dir} cp -rf ${repo_root}/scripts ${container_repo_root}
cp -rf ${repo_root}/src ${container_vagrant_dir} cp -rf ${repo_root}/src ${container_repo_root}
chown -R 100000:100000 ${container_vagrant_dir} chown -R 100000:100000 ${container_repo_root}
# start the container # start the container
echo "Starting: ${service_name}" echo "Starting: ${service_name}"
...@@ -50,9 +51,9 @@ create() { ...@@ -50,9 +51,9 @@ create() {
# provision software into each container # provision software into each container
echo "Provisioning: ${service_name}" echo "Provisioning: ${service_name}"
if [ ${service_name} == "clmc-service" ]; then 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}" 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=$? exit_code=$?
if [ $exit_code != 0 ]; then if [ $exit_code != 0 ]; then
echo "clmc-service installation failed with exit code ${exit_code}" echo "clmc-service installation failed with exit code ${exit_code}"
...@@ -60,7 +61,7 @@ create() { ...@@ -60,7 +61,7 @@ create() {
fi fi
elif [ ${service_name} == "test-runner" ] elif [ ${service_name} == "test-runner" ]
then 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} lxc exec ${service_name} -- ${cmd}
exit_code=$? exit_code=$?
if [ $exit_code != 0 ]; then if [ $exit_code != 0 ]; then
...@@ -78,16 +79,16 @@ create() { ...@@ -78,16 +79,16 @@ create() {
influxdb_url=$(echo $SERVICE | jq -r '.influxdb_url') influxdb_url=$(echo $SERVICE | jq -r '.influxdb_url')
# install service function specific software # install service function specific software
cmd=/vagrant/src/test/clmctest/services/${sf_package_id}/install.sh cmd="${target_root}/src/test/clmctest/services/${sf_package_id}/install.sh"
lxc exec ${service_name} --env REPO_ROOT="/vagrant" -- ${cmd} lxc exec ${service_name} --env REPO_ROOT="${target_root}" -- ${cmd}
exit_code=$? exit_code=$?
if [ $exit_code != 0 ]; then if [ $exit_code != 0 ]; then
echo "${sf_package_id} installation failed with exit code ${exit_code}" echo "${sf_package_id} installation failed with exit code ${exit_code}"
exit 1 exit 1
fi fi
# install telegraf # install telegraf
cmd=/vagrant/scripts/clmc-agent/install.sh cmd="${target_root}/scripts/clmc-agent/install.sh"
lxc exec ${service_name} --env REPO_ROOT="/vagrant" -- /vagrant/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) # 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 if lxc-attach -n ${service_name} -- ls /etc/telegraf |& grep 'ls: cannot access'; then
...@@ -108,7 +109,7 @@ create() { ...@@ -108,7 +109,7 @@ create() {
chown -R 100000:100000 ${container_dir}/etc/telegraf/ chown -R 100000:100000 ${container_dir}/etc/telegraf/
# replace telegraf template with container parameters # 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} lxc exec ${service_name} -- ${cmd}
# start telegraf # start telegraf
......
...@@ -15,7 +15,7 @@ pyramid.includes = pyramid_exclog ...@@ -15,7 +15,7 @@ pyramid.includes = pyramid_exclog
exclog.ignore = 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 # PostgreSQL connection url
sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb
......
...@@ -29,6 +29,7 @@ import subprocess ...@@ -29,6 +29,7 @@ import subprocess
def test_write_telegraf_conf(): def test_write_telegraf_conf():
# test telegraf monitoring configuration # test telegraf monitoring configuration
TARGET_ROOT = "/opt/clmc"
TELEGRAF_CONF_DIR = "/etc/telegraf" TELEGRAF_CONF_DIR = "/etc/telegraf"
LOCATION = "DC1" LOCATION = "DC1"
SFC_ID = "media_service_A" SFC_ID = "media_service_A"
...@@ -49,21 +50,21 @@ def test_write_telegraf_conf(): ...@@ -49,21 +50,21 @@ def test_write_telegraf_conf():
assert code == 0, "Failed to create telegraf include dir : " + str(code) + ", cmd=" + cmd assert code == 0, "Failed to create telegraf include dir : " + str(code) + ", cmd=" + cmd
# run write config template script with no telegraf.d directory # 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) (out, err, code) = run_command(cmd)
assert code == 0, "Failed to copy telegraf.conf : " + str(code) + ", cmd=" + 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) (out, err, code) = run_command(cmd)
assert code == 0, "Failed to copy telegraf_output.conf : " + str(code) + ", cmd=" + cmd assert code == 0, "Failed to copy telegraf_output.conf : " + str(code) + ", cmd=" + cmd
# run template relacement script with incorrect arguments # 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) (out, err, code) = run_command(cmd)
assert code == 1, "Failed to return error on incorrect arguments : " + str(code) + ", cmd=" + cmd assert code == 1, "Failed to return error on incorrect arguments : " + str(code) + ", cmd=" + cmd
# run template relacement script with all arguments # 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) (out, err, code) = run_command(cmd)
assert code == 0, "Configure command returned error, output=" + str(out) + ", cmd=" + cmd assert code == 0, "Configure command returned error, output=" + str(out) + ", cmd=" + cmd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment