forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker_quota.go
85 lines (71 loc) · 2.38 KB
/
docker_quota.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package builds
import (
"fmt"
"os"
"path/filepath"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
)
var _ = g.Describe("[Feature:Builds][quota][Slow] docker build with a quota", func() {
defer g.GinkgoRecover()
const (
buildTestPod = "build-test-pod"
buildTestService = "build-test-svc"
)
fixtures := []struct {
name string
path string
}{
{
name: "docker build",
path: exutil.FixturePath("testdata", "builds", "test-docker-build-quota.json"),
},
{
name: "optimized docker build",
path: exutil.FixturePath("testdata", "builds", "test-docker-build-quota-optimized.json"),
},
}
var (
oc = exutil.NewCLI("docker-build-quota", exutil.KubeConfigPath())
)
g.Context("", func() {
g.BeforeEach(func() {
exutil.DumpDockerInfo()
})
g.JustBeforeEach(func() {
g.By("waiting for default service account")
err := exutil.WaitForServiceAccount(oc.KubeClient().Core().ServiceAccounts(oc.Namespace()), "default")
o.Expect(err).NotTo(o.HaveOccurred())
g.By("waiting for builder service account")
err = exutil.WaitForServiceAccount(oc.KubeClient().Core().ServiceAccounts(oc.Namespace()), "builder")
o.Expect(err).NotTo(o.HaveOccurred())
})
g.AfterEach(func() {
if g.CurrentGinkgoTestDescription().Failed {
exutil.DumpPodStates(oc)
exutil.DumpPodLogsStartingWith("", oc)
}
})
g.Describe("Building from a template", func() {
for _, test := range fixtures {
g.It(fmt.Sprintf("should create a %s with a quota and run it", test.name), func() {
g.By(fmt.Sprintf("calling oc create -f %q", test.path))
err := oc.Run("create").Args("-f", test.path).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting a test build")
path := exutil.FixturePath("testdata", "builds", "build-quota")
o.Expect(os.Chmod(filepath.Join(path, ".s2i", "bin", "assemble"), 0755)).NotTo(o.HaveOccurred())
br, err := exutil.StartBuildAndWait(oc, "docker-build-quota", "--from-dir", path)
g.By("expecting the build is in Failed phase")
br.AssertFailure()
g.By("expecting the build logs to contain the correct cgroups values")
out, err := br.Logs()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("MEMORY=209715200"))
o.Expect(out).To(o.ContainSubstring("MEMORYSWAP=209715200"))
})
}
})
})
})