-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(system): cgroups test with virtualisation disabled
- Loading branch information
Showing
4 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters