Skip to content

Commit

Permalink
Merge pull request #705 from lukaszo/longevity
Browse files Browse the repository at this point in the history
Add longevity tests
  • Loading branch information
jellonek authored Jul 11, 2018
2 parents 69ff207 + 239a80e commit 2d3ebd0
Show file tree
Hide file tree
Showing 24 changed files with 511 additions and 42 deletions.
1 change: 1 addition & 0 deletions build/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function build_internal {
go build -i -o "${project_dir}/_output/vmwrapper" ./cmd/vmwrapper
go build -i -o "${project_dir}/_output/flexvolume_driver" ./cmd/flexvolume_driver
go test -i -c -o "${project_dir}/_output/virtlet-e2e-tests" ./tests/e2e
go build -i -o "${project_dir}/_output/virtlet-longevity-tests" -ldflags "${ldflags}" ./cmd/longevity
}

function release_description {
Expand Down
53 changes: 53 additions & 0 deletions cmd/longevity/longevity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2018 Mirantis
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 main

import (
"flag"

"github.com/Mirantis/virtlet/tests/e2e/framework"
"github.com/Mirantis/virtlet/tests/longevity"
"github.com/golang/glog"
)

func main() {
baseTest := flag.Bool("base", false, "Run base longevity tests")
stressTest := flag.Bool("stress", false, "Run longevity stress tests")

flag.Parse()

glog.Infof("Starting Virtlet longevity tests...")
controller, err := framework.NewController("")
if err != nil {
glog.Fatal(err)
}

instances := []*longevity.VMInstance{}

if *baseTest {
instances = append(instances, longevity.GetBaseTests(controller)...)
}
if *stressTest {
instances = append(instances, longevity.GetStressTests(controller)...)
}

err = longevity.Run(controller, instances)
if err != nil {
glog.Fatal(err)
}
controller.Finalize()
}
27 changes: 22 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import:
version: bcac9884e7502bb2b474c0339d889cb981a2f27f
- package: github.com/onsi/ginkgo
- package: github.com/onsi/gomega
version: v1.4.0
- package: golang.org/x/sync
subpackages:
- syncmap
Expand All @@ -55,6 +56,8 @@ import:
version: edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c
subpackages:
- reference
- package: github.com/docker/engine-api
version: dea108d3aa0c67d7162a3fd8aa65f38a430019fd
- package: github.com/opencontainers/go-digest
version: a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb
- package: github.com/spf13/pflag
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = Describe("Virtlet [Basic cirros tests]", func() {

BeforeAll(func() {
vm = controller.VM("cirros-vm")
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
var err error
vmPod, err = vm.Pod()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -182,7 +182,7 @@ var _ = Describe("Virtlet [Disruptive]", func() {
Expect(err).NotTo(HaveOccurred())

vm = controller.VM("cirros-vm")
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})
})

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/ceph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = Describe("Ceph volumes tests", func() {
})
}

Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
var err error
_, err = vm.Pod()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -141,7 +141,7 @@ var _ = Describe("Ceph volumes tests", func() {
})
}

Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
_ = do(vm.Pod()).(*framework.PodInterface)
})

