Skip to content

Commit

Permalink
test(system): cgroups test with virtualisation disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 17, 2023
1 parent 8bc00e2 commit 72a85fb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
55 changes: 55 additions & 0 deletions packages/system/env/cgroups-multipass/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -e

cd `pwd`/`dirname ${BASH_SOURCE}`

multipass launch \
--name nikita-system-cgroup \
--cpus 2 \
--memory 10G \
--disk 20G \
release:18.04
NIKITA_HOME=`node -e "process.stdout.write(path.join(process.cwd(), '../../../..'))"`
# Fix DNS
multipass exec nikita-system-cgroup -- bash <<EOF
sudo su -
bash -c "echo 'DNS=8.8.8.8' >> /etc/systemd/resolved.conf"
systemctl restart systemd-resolved
EOF
# Allow mounting directories
multipass exec nikita-system-cgroup -- sudo apt upgrade -y
multipass exec nikita-system-cgroup -- sudo snap install multipass-sshfs
multipass mount $NIKITA_HOME nikita-system-cgroup:/nikita
# Install Node.js
multipass exec nikita-system-cgroup bash <<'EOF'
if command -v node ; then exit 42; fi
curl -sS -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# NVM is sourced from ~/.bashrc which is not loaded in non interactive mode
echo '. $HOME/.nvm/nvm.sh' >> $HOME/.profile
. $HOME/.profile
nvm install 16
EOF
# Configure SSH
multipass exec nikita-system-cgroup bash <<'EOF'
mkdir -p $HOME/.ssh && chmod 700 $HOME/.ssh
if [ ! -f $HOME/.ssh/id_ed25519 ]; then
ssh-keygen -t ed25519 -f $HOME/.ssh/id_ed25519 -N ''
cat $HOME/.ssh/id_ed25519.pub >> $HOME/.ssh/authorized_keys
# sudo bash -c "cat $HOME/.ssh/id_ed25519.pub >> /root/.ssh/authorized_keys"
fi
EOF
# Install test dependencies
multipass exec nikita-system-cgroup bash <<EOF
sudo su -
apt update -y && apt install -y cgroup-tools
cp -pr /usr/share/doc/cgroup-tools/examples/cgsnapshot_blacklist.conf /etc/cgsnapshot_blacklist.conf
EOF
# Run tests
multipass exec nikita-system-cgroup bash <<'EOF'
. $HOME/.profile
export NIKITA_TEST_MODULE=/nikita/packages/system/env/cgroups-multipass/test.coffee
cd /nikita/packages/system/
npm run test:local
EOF
# Enter the container
# multipass exec nikita-system-cgroup -d /nikita/packages/system/ -- bash
12 changes: 12 additions & 0 deletions packages/system/env/cgroups-multipass/test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

module.exports =
tags:
system_cgroups: true
config: [
label: 'local'
,
label: 'remote'
ssh:
host: '127.0.0.1', username: process.env.USER,
private_key_path: '~/.ssh/id_ed25519'
]
14 changes: 5 additions & 9 deletions packages/system/env/cgroups/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
module.exports =
tags:
system_cgroups: true
# service:
# name: 'cronie'
# srv_name: 'crond'
# chk_name: 'crond'
config: [
label: 'local'
# label: 'local'
# ,
# label: 'remote'
# ssh:
# host: '127.0.0.1', username: process.env.USER,
# private_key_path: '~/.ssh/id_ed25519'
label: 'remote'
ssh:
host: '127.0.0.1', username: process.env.USER,
private_key_path: '~/.ssh/id_ed25519'
]
6 changes: 5 additions & 1 deletion packages/system/env/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -e
cd `pwd`/`dirname ${BASH_SOURCE}`

# Require cgroup v1
# npx coffee ./env/cgroups/index.coffee run
if command -v multipass; then
./cgroup-multipass/run.sh
else
npx coffee ./env/cgroups/index.coffee run
fi
./info_archlinux/run.sh
./info_centos6/run.sh
./info_centos7/run.sh
Expand Down

0 comments on commit 72a85fb

Please sign in to comment.