@@ -28,3 +28,53 @@ image:
2828 docker buildx create --use
2929 docker buildx build --platform linux/amd64 -t ghostbaby/shepherd:v0.0.1-amd64 --push .
3030 docker buildx build --platform linux/arm64 -t ghostbaby/shepherd:v0.0.1-arm64 --push .
31+
32+ .ONESHELL :
33+ prepare_e2e_filesystem :
34+ cd ./tests/e2e/vm/filesystem
35+ # build filesystem image and store as tar archive
36+ DOCKER_BUILDKIT=1 docker build --output " type=tar,dest=filesystem.tar" .
37+ # convert tar to qcow2 image
38+ sudo virt-make-fs --format=qcow2 --size=+100M filesystem.tar filesystem-large.qcow2
39+ # reduce size of image
40+ qemu-img convert filesystem-large.qcow2 -O qcow2 filesystem.qcow2
41+ # reduce size by packing
42+ zip filesystem.zip filesystem.qcow2
43+ # remove unnecessary files
44+ rm -f filesystem-large.qcow2 filesystem.qcow2 filesystem.tar
45+
46+ .ONESHELL :
47+ start_qemu :
48+ cd ./tests/e2e/vm/filesystem
49+ rm -f filesystem.qcow2 filesystem-diff.qcow2
50+ unzip ./filesystem.zip
51+ sudo qemu-img create -f qcow2 -b filesystem.qcow2 -F qcow2 filesystem-diff.qcow2
52+ PWD=$(pwd )
53+ sudo qemu-system-x86_64 \
54+ -cpu host \
55+ -m 4G \
56+ -smp 4 \
57+ -kernel ${PWD} /tests/e2e/vm/kernels/${KERNEL} /bzImage \
58+ -append " console=ttyS0 root=/dev/sda rw" \
59+ -drive file=" ${PWD} /tests/e2e/vm/filesystem/filesystem-diff.qcow2,format=qcow2" \
60+ -net nic -net user,hostfwd=tcp::10022-:22,hostfwd=tcp::16676-:6676,hostfwd=tcp::10443-:443 \
61+ -enable-kvm \
62+ -pidfile qemu.pid \
63+ -nographic &
64+
65+ .ONESHELL :
66+ prepare_e2e : start_qemu
67+ while ! nc -z 127.0.0.1 10022 ; do echo " waiting for ssh" ; sleep 1; done
68+ sshpass -p root scp -o
' StrictHostKeyChecking no' -P 10022 ./cmd/shepherd
[email protected] :/root/shepherd
69+ sshpass -p root scp -o
' StrictHostKeyChecking no' -P 10022 ./cmd/config.yaml
[email protected] :/root/config.yaml
70+ sshpass -p root ssh -p 10022
[email protected] ' chmod 0655 /root/shepherd && systemctl start shepherd.service' 71+ while ! sshpass -p root ssh -p 10022
[email protected] ' systemctl is-active shepherd.service' ; do echo " waiting for shepherd service" ; sleep 1
; done 72+
73+ .ONESHELL :
74+ e2e : prepare_e2e
75+ ifconfig
76+ RC=$$?
77+ pwd
78+ sshpass -p root ssh -p 10022
[email protected] ' ls /root && ls /root/log/' 79+ sudo cat ./tests/e2e/vm/filesystem/qemu.pid | sudo xargs kill
80+ exit $$ RC
0 commit comments