Skip to content

Commit 2d3ebd0

Browse files
authored
Merge pull request #705 from lukaszo/longevity
Add longevity tests
2 parents 69ff207 + 239a80e commit 2d3ebd0

24 files changed

+511
-42
lines changed

build/cmd.sh

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ function build_internal {
444444
go build -i -o "${project_dir}/_output/vmwrapper" ./cmd/vmwrapper
445445
go build -i -o "${project_dir}/_output/flexvolume_driver" ./cmd/flexvolume_driver
446446
go test -i -c -o "${project_dir}/_output/virtlet-e2e-tests" ./tests/e2e
447+
go build -i -o "${project_dir}/_output/virtlet-longevity-tests" -ldflags "${ldflags}" ./cmd/longevity
447448
}
448449

449450
function release_description {

cmd/longevity/longevity.go

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Copyright 2018 Mirantis
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 main
18+
19+
import (
20+
"flag"
21+
22+
"github.com/Mirantis/virtlet/tests/e2e/framework"
23+
"github.com/Mirantis/virtlet/tests/longevity"
24+
"github.com/golang/glog"
25+
)
26+
27+
func main() {
28+
baseTest := flag.Bool("base", false, "Run base longevity tests")
29+
stressTest := flag.Bool("stress", false, "Run longevity stress tests")
30+
31+
flag.Parse()
32+
33+
glog.Infof("Starting Virtlet longevity tests...")
34+
controller, err := framework.NewController("")
35+
if err != nil {
36+
glog.Fatal(err)
37+
}
38+
39+
instances := []*longevity.VMInstance{}
40+
41+
if *baseTest {
42+
instances = append(instances, longevity.GetBaseTests(controller)...)
43+
}
44+
if *stressTest {
45+
instances = append(instances, longevity.GetStressTests(controller)...)
46+
}
47+
48+
err = longevity.Run(controller, instances)
49+
if err != nil {
50+
glog.Fatal(err)
51+
}
52+
controller.Finalize()
53+
}

glide.lock

+22-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import:
3535
version: bcac9884e7502bb2b474c0339d889cb981a2f27f
3636
- package: github.com/onsi/ginkgo
3737
- package: github.com/onsi/gomega
38+
version: v1.4.0
3839
- package: golang.org/x/sync
3940
subpackages:
4041
- syncmap
@@ -55,6 +56,8 @@ import:
5556
version: edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c
5657
subpackages:
5758
- reference
59+
- package: github.com/docker/engine-api
60+
version: dea108d3aa0c67d7162a3fd8aa65f38a430019fd
5861
- package: github.com/opencontainers/go-digest
5962
version: a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb
6063
- package: github.com/spf13/pflag

tests/e2e/basic_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var _ = Describe("Virtlet [Basic cirros tests]", func() {
3838

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

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

tests/e2e/ceph_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var _ = Describe("Ceph volumes tests", func() {
6565
})
6666
}
6767

68-
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
68+
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, podCustomization)).To(Succeed())
6969
var err error
7070
_, err = vm.Pod()
7171
Expect(err).NotTo(HaveOccurred())
@@ -141,7 +141,7 @@ var _ = Describe("Ceph volumes tests", func() {
141141
})
142142
}
143143

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

