Skip to content

Commit

Permalink
A simple end to end pod with vm type in E2E (#638)
Browse files Browse the repository at this point in the history
* add a simple e2e test for vm type

* add a simple e2e test for vm type

* add a simple e2e test for vm type

* make update changes

* add vmpod test to conformance test data

Co-authored-by: Yunwen Bai <yunwenbai@yunwens-mbp.lan>
Co-authored-by: root <root@ip-172-31-8-178.us-west-2.compute.internal>
Co-authored-by: Xiaoning Ding <xiaoning.ding@futurewei.com>
  • Loading branch information
4 people authored Sep 8, 2020
1 parent ae662ef commit 7983fde
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/conformance/testdata/conformance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ test/e2e/node/events.go: "should be sent by kubelets and the scheduler about pod
test/e2e/node/pods.go: "should be submitted and removed"
test/e2e/node/pods.go: "should be submitted and removed"
test/e2e/node/pre_stop.go: "should call prestop when killing a pod"
test/e2e/node/vmpods.go: "should be submitted and removed"
test/e2e/scheduling/predicates.go: "validates resource limits of pods that are allowed to run"
test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if not matching"
test/e2e/scheduling/predicates.go: "validates that NodeSelector is respected if matching"
Expand Down
1 change: 1 addition & 0 deletions test/e2e/node/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ go_library(
"security_context.go",
"ssh.go",
"ttlafterfinished.go",
"vmpods.go",
],
importpath = "k8s.io/kubernetes/test/e2e/node",
visibility = ["//visibility:public"],
Expand Down
79 changes: 79 additions & 0 deletions test/e2e/node/vmpods.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright 2020 Authors of Arktos - file modified.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package node

import (
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"
)

// smoke level e2e case
var _ = SIGDescribe("Basic VM Type test", func() {
f := framework.NewDefaultFramework("podswithvmtype")

framework.KubeDescribe("Pods with vm type", func() {
var podClient *framework.PodClient
ginkgo.BeforeEach(func() {
podClient = f.PodClient()
})

framework.ConformanceIt("should be submitted and removed [Arktos-CI]", func() {
ginkgo.By("creating the pod")
name := "pod-" + string(uuid.NewUUID())
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"name": name,
},
},
Spec: v1.PodSpec{
VirtualMachine: &v1.VirtualMachine{
KeyPairName: "foobar",
Name: "vm1",
Image: imageutils.GetE2EImage(imageutils.Cirros),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("1"),
v1.ResourceMemory: resource.MustParse("500Mi"),
},
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("1"),
v1.ResourceMemory: resource.MustParse("500Mi"),
},
},
},
},
}

ginkgo.By("submitting the pod to kubernetes")
podClient.Create(pod)

ginkgo.By("verifying QOS class is set on the pod")
pod, err := podClient.Get(name, metav1.GetOptions{})
framework.ExpectNoError(err, "failed to query pod")
gomega.Expect(pod.Status.QOSClass == v1.PodQOSGuaranteed)
})
})
})
21 changes: 21 additions & 0 deletions test/utils/image/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type RegistryList struct {
GoogleContainerRegistry string `yaml:"googleContainerRegistry"`
PrivateRegistry string `yaml:"privateRegistry"`
SampleRegistry string `yaml:"sampleRegistry"`
CirrosRegistry string `yaml:"cirrosRegistry"`
}

// Config holds an images registry, name, and version
Expand Down Expand Up @@ -69,6 +70,7 @@ func initReg() RegistryList {
GoogleContainerRegistry: "gcr.io/google-containers",
PrivateRegistry: "gcr.io/k8s-authenticated-test",
SampleRegistry: "gcr.io/google-samples",
CirrosRegistry: "download.cirros-cloud.net",
}
repoList := os.Getenv("KUBE_TEST_REPO_LIST")
if repoList == "" {
Expand Down Expand Up @@ -98,6 +100,7 @@ var (
// PrivateRegistry is an image repository that requires authentication
PrivateRegistry = registry.PrivateRegistry
sampleRegistry = registry.SampleRegistry
cirros = registry.CirrosRegistry

// Preconfigured image configs
imageConfigs = initImageConfigs()
Expand Down Expand Up @@ -213,6 +216,8 @@ const (
VolumeRBDServer
// WindowsNanoServer image
WindowsNanoServer
// Cirros image
Cirros
)

func initImageConfigs() map[int]Config {
Expand Down Expand Up @@ -271,6 +276,7 @@ func initImageConfigs() map[int]Config {
configs[VolumeGlusterServer] = Config{e2eRegistry, "volume/gluster", "1.0"}
configs[VolumeRBDServer] = Config{e2eRegistry, "volume/rbd", "1.0.1"}
configs[WindowsNanoServer] = Config{e2eRegistry, "windows-nanoserver", "v1"}
configs[Cirros] = Config{cirros, "cirros-0.5.1-x86_64-disk.img", "0.5.1"}
return configs
}

Expand All @@ -294,7 +300,22 @@ func (i *Config) GetE2EImage() string {
return fmt.Sprintf("%s/%s:%s", i.registry, i.name, i.version)
}

// Cirros image url format is site/version/name
func GetE2EVmImage(image int) string {
return fmt.Sprintf("%s/%s:%s", imageConfigs[image].registry, imageConfigs[image].version, imageConfigs[image].name)
}

func (i *Config) GetE2EVmImage() string {
return fmt.Sprintf("%s/%s:%s", i.registry, i.version, i.name)
}

// GetPauseImageName returns the pause image name with proper version
func GetPauseImageName() string {
return GetE2EImage(Pause)
}

// Default VM test image with 0.5.1 version of cirros image
// download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img
func GetDefaultVmE2EImage() string {
return GetE2EVmImage(Cirros)
}

0 comments on commit 7983fde

Please sign in to comment.