Skip to content
Snippets Groups Projects
Commit 3ea1df43 authored by panos's avatar panos
Browse files

update README, VBox, installation (fixture)

parent 4ebfe4c9
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,8 @@ Testing is implemented using pytest using the following convention: ...@@ -50,6 +50,8 @@ Testing is implemented using pytest using the following convention:
* Tests are executed from the test-runner container on the VM using install python modules * Tests are executed from the test-runner container on the VM using install python modules
* CI testing is on givry using nested LXD containers * CI testing is on givry using nested LXD containers
##### Create VM
Create a single VM with LXC installed and configured with lxcbr0 configured for the network 172.40.231.0/24 Create a single VM with LXC installed and configured with lxcbr0 configured for the network 172.40.231.0/24
```shell ```shell
...@@ -76,18 +78,22 @@ To create|start|stop|destroy specific services use the `-c` option e.g. ...@@ -76,18 +78,22 @@ To create|start|stop|destroy specific services use the `-c` option e.g.
/vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json -c clmc-service /vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json -c clmc-service
``` ```
##### Create `reporc` file
The installation of several of the services depend on accessing the Nexus binary repository (for the custom Telegraf agent). To do this, a username and password for the repository must be specified in a `reporc` file in the user's home directory, e.g. The installation of several of the services depend on accessing the Nexus binary repository (for the custom Telegraf agent). To do this, a username and password for the repository must be specified in a `reporc` file in the user's home directory, e.g.
```shell ```shell
REPO_USER=itinnov.flame.integration REPO_USER=itinnov.flame.integration
REPO_PASS=xxxxxxx REPO_PASS=xxxxxxx
``` ```
##### Build all services
Create all the services needed for integration tests: Create all the services needed for integration tests:
```shell ```shell
sudo su sudo /vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json -c all
/vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json -c all
``` ```
As part of the clmc-service installation, the service's unit tests have been run. The fixture script will fail if any individual service installation fails to install (or fails its tests). As part of the clmc-service installation, the service's unit tests have been run. The fixture script will fail if any individual service installation fails to install (or fails its tests).
...@@ -95,22 +101,20 @@ As part of the clmc-service installation, the service's unit tests have been run ...@@ -95,22 +101,20 @@ As part of the clmc-service installation, the service's unit tests have been run
Attach to the test-runner to run the tests Attach to the test-runner to run the tests
```shell ```shell
lxc exec test-runner /bin/bash sudo lxc exec test-runner -- bash
``` ```
Build and install the CLMC test Python module: Build and install the CLMC test Python module:
```shell ```shell
cd /opt/clmc/src/test cd /opt/clmc/src/test
python setup.py sdist --dist-dir=../../build python3 setup.py sdist --dist-dir=../../build
apt install python-pip pip3 install /opt/clmc/build/clmctest-<version>.tar.gz
pip install /opt/clmc/build/clmctest-<version>.tar.gz
``` ```
The following module is unit tests: The following module is unit tests:
```shell ```shell
apt install python3-pytest
pytest -s --pyargs clmctest.scripts pytest -s --pyargs clmctest.scripts
``` ```
......
...@@ -59,14 +59,28 @@ SCRIPT ...@@ -59,14 +59,28 @@ SCRIPT
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64" config.vm.box = "ubuntu/bionic64"
config.vm.box_version = '20190627.1.0' config.vm.box_version = '20190627.1.0'
config.disksize.size = '50GB'
# use public network by allowing the IP to be assigned via DHCP
config.vm.network "public_network", use_dhcp_assigned_default_route: true
# forward ports to host
#config.vm.network "forwarded_port", guest: 80, host: 80
# increase default disk size, it requires to install the plugin first
# e.g. vagrant plugin install vagrant-disksize
config.disksize.size = '15GB'
# forward X11
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
# provision the VM
config.vm.provider "virtualbox" do |vb| config.vm.provider "virtualbox" do |vb|
vb.cpus = 2 vb.cpus = 2
vb.memory = "8192" #vb.memory = "8192"
vb.memory = "12288"
end end
#config.vm.network "forwarded_port", guest: 8888, host: 8888
# Install lxc # Install lxc
config.vm.provision :shell, inline: $lxc_script config.vm.provision :shell, inline: $lxc_script
end end
...@@ -36,6 +36,14 @@ usage() { ...@@ -36,6 +36,14 @@ usage() {
exit 1 exit 1
} }
failed() {
msg=$1
sn=$2
echo "failed on: $msg"
delete_c $sn
exit 1
}
create() { create() {
service_name=$1 service_name=$1
config_file=$2 config_file=$2
...@@ -47,7 +55,7 @@ create() { ...@@ -47,7 +55,7 @@ create() {
echo $SERVICE echo $SERVICE
ip=$(echo $SERVICE | jq -r '.ip_address') ip=$(echo $SERVICE | jq -r '.ip_address')
lxc init ubuntu:16.04 ${service_name} lxc init ubuntu:16.04 ${service_name} || return
echo "Creating network: ${service_name}" echo "Creating network: ${service_name}"
lxc network attach lxcbr0 ${service_name} eth0 lxc network attach lxcbr0 ${service_name} eth0
lxc config device set ${service_name} eth0 ipv4.address ${ip} lxc config device set ${service_name} eth0 ipv4.address ${ip}
...@@ -57,11 +65,12 @@ create() { ...@@ -57,11 +65,12 @@ create() {
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_repo_root=${container_dir}${target_root} container_repo_root=${container_dir}${target_root}
mkdir -p ${container_repo_root} mkdir -p ${container_repo_root} || failed "to create target directory" ${service_name}
cp -f ${repo_root}/reporc ${container_repo_root} cp -f ${repo_root}/reporc ${container_repo_root} || failed "to copy reporc" ${service_name}
cp -rf ${repo_root}/scripts ${container_repo_root} cp -rf ${repo_root}/scripts ${container_repo_root} || failed "to copy scripts" ${service_name}
cp -rf ${repo_root}/src ${container_repo_root} cp -rf ${repo_root}/src ${container_repo_root} || failed "to copy src" ${service_name}
chown -R 100000:100000 ${container_repo_root} chown -R 100000:100000 ${container_repo_root} || failed "to change permissions" ${service_name}
# start the container # start the container
echo "Starting: ${service_name}" echo "Starting: ${service_name}"
...@@ -83,8 +92,7 @@ create() { ...@@ -83,8 +92,7 @@ create() {
echo "clmc-service installation failed with exit code ${exit_code}" echo "clmc-service installation failed with exit code ${exit_code}"
exit 1 exit 1
fi fi
elif [ ${service_name} == "test-runner" ] elif [ ${service_name} == "test-runner" ]; then
then
cmd="${target_root}/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=$?
...@@ -115,8 +123,9 @@ create() { ...@@ -115,8 +123,9 @@ create() {
lxc exec ${service_name} --env REPO_ROOT="${target_root}" -- ${cmd} 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
echo "Telegraf agent failed to install (check reporc?)" if lxc exec ${service_name} -- ls /etc/telegraf |& grep 'ls: cannot access'; then
echo "Telegraf agent failed to install for ${service_name} (check reporc?)"
exit 1 exit 1
fi fi
...@@ -167,10 +176,19 @@ stop() { ...@@ -167,10 +176,19 @@ stop() {
service_name=$1 service_name=$1
if lxc info ${service_name}; then if lxc info ${service_name}; then
echo "Stopping container: ${service_name}" echo "Stopping container: ${service_name}"
lxc stop -n ${service_name} lxc stop ${service_name}
fi fi
} }
delete_c() {
service_name=$1
if lxc list | grep -q ${service_name}; then
echo "Deleting container: ${service_name}"
lxc delete ${service_name}
fi
}
destroy() { destroy() {
service_name=$1 service_name=$1
config_file=$2 config_file=$2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment