Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions juniper_junos-formula/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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='<your public SSH key>' -p <port>: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<port>' -lr . geeko@<remote machine>:/srv/opensuse-salt-formulas`
5. `ssh -p<port> geeko@<remote machine>`
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
Expand Down
2 changes: 1 addition & 1 deletion juniper_junos-formula/bin/lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

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'
Expand Down
75 changes: 75 additions & 0 deletions test/bootstrap-salt-roots-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Helper script for installing the openSUSE Salt formulas in a containerized test environment.
# Copyright (C) 2024 Georg Pfuetzenreuter <[email protected]>
#
# 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 <https://www.gnu.org/licenses/>.

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 <<EOF
include:
- samples.*
EOF