Skip to content

Commit

Permalink
Support kubevirt tests on sle-micro 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nanzhg committed Apr 19, 2024
1 parent ca38a25 commit 98bb07f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 16 deletions.
3 changes: 3 additions & 0 deletions data/virt_autotest/kubevirt_tests/core-tests.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ GINKGO_FOCUS=test_id:1532

[replicaset_test]
GINKGO_FOCUS=test_id:4121

[hotplug_test]
GINKGO_FOCUS=should allow live migration with attached hotplug volumes
14 changes: 5 additions & 9 deletions data/virt_autotest/kubevirt_tests/full-tests.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ GINKGO_FOCUS=vmi_lifecycle_test.go

[vm_test]
GINKGO_FOCUS=vm_test.go
GINKGO_SKIP=test_id:3312

[vmipreset_test]
GINKGO_FOCUS=vmipreset_test.go
Expand All @@ -36,7 +35,7 @@ GINKGO_FOCUS=container_disk_test.go

[datavolume_test]
GINKGO_FOCUS=datavolume.go
GINKGO_SKIP=test_id:3189|test_id:6686|test_id:5252|should resolve DataVolume sourceRef|test_id:8571|virtiofs VirtIO-FS with multiple PVCs should be successfully started and accessible with passt enabled|test_id:5253|test_id:5254
GINKGO_SKIP=virtiofs VirtIO-FS with multiple PVCs should be successfully started and accessible with passt enabled

[hotplug_test]
GINKGO_FOCUS=hotplug.go
Expand All @@ -60,7 +59,6 @@ EXTRA_OPT=-skip-shasums-check

[vmi_networking_test]
GINKGO_FOCUS=vmi_networking.go
GINKGO_SKIP=test_id:1780

[networkpolicy_test]
GINKGO_FOCUS=networkpolicy.go
Expand Down Expand Up @@ -92,17 +90,15 @@ GINKGO_FOCUS=services.go
GINKGO_FOCUS=vmi_kernel_boot_test.go

[infra_test]
GINKGO_FOCUS=infra_test.go
GINKGO_SKIP=test_id:4099|test_id:4137|test_id:4139|test_id:6535
GINKGO_FOCUS=infrastructure.go

[operator_test]
GINKGO_FOCUS=operator_test.go
GINKGO_SKIP=test_id:3153
GINKGO_FOCUS=operator.go
EXTRA_OPT=-skip-shasums-check

[migration_test]
GINKGO_FOCUS=migration_test.go
GINKGO_SKIP=test_id:6979|test_id:6982|test_id:3190|test_id:4746
GINKGO_FOCUS=migration.go
GINKGO_SKIP=test_id:4746

