diff --git a/juniper_junos-formula/README.md b/juniper_junos-formula/README.md index 8918e349..c60c1ad9 100644 --- a/juniper_junos-formula/README.md +++ b/juniper_junos-formula/README.md @@ -27,6 +27,40 @@ The test suite currently only validates whether the configuration is applied as To run the test suite, a lab environment can be set up if the proprietary vSRX and vQFX images are provided in `/opt/images`. +### Remote / using Docker + +This process is still a work in progress, the steps below still need to be simplified. +The idea is to run the very resource heavy simulation devices on a powerful remote computer whilst executing the test suite from the local workstation out of the local development environment. + +#### Test dependencies + +On the local system: + +- Pytest + Testinfra + +On the remote system: + +- Docker +- Libvirt + QEMU + +#### Test steps + +On the remote system: + +1. `./juniper_junos-formula/bin/lab.sh` +2. `docker run --pull=always --name=dev0 -eSSH_KEY='' -p :22 --rm -d --privileged registry.opensuse.org/isv/suseinfra/containers/next/containerfile/suseinfra/salt-development-heavy` +3. `docker cp .devices dev0:/etc/` + +On the local system: + +4. `rsync --rsh='ssh -p' -lr . geeko@:/srv/opensuse-salt-formulas` +5. `ssh -p geeko@` +6. `sudo /srv/opensuse-salt-formulas/test/bootstrap-salt-roots-container.sh` +7. `cd /etc` +8. `sudo /usr/local/sbin/proxy_setup` + +### Local / using Vagrant + #### Test dependencies - Docker diff --git a/juniper_junos-formula/bin/lab.sh b/juniper_junos-formula/bin/lab.sh index 6b70c732..bd53db6f 100755 --- a/juniper_junos-formula/bin/lab.sh +++ b/juniper_junos-formula/bin/lab.sh @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -Ceux +set -Ceu #x # Git repository to fetch vrnetlab from ; to-do -> extract the needed files instead of cloning the whole tree repository='https://github.com/tacerus/vrnetlab.git' diff --git a/test/bootstrap-salt-roots-container.sh b/test/bootstrap-salt-roots-container.sh new file mode 100755 index 00000000..d5e1ab74 --- /dev/null +++ b/test/bootstrap-salt-roots-container.sh @@ -0,0 +1,75 @@ +# Helper script for installing the openSUSE Salt formulas in a containerized test environment. +# Copyright (C) 2024 Georg Pfuetzenreuter +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if [ ! -d /srv/formulas ] +then + mkdir /srv/formulas +fi +if [ ! -d /srv/pillar/samples ] +then + mkdir /srv/pillar/samples +fi +for formula in $(find /srv/opensuse-salt-formulas -mindepth 1 -maxdepth 1 -type d -name '*-formula' -printf '%P\n') +do + echo "$formula" + fname="${formula%%-*}" + src="/srv/opensuse-salt-formulas/$formula" + src_states="$formula/$fname" + src_formula="/srv/opensuse-salt-formulas/$src_states" + src_pillar="/srv/opensuse-salt-formulas/$formula/pillar.example" + src_test_pillar="/srv/opensuse-salt-formulas/$formula/tests/pillar.sls" + if [ ! -d "$src_formula" ] + then + fname="${fname//_/-}" + src_states="$formula/$fname" + src_formula="/srv/opensuse-salt-formulas/$src_states" + fi + if [ ! -h "/srv/formulas/$fname" ] + then + ln -s "$src_formula" "/srv/formulas" + fi + dst_pillar="/srv/pillar/samples/$fname.sls" + if [ -f "$src_test_pillar" ] + then + cp "$src_test_pillar" "$dst_pillar" + elif [ -f "$src_pillar" ] + then + cp "$src_pillar" "$dst_pillar" + fi + dst_salt='/srv/salt' + for mod in modules states proxy + do + mod="_$mod" + src_mod="$src/$mod" + dst_mod="$dst_salt/$mod" + + if [ ! -d "$dst_mod" ] + then + mkdir "$dst_mod" + fi + + if [ -d "$src_mod" ] + then + echo "$fname: $mod" + cp "$src_mod/"* "$dst_mod/" + fi + done +done + +tee /srv/pillar/base.sls >/dev/null <