-
Notifications
You must be signed in to change notification settings - Fork 10
/
virtink.sh
executable file
·72 lines (64 loc) · 1.94 KB
/
virtink.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2022
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -o errexit
set -o nounset
set -o pipefail
# shellcheck source=tests/_functions.sh
source _functions.sh
# shellcheck source=tests/_assertions.sh
source _assertions.sh
vm_name=ubuntu-container-rootfs
function cleanup {
kubectl delete vm $vm_name --ignore-not-found
}
# Setup
# editorconfig-checker-disable
cat <<EOF | kubectl apply -f -
apiVersion: virt.virtink.smartx.com/v1alpha1
kind: VirtualMachine
metadata:
name: $vm_name
spec:
instance:
memory:
size: 1Gi
kernel:
image: smartxworks/virtink-kernel-5.15.12
cmdline: "console=ttyS0 root=/dev/vda rw"
disks:
- name: ubuntu
- name: cloud-init
interfaces:
- name: pod
volumes:
- name: ubuntu
containerRootfs:
image: smartxworks/virtink-container-rootfs-ubuntu
size: 4Gi
- name: cloud-init
cloudInit:
userData: |-
#cloud-config
password: password
chpasswd: { expire: False }
ssh_pwauth: True
networks:
- name: pod
pod: {}
EOF
# editorconfig-checker-enable
sleep 5
trap cleanup EXIT
# Test
info "===== Test started ====="
kubectl wait vm ubuntu-container-rootfs --for jsonpath='{.status.phase}'=Running --timeout -1s
pod_name=$(kubectl get vm "$vm_name" -o jsonpath='{.status.vmPodName}')
assert_are_not_equal "$(kubectl run "ssh-$vm_name" --rm --image=alpine --restart=Never -it -- uname -a)" "$(uname -a)" "$pod_name has the same kernel version than the host"
info "===== Test completed ====="