Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jip-Hop committed Jul 8, 2024
1 parent ee1f225 commit e3058b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 49 deletions.
46 changes: 19 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
on:
# Triggers the workflow on push or pull request events for any branch
push:
branches: [ "**" ]
branches: ["**"]
pull_request:
branches: [ "**" ]
branches: ["**"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -25,6 +25,7 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# NOTE: <https://github.com/marketplace/actions/tune-github-hosted-runner-network>
# Create a network namespace in the GitHub-hosted runner VM,
# simulating a primary bridge network on TrueNAS SCALE
- name: Set up networking resources
Expand All @@ -33,12 +34,10 @@ jobs:
sed -i -e 's/^#DNSStubListener=yes$/DNSStubListener=no/' /etc/systemd/resolved.conf
systemctl stop systemd-resolved
systemctl status systemd-resolved
rm /etc/resolv.conf
echo 'nameserver 1.1.1.1' > /etc/resolv.conf
apt-get install -qq -y \
systemd-container
apt-get install -qq -y systemd-container
cat <<NETWORKCONFIG >/etc/systemd/network/10-br1.network
[Match]
Expand All @@ -59,41 +58,34 @@ jobs:
systemctl restart systemd-networkd
ip link add name br1 type bridge
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -I DOCKER-USER -i br1 -o eth0 -j ACCEPT
END
# (temporary)
- name: Examine the GitHub-hosted runner environment
run: |
uname -r
cat /etc/os-release
python3 --version
echo
for path in /etc/systemd/network* /etc/systemd/resolve* /etc/resolv.conf ; do
echo "✳️ $path"
[ -d "$path" ] && ls -la "$path" || cat "$path"
echo
done
ip addr
# NOTE: <https://github.com/marketplace/actions/tune-github-hosted-runner-network>
# # TODO: create zpool with virtual disks, create jailmaker dataset and test jlmkr.py from there
# # https://medium.com/@abaddonsd/zfs-usage-with-virtual-disks-62898064a29b
# - name: Create a parent ZFS dataset
# run: |
# sudo -s <<END
# apt-get install -y -qq zfsutils-linux
# modinfo zfs | grep version
# zfs --version
# zpool --version
# END

# TODO: create zpool with virtual disks, create jailmaker dataset and test jlmkr.py from there
# https://medium.com/@abaddonsd/zfs-usage-with-virtual-disks-62898064a29b
- name: Create a parent ZFS dataset
run: |
sudo -s <<END
apt-get install -y -qq zfsutils-linux
modinfo zfs | grep version
zfs --version
zpool --version
END
# Runs a single command using the runners shell
# Run multiple commands using the runners shell
- name: Run the test script
env:
PYTHONUNBUFFERED: 1
run: |
sudo chown 0:0 jlmkr.py test/test.sh
sudo chmod +x jlmkr.py test/test.sh
sudo ./test/test.sh
23 changes: 1 addition & 22 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -I DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -I DOCKER-USER -i br1 -o eth0 -j ACCEPT
iptables -A INPUT -i br1 -p udp -m udp --dport 67 -j ACCEPT

# TODO: create a path and/or zfs pool with a space in it to test if jlmkr.py still works properly when ran from inside
# mkdir -p "/tmp/path with space/jailmaker"

# TODO: many more test cases and checking if actual output (text, files on disk etc.) is correct instead of just a 0 exit code

./jlmkr.py create --start examiner --network-bridge=br1 --resolv-conf=bind-host
echo "About to run debug logging in jail"
cat <<EOF > jails/examiner/rootfs/root/debug.sh
for path in /etc/systemd/network* /etc/systemd/resolve* /etc/resolv.conf ; do
echo "✳️ \$path"
[ -d "\$path" ] && ls -la "\$path" || cat "\$path"
echo
done
netstat -n -r
sleep 3
ip addr
resolvectl query deb.debian.org
EOF

sleep 5
./jlmkr.py exec examiner bash /root/debug.sh

# TODO: test jlmkr.py from inside another working directory, with a relative path to a config file to test if it uses the config file (and doesn't look for it relative to the jlmkr.py file itself)

./jlmkr.py create --start --config=./templates/docker/config test
./jlmkr.py exec test docker run hello-world

0 comments on commit e3058b9

Please sign in to comment.