Skip to content

Commit f77c6f2

Browse files
authored
Merge pull request #22009 from medyagh/kvm_crios
ci: add kvm crio to prow
2 parents ac6618d + a8fcc8e commit f77c6f2

File tree

7 files changed

+131
-66
lines changed

7 files changed

+131
-66
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -x
19+
20+
OS="linux"
21+
ARCH="amd64"
22+
DRIVER="kvm2"
23+
CONTAINER_RUNTIME="crio"
24+
# in prow, if you want libvirtd to be run, you have to start a privileged container as root
25+
EXTRA_START_ARGS=""
26+
EXTRA_TEST_ARGS=""
27+
JOB_NAME="KVM_Crio_Linux_X86-64"
28+
# marking all directories ('*') as trusted, since .git belongs to root, not minikube user
29+
git config --global --add safe.directory '*'
30+
COMMIT=$(git rev-parse HEAD)
31+
MINIKUBE_LOCATION=$COMMIT
32+
echo "running test in $(pwd)"
33+
34+
set +e
35+
sleep 5 # wait for libvirtd to be running
36+
echo "=========libvirtd status=========="
37+
sudo systemctl status libvirtd
38+
echo "=========Check virtualization support=========="
39+
grep -E -q 'vmx|svm' /proc/cpuinfo && echo yes || echo no
40+
echo "=========virt-host-validate=========="
41+
virt-host-validate
42+
43+
set -e
44+
source ./hack/prow/common.sh