tests/e2e/cloudinit_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var _ = Describe("Cloud-init related tests", func() {
3737
Name: "cm-ssh-key-impl",
3838
},
3939
Data: map[string]string{
40-
"authorized_keys": sshPublicKey,
40+
"authorized_keys": SshPublicKey,
4141
},
4242
}
4343
_, err := controller.ConfigMaps().Create(cm)
@@ -46,7 +46,7 @@ var _ = Describe("Cloud-init related tests", func() {
4646
vm = controller.VM("ssh-from-cm-impl")
4747
Expect(vm.Create(VMOptions{
4848
SSHKeySource: "configmap/cm-ssh-key-impl",
49-
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
49+
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
5050
})
5151

5252
AfterAll(func() {
@@ -68,7 +68,7 @@ var _ = Describe("Cloud-init related tests", func() {
6868
Name: "cm-ssh-key-expl",
6969
},
7070
Data: map[string]string{
71-
"myKey": sshPublicKey,
71+
"myKey": SshPublicKey,
7272
},
7373
}
7474
_, err := controller.ConfigMaps().Create(cm)
@@ -77,7 +77,7 @@ var _ = Describe("Cloud-init related tests", func() {
7777
vm = controller.VM("ssh-from-cm-expl")
7878
Expect(vm.Create(VMOptions{
7979
SSHKeySource: "configmap/cm-ssh-key-expl/myKey",
80-
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
80+
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
8181
})
8282

8383
AfterAll(func() {
@@ -99,7 +99,7 @@ var _ = Describe("Cloud-init related tests", func() {
9999
Name: "secret-ssh-key-impl",
100100
},
101101
StringData: map[string]string{
102-
"authorized_keys": sshPublicKey,
102+
"authorized_keys": SshPublicKey,
103103
},
104104
}
105105
_, err := controller.Secrets().Create(secret)
@@ -108,7 +108,7 @@ var _ = Describe("Cloud-init related tests", func() {
108108
vm = controller.VM("ssh-from-secret-impl")
109109
Expect(vm.Create(VMOptions{
110110
SSHKeySource: "secret/secret-ssh-key-impl",
111-
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
111+
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
112112
})
113113

114114
AfterAll(func() {
@@ -130,7 +130,7 @@ var _ = Describe("Cloud-init related tests", func() {
130130
Name: "secret-ssh-key-expl",
131131
},
132132
StringData: map[string]string{
133-
"myKey": sshPublicKey,
133+
"myKey": SshPublicKey,
134134
},
135135
}
136136
_, err := controller.Secrets().Create(secret)
@@ -139,7 +139,7 @@ var _ = Describe("Cloud-init related tests", func() {
139139
vm = controller.VM("ssh-from-secret-expl")
140140
Expect(vm.Create(VMOptions{
141141
SSHKeySource: "secret/secret-ssh-key-expl/myKey",
142-
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
142+
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
143143
})
144144

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

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

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

251251
AfterAll(func() {

tests/e2e/cni_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You may obtain a copy of the License at
77
88
http://www.apache.org/licenses/LICENSE-2.0
99
10-
Unless required by applicable law or agreed to in writing, software
10+
Unless required by Applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
@@ -35,7 +35,7 @@ var _ = Describe("Virtlet CNI", func() {
3535
// if network namespace was deleted
3636
It("Should delete network namespace when VM is deleted", func() {
3737
vm = controller.VM("cirros-vm")
38-
err := vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
38+
err := vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)
3939
Expect(err).NotTo(HaveOccurred())
4040

4141
virtletPod, err := vm.VirtletPod()

tests/e2e/common.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434

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

140140
type VMOptions framework.VMOptions
141141

142-
func (o VMOptions) applyDefaults() framework.VMOptions {
142+
func (o VMOptions) ApplyDefaults() framework.VMOptions {
143143
res := framework.VMOptions(o)
144144
if res.Image == "" {
145145
res.Image = *vmImageLocation
146146
}
147147
if res.SSHKey == "" && res.SSHKeySource == "" {
148-
res.SSHKey = sshPublicKey
148+
res.SSHKey = SshPublicKey
149149
}
150150
if res.VCPUCount == 0 {
151151
res.VCPUCount = 1

tests/e2e/constants.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ package e2e
1818

1919
const (
2020
defaultVMImageLocation = "download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img"
21-
defaultSSHUser = "cirros"
21+
DefaultSSHUser = "cirros"
2222

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

28-
sshPrivateKey = `
28+
SshPrivateKey = `
2929
-----BEGIN RSA PRIVATE KEY-----
3030
MIIEpAIBAAKCAQEAmiRHBQ1xCtmW19GS0tRCGBWUWwwHEX7lY6bLUnNA3vPrFdWo
3131
rvnXj8XZLg0cKhbQspOnRGZLLIzpAV7a4tNDBAi5Iq+hXB95CjibWyer8t7miXPc

tests/e2e/framework/common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func RunSimple(executor Executor, command ...string) (string, error) {
6767
if err != nil {
6868
if ce, ok := err.(CommandError); ok {
6969
if ce.ExitCode != 0 {
70-
return "", fmt.Errorf("command exited with code %d, stderr: %s", ce.ExitCode, strings.TrimSpace(stderr))
70+
return "", fmt.Errorf("command exited with code %d, stderr: %s", ce.ExitCode, strings.TrimSpace(stderr)+strings.TrimSpace(stdout))
7171
}
7272
return strings.TrimSpace(stdout), nil
7373
}

tests/e2e/hung_vm_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var _ = Describe("Hung VM", func() {
3333

3434
BeforeAll(func() {
3535
vm = controller.VM("hung-vm")
36-
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
36+
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
3737
var err error
3838
_, err = vm.Pod()
3939
Expect(err).NotTo(HaveOccurred())

tests/e2e/image_name_translation_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var _ = Describe("Image URL", func() {
5454

5555
It("Can be specified in CRD [Conformance]", func() {
5656
vm := controller.VM("cirros-vm-with-remapped-image")
57-
Expect(vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
57+
Expect(vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
5858
_, err := vm.Pod()
5959
Expect(err).NotTo(HaveOccurred())
6060
deleteVM(vm)

tests/e2e/multi_cni_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func makeMultiCNIVM(name string, addCNIAnnotation bool) *multiCNIVM {
100100
if addCNIAnnotation {
101101
opts.MultiCNI = "calico,flannel"
102102
}
103-
Expect(vm.Create(opts.applyDefaults(), time.Minute*5, nil)).To(Succeed())
103+
Expect(vm.Create(opts.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
104104
vmPod, err := vm.Pod()
105105
Expect(err).NotTo(HaveOccurred())
106106
return &multiCNIVM{

tests/e2e/resources_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var _ = Describe("VM resources", func() {
3737
vm = controller.VM("vm-resources")
3838
Expect(vm.Create(VMOptions{
3939
VCPUCount: 2,
40-
}.applyDefaults(), time.Minute*5, nil)).To(Succeed())
40+
}.ApplyDefaults(), time.Minute*5, nil)).To(Succeed())
4141
do(vm.Pod())
4242
})
4343

tests/e2e/restart_virtlet_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var _ = Describe("Virtlet restart [Disruptive]", func() {
3636

3737
BeforeAll(func() {
3838
vm = controller.VM("cirros-vm")
39-
vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
39+
vm.Create(VMOptions{}.ApplyDefaults(), time.Minute*5, nil)
4040
var err error
4141
vmPod, err = vm.Pod()
4242
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)