[subresource_api_test]
GINKGO_FOCUS=subresource_api_test.go
Expand Down
25 changes: 25 additions & 0 deletions schedule/virt_autotest/slem-kubevirt-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: slem-kubevirt-tests
description: >
Maintainer: Nan Zhang <nan.zhang@suse.com> qe-virt@suse.de
Kubevirt server & agent node installation and test modules
vars: {}
schedule:
- '{{barrier_setup}}'
- installation/ipxe_install
- installation/usb_install
- installation/bootloader_uefi
- microos/selfinstall
- transactional/host_config
- console/suseconnect_scc
- '{{kubevirt_tests}}'
conditional_schedule:
barrier_setup:
SERVICE:
rke2-server:
- virt_autotest/kubevirt_barriers
kubevirt_tests:
SERVICE:
rke2-server:
- virt_autotest/kubevirt_tests_server
rke2-agent:
- virt_autotest/kubevirt_tests_agent
29 changes: 26 additions & 3 deletions tests/virt_autotest/kubevirt_tests_agent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use Utils::Logging qw(save_and_upload_log save_and_upload_systemd_unit_log);
sub run {
my ($self) = shift;

if (get_required_var('WITH_HOST_INSTALL')) {
unless (check_var('RUN_TEST_ONLY', '1')) {
use_ssh_serial_console;
my $sut_ip = get_required_var('SUT_IP');

set_var('AGENT_IP', $sut_ip);
Expand Down Expand Up @@ -51,6 +52,9 @@ sub rke2_agent_setup {
disable_and_stop_service('apparmor.service');
disable_and_stop_service('firewalld.service');
}
# Enable NTP service
systemctl('enable --now chronyd', timeout => 180);

$self->setup_passwordless_ssh_login($server_ip);

# rebootmgr has to be turned off as prerequisity for this to work
Expand All @@ -60,6 +64,8 @@ sub rke2_agent_setup {

transactional::process_reboot(trigger => 1) if (is_transactional);
record_info('Installed certificates packages', script_output('rpm -qa | grep certificates'));
# Set long host name to avoid x509 server connection issue
assert_script_run('hostnamectl set-hostname $(hostname -s)');

# Install kubevirt packages complete
barrier_wait('kubevirt_packages_install_complete');
Expand All @@ -84,8 +90,25 @@ sub rke2_agent_setup {
# Configure rke2-agent service
my $server_node_token = script_output("ssh root\@$server_ip cat /var/lib/rancher/rke2/server/node-token");
assert_script_run('mkdir -p /etc/rancher/rke2/');
assert_script_run("echo 'server: https://$server_ip:9345' > /etc/rancher/rke2/config.yaml");
assert_script_run("echo 'token: $server_node_token' >> /etc/rancher/rke2/config.yaml");
assert_script_run("cat > /etc/rancher/rke2/config.yaml <<__END
server: https://$server_ip:9345
token: $server_node_token
kubelet-arg:
- cpu-manager-policy=static
- kube-reserved=cpu=500m
- system-reserved=cpu=500m
__END
(exit \$?)");

# Setup cnv-bridge containernetworking plugin: one of the tests requires
# a newer version of the Linux bridge CNI:
# https://github.com/kubevirt/kubevirt/commit/3fa7e2b67f9095d664e83eb1e13b587ab76b4950
assert_script_run("curl -LO https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz");
assert_script_run("curl -LO https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz.sha256");
assert_script_run("sha256sum --check cni-plugins-linux-amd64-v1.1.1.tgz.sha256");
assert_script_run("mkdir -p /opt/cni/bin");
assert_script_run("tar -xOf cni-plugins-linux-amd64-v1.1.1.tgz ./bridge > /opt/cni/bin/cnv-bridge");
assert_script_run("chmod +x /opt/cni/bin/cnv-bridge");

# Enable rke2-agent service
systemctl('enable --now rke2-agent.service', timeout => 180);
Expand Down
24 changes: 20 additions & 4 deletions tests/virt_autotest/kubevirt_tests_server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ my @core_tests = (
sub run {
my ($self) = shift;

if (get_required_var('WITH_HOST_INSTALL')) {
unless (check_var('RUN_TEST_ONLY', '1')) {
use_ssh_serial_console;
my $sut_ip = get_required_var('SUT_IP');

set_var('SERVER_IP', $sut_ip);
Expand Down Expand Up @@ -101,6 +102,9 @@ sub rke2_server_setup {
disable_and_stop_service('apparmor.service');
disable_and_stop_service('firewalld.service');
}
# Enable NTP service
systemctl('enable --now chronyd', timeout => 180);

$self->setup_passwordless_ssh_login($agent_ip);

# rebootmgr has to be turned off as prerequisity for this to work
Expand All @@ -110,6 +114,8 @@ sub rke2_server_setup {

transactional::process_reboot(trigger => 1) if (is_transactional);
record_info('Installed certificates packages', script_output('rpm -qa | grep certificates'));
# Set long host name to avoid x509 server connection issue
assert_script_run('hostnamectl set-hostname $(hostname -s)');

$self->install_kubevirt_packages();

Expand All @@ -130,6 +136,16 @@ sub rke2_server_setup {
# For network multus backend testing
assert_script_run("sed -i '/ExecStart=/s/server\$/server --cni=multus,canal/' /etc/systemd/system/rke2-server.service");

# Setup cnv-bridge containernetworking plugin: one of the tests requires
# a newer version of the Linux bridge CNI:
# https://github.com/kubevirt/kubevirt/commit/3fa7e2b67f9095d664e83eb1e13b587ab76b4950
assert_script_run("curl -LO https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz");
assert_script_run("curl -LO https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz.sha256");
assert_script_run("sha256sum --check cni-plugins-linux-amd64-v1.1.1.tgz.sha256");
assert_script_run("mkdir -p /opt/cni/bin");
assert_script_run("tar -xOf cni-plugins-linux-amd64-v1.1.1.tgz ./bridge > /opt/cni/bin/cnv-bridge");
assert_script_run("chmod +x /opt/cni/bin/cnv-bridge");

# Enable rke2-server service
systemctl('enable --now rke2-server.service', timeout => 180);
$self->check_service_status();
Expand Down Expand Up @@ -273,7 +289,7 @@ sub deploy_kubevirt_manifests {
# Remove existing local disks
record_info('Remove existing local disks', script_output('[ -d /tmp/hostImages -a -d /mnt/local-storage ] && rm -r /tmp/hostImages /mnt/local-storage', proceed_on_failure => 1));

assert_script_run("kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/v${kubevirt_ver}/rbac-for-testing.yaml");
assert_script_run("kubectl apply -f /usr/share/kube-virt/manifests/testing/rbac-for-testing.yaml");
assert_script_run("kubectl apply -f /usr/share/kube-virt/manifests/testing/disks-images-provider.yaml");

if ($kubevirt_ver lt "0.50.0") {
Expand Down Expand Up @@ -323,7 +339,7 @@ sub setup_longhorn_csi {
assert_script_run("kubectl apply -f https://gitlab.suse.de/virtualization/kubevirt-ci/-/raw/main/storage/longhorn-sc.yaml");

# Ensure only one default storage class exists
assert_script_run(qq(kubectl patch storageclass longhorn-default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'));
assert_script_run(qq(kubectl patch storageclass longhorn-default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'));
assert_script_run("kubectl delete --ignore-not-found configmaps -n longhorn-system longhorn-storageclass");
assert_script_run("kubectl delete --ignore-not-found storageclass longhorn");

Expand Down Expand Up @@ -407,7 +423,7 @@ EOF
# bsc#1210906
assert_script_run("sysctl -w vm.unprivileged_userfaultfd=1");
# Installing Whereabouts plugin
assert_script_run("git clone https://github.com/k8snetworkplumbingwg/whereabouts && cd whereabouts", 600);
assert_script_run("git clone --depth 1 https://github.com/k8snetworkplumbingwg/whereabouts && cd whereabouts", 600);
assert_script_run("kubectl apply -f doc/crds/daemonset-install.yaml " .
"-f doc/crds/whereabouts.cni.cncf.io_ippools.yaml " .
"-f doc/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml && cd");
Expand Down

0 comments on commit 98bb07f

Please sign in to comment.