hack/prow/minitest/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var deployers = map[string]func(string) deployer.MiniTestDeployer{
3636
var testers = map[string]tester.MiniTestTester{
3737
"kvm-docker-linux-amd64-integration": &tester.KVMDockerLinuxAmd64IntegrationTester{},
3838
"kvm-containerd-linux-amd64-integration": &tester.KVMContainerdLinuxAmd64IntegrationTester{},
39+
"kvm-crio-linux-amd64-integration": &tester.KVMCRIOLinuxAmd64IntegrationTester{},
3940
"none-docker-linux-amd64-integration": &tester.NoneDockerLinuxAmd64IntegrationTester{},
4041
}
4142

hack/prow/minitest/tester/kvm_containerd_linux_amd64_integration.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ limitations under the License.
1616

1717
package tester
1818

19-
import (
20-
"fmt"
21-
"os"
22-
23-
"k8s.io/klog/v2"
24-
)
25-
2619
var _ MiniTestTester = &KVMDockerLinuxAmd64IntegrationTester{}
2720

2821
// this runs the integration tests with kvm2 driver and a docker container runtime.
@@ -31,30 +24,5 @@ type KVMContainerdLinuxAmd64IntegrationTester struct {
3124

3225
// Run implements MiniTestTester.
3326
func (k *KVMContainerdLinuxAmd64IntegrationTester) Run(runner MiniTestRunner) error {
34-
35-
if up, err := runner.IsUp(); err != nil || !up {
36-
klog.Errorf("tester: deployed environment is not up: %v", err)
37-
}
38-
if err := runner.SyncToRemote(".", "~/minikube", []string{".cache"}); err != nil {
39-
klog.Errorf("failed to sync file in docker deployer: %v", err)
40-
}
41-
pr := os.Getenv("PULL_NUMBER")
42-
43-
var testErr error
44-
// install docker and libvirtd first then run the test in a new shell
45-
if err := runner.Execute("cd minikube && ./hack/prow/integration_pre_install.sh"); err != nil {
46-
klog.Errorf("failed to install docker in env: %v", err)
47-
return err
48-
}
49-
if testErr = runner.Execute(fmt.Sprintf("cd minikube && PULL_NUMBER=\"%s\" ./hack/prow/integration_kvm_containerd_linux_x86-64.sh", pr)); testErr != nil {
50-
klog.Errorf("failed to execute command in env: %v", testErr)
51-
// don't return here, we still want to collect the test reports
52-
}
53-
54-
// prow requires result file to be copied to $ARTIFACTS. All other files will not be persisted.
55-
if err := copyFileToArtifact(runner); err != nil {
56-
return err
57-
}
58-
return testErr
59-
27+
return kvmGeneralTester(runner, "./hack/prow/integration_kvm_containerd_linux_x86-64.sh")
6028
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package tester
18+
19+
var _ MiniTestTester = &KVMDockerLinuxAmd64IntegrationTester{}
20+
21+
// this runs the integration tests with kvm2 driver and a docker container runtime.
22+
type KVMCRIOLinuxAmd64IntegrationTester struct {
23+
}
24+
25+
// Run implements MiniTestTester.
26+
func (k *KVMCRIOLinuxAmd64IntegrationTester) Run(runner MiniTestRunner) error {
27+
return kvmGeneralTester(runner, "./hack/prow/integration_kvm_crio_linux_x86-64.sh")
28+
}

hack/prow/minitest/tester/kvm_docker_linux_amd64_integration.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ limitations under the License.
1616

1717
package tester
1818

19-
import (
20-
"fmt"
21-
"os"
22-
23-
"k8s.io/klog/v2"
24-
)
25-
2619
var _ MiniTestTester = &KVMDockerLinuxAmd64IntegrationTester{}
2720

2821
// this runs the integration tests with kvm2 driver and a docker container runtime.
@@ -31,30 +24,5 @@ type KVMDockerLinuxAmd64IntegrationTester struct {
3124

3225
// Run implements MiniTestTester.
3326
func (k *KVMDockerLinuxAmd64IntegrationTester) Run(runner MiniTestRunner) error {
34-
35-
if up, err := runner.IsUp(); err != nil || !up {
36-
klog.Errorf("tester: deployed environment is not up: %v", err)
37-
}
38-
if err := runner.SyncToRemote(".", "~/minikube", []string{".cache"}); err != nil {
39-
klog.Errorf("failed to sync file in docker deployer: %v", err)
40-
}
41-
pr := os.Getenv("PULL_NUMBER")
42-
43-
var testErr error
44-
// install docker and libvirtd first then run the test in a new shell
45-
if err := runner.Execute("cd minikube && ./hack/prow/integration_pre_install.sh"); err != nil {
46-
klog.Errorf("failed to install docker in env: %v", err)
47-
return err
48-
}
49-
if testErr = runner.Execute(fmt.Sprintf("cd minikube && PULL_NUMBER=\"%s\" ./hack/prow/integration_kvm_docker_linux_x86-64.sh", pr)); testErr != nil {
50-
klog.Errorf("failed to execute command in env: %v", testErr)
51-
// don't return here, we still want to collect the test reports
52-
}
53-
54-
// prow requires result file to be copied to $ARTIFACTS. All other files will not be persisted.
55-
if err := copyFileToArtifact(runner); err != nil {
56-
return err
57-
}
58-
return testErr
59-
27+
return kvmGeneralTester(runner, "./hack/prow/integration_kvm_docker_linux_x86-64.sh")
6028
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package tester
18+
19+
import (
20+
"fmt"
21+
"os"
22+
23+
"k8s.io/klog/v2"
24+
)
25+
26+
func kvmGeneralTester(runner MiniTestRunner, script string) error {
27+
if up, err := runner.IsUp(); err != nil || !up {
28+
klog.Errorf("tester: deployed environment is not up: %v", err)
29+
}
30+
if err := runner.SyncToRemote(".", "~/minikube", []string{".cache"}); err != nil {
31+
klog.Errorf("failed to sync file in docker deployer: %v", err)
32+
}
33+
pr := os.Getenv("PULL_NUMBER")
34+
35+
var testErr error
36+
// install docker and libvirtd first then run the test in a new shell
37+
if err := runner.Execute("cd minikube && ./hack/prow/integration_pre_install.sh"); err != nil {
38+
klog.Errorf("failed to install docker in env: %v", err)
39+
return err
40+
}
41+
if testErr = runner.Execute(fmt.Sprintf("cd minikube && PULL_NUMBER=\"%s\" %s", pr, script)); testErr != nil {
42+
klog.Errorf("failed to execute command in env: %v", testErr)
43+
// don't return here, we still want to collect the test reports
44+
}
45+
46+
// prow requires result file to be copied to $ARTIFACTS. All other files will not be persisted.
47+
if err := copyFileToArtifact(runner); err != nil {
48+
return err
49+
}
50+
return testErr
51+
}

hack/prow/prow.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ integration-prow-kvm-containerd-linux-x86-64: setup-prow-gcp-ssh-keys build-mini
2424
./hack/prow/minikube_cross_build.sh $(GO_VERSION) linux amd64
2525
./out/minitest --deployer boskos --tester kvm-containerd-linux-amd64-integration --config hack/prow/bosksos-nested.json
2626

27+
.PHONY: integration-prow-kvm-crio-linux-x86-64
28+
integration-prow-kvm-crio-linux-x86-64: setup-prow-gcp-ssh-keys build-mini-test
29+
./hack/prow/minikube_cross_build.sh $(GO_VERSION) linux amd64
30+
./out/minitest --deployer boskos --tester kvm-crio-linux-amd64-integration --config hack/prow/bosksos-nested.json
31+
2732
.PHONY: build-mini-test
2833
build-mini-test: # build minitest binary
2934
GOTOOLCHAIN=auto go build -C ./hack/prow/minitest -o $(PWD)/out/minitest .

0 commit comments

Comments
 (0)