Expand Down
22 changes: 11 additions & 11 deletions tests/e2e/cloudinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = Describe("Cloud-init related tests", func() {
Name: "cm-ssh-key-impl",
},
Data: map[string]string{
"authorized_keys": sshPublicKey,
"authorized_keys": SshPublicKey,
},
}
_, err := controller.ConfigMaps().Create(cm)
Expand All @@ -46,7 +46,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("ssh-from-cm-impl")
Expect(vm.Create(VMOptions{
SSHKeySource: "configmap/cm-ssh-key-impl",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand All @@ -68,7 +68,7 @@ var _ = Describe("Cloud-init related tests", func() {
Name: "cm-ssh-key-expl",
},
Data: map[string]string{
"myKey": sshPublicKey,
"myKey": SshPublicKey,
},
}
_, err := controller.ConfigMaps().Create(cm)
Expand All @@ -77,7 +77,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("ssh-from-cm-expl")
Expect(vm.Create(VMOptions{
SSHKeySource: "configmap/cm-ssh-key-expl/myKey",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand All @@ -99,7 +99,7 @@ var _ = Describe("Cloud-init related tests", func() {
Name: "secret-ssh-key-impl",
},
StringData: map[string]string{
"authorized_keys": sshPublicKey,
"authorized_keys": SshPublicKey,
},
}
_, err := controller.Secrets().Create(secret)
Expand All @@ -108,7 +108,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("ssh-from-secret-impl")
Expect(vm.Create(VMOptions{
SSHKeySource: "secret/secret-ssh-key-impl",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand All @@ -130,7 +130,7 @@ var _ = Describe("Cloud-init related tests", func() {
Name: "secret-ssh-key-expl",
},
StringData: map[string]string{
"myKey": sshPublicKey,
"myKey": SshPublicKey,
},
}
_, err := controller.Secrets().Create(secret)
Expand All @@ -139,7 +139,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("ssh-from-secret-expl")
Expect(vm.Create(VMOptions{
SSHKeySource: "secret/secret-ssh-key-expl/myKey",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand Down Expand Up @@ -173,7 +173,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("userdata-cm")
Expect(vm.Create(VMOptions{
UserDataSource: "configmap/cm-userdata",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand Down Expand Up @@ -208,7 +208,7 @@ var _ = Describe("Cloud-init related tests", func() {
vm = controller.VM("userdata-secret")
Expect(vm.Create(VMOptions{
UserDataSource: "secret/secret-userdata",
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand Down Expand Up @@ -245,7 +245,7 @@ var _ = Describe("Cloud-init related tests", func() {
Expect(vm.Create(VMOptions{
UserDataSource: "configmap/cm-userdata",
UserData: userData,
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
})

AfterAll(func() {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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
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
Expand Down Expand Up @@ -35,7 +35,7 @@ var _ = Describe("Virtlet CNI", func() {
// if network namespace was deleted
It("Should delete network namespace when VM is deleted", func() {
vm = controller.VM("cirros-vm")
err := vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
err := vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)
Expect(err).NotTo(HaveOccurred())

virtletPod, err := vm.VirtletPod()
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

var (
vmImageLocation = flag.String("image", defaultVMImageLocation, "VM image URL (*without http(s)://*")
sshUser = flag.String("sshuser", defaultSSHUser, "default SSH user for VMs")
sshUser = flag.String("sshuser", DefaultSSHUser, "default SSH user for VMs")
includeCloudInitTests = flag.Bool("include-cloud-init-tests", false, "include Cloud-Init tests")
includeUnsafeTests = flag.Bool("include-unsafe-tests", false, "include tests that can be unsafe if they're run outside the build container")
memoryLimit = flag.Int("memoryLimit", 160, "default VM memory limit (in MiB)")
Expand All @@ -57,7 +57,7 @@ func waitSSH(vm *framework.VMInterface) framework.Executor {
Eventually(
func() error {
var err error
ssh, err = vm.SSH(*sshUser, sshPrivateKey)
ssh, err = vm.SSH(*sshUser, SshPrivateKey)
if err != nil {
return err
}
Expand Down Expand Up @@ -139,13 +139,13 @@ func do(value interface{}, extra ...interface{}) interface{} {

type VMOptions framework.VMOptions

func (o VMOptions) applyDefaults() framework.VMOptions {
func (o VMOptions) ApplyDefaults() framework.VMOptions {
res := framework.VMOptions(o)
if res.Image == "" {
res.Image = *vmImageLocation
}
if res.SSHKey == "" && res.SSHKeySource == "" {
res.SSHKey = sshPublicKey
res.SSHKey = SshPublicKey
}
if res.VCPUCount == 0 {
res.VCPUCount = 1
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package e2e

const (
defaultVMImageLocation = "download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img"
defaultSSHUser = "cirros"
DefaultSSHUser = "cirros"

sshPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2ZbX0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+deP" +
SshPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2ZbX0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+deP" +
"xdkuDRwqFtCyk6dEZkssjOkBXtri00MECLkir6FcH3kKOJtbJ6vy3uaJc9w1ERo+wyl6SkAh/+JTJkp7QRXj8oylW5E20LsbnA/dIwW" +
"zAF51PPwF7A7FtNg9DnwPqMkxFo1Th/buOMKbP5ZA1mmNNtmzbMpMfJATvVyiv3ccsSJKOiyQr6UG+j7sc/7jMVz5Xk34Vd0l8GwcB0" +
"334MchHckmqDB142h/NCWTr8oLakDNvkfC1YneAfAO41hDkUbxPtVBG5M/o7P4fxoqiHEX+ZLfRxDtHB53 me@localhost"

sshPrivateKey = `
SshPrivateKey = `
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAmiRHBQ1xCtmW19GS0tRCGBWUWwwHEX7lY6bLUnNA3vPrFdWo
rvnXj8XZLg0cKhbQspOnRGZLLIzpAV7a4tNDBAi5Iq+hXB95CjibWyer8t7miXPc
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func RunSimple(executor Executor, command ...string) (string, error) {
if err != nil {
if ce, ok := err.(CommandError); ok {
if ce.ExitCode != 0 {
return "", fmt.Errorf("command exited with code %d, stderr: %s", ce.ExitCode, strings.TrimSpace(stderr))
return "", fmt.Errorf("command exited with code %d, stderr: %s", ce.ExitCode, strings.TrimSpace(stderr)+strings.TrimSpace(stdout))
}
return strings.TrimSpace(stdout), nil
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/hung_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Hung VM", func() {

BeforeAll(func() {
vm = controller.VM("hung-vm")
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
var err error
_, err = vm.Pod()
Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/image_name_translation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("Image URL", func() {

It("Can be specified in CRD [Conformance]", func() {
vm := controller.VM("cirros-vm-with-remapped-image")
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
_, err := vm.Pod()
Expect(err).NotTo(HaveOccurred())
deleteVM(vm)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/multi_cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func makeMultiCNIVM(name string, addCNIAnnotation bool) *multiCNIVM {
if addCNIAnnotation {
opts.MultiCNI = "calico,flannel"
}
Expect(vm.Create(opts.applyDefaults(), time.Minute*5, nil)).To(Succeed())
Expect(vm.Create(opts.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
vmPod, err := vm.Pod()
Expect(err).NotTo(HaveOccurred())
return &multiCNIVM{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = Describe("VM resources", func() {
vm = controller.VM("vm-resources")
Expect(vm.Create(VMOptions{
VCPUCount: 2,
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
do(vm.Pod())
})

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/restart_virtlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var _ = Describe("Virtlet restart [Disruptive]", func() {

BeforeAll(func() {
vm = controller.VM("cirros-vm")
vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)
var err error
vmPod, err = vm.Pod()
Expect(err).NotTo(HaveOccurred())
Expand Down
Loading

0 comments on commit 2d3ebd0

Please sign in to comment.