forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_repos.go
189 lines (163 loc) · 5.92 KB
/
sample_repos.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package images
import (
"fmt"
"time"
"k8s.io/kubernetes/test/e2e"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
)
type SampleRepoConfig struct {
repoName string
templateURL string
buildConfigName string
serviceName string
deploymentConfigName string
expectedString string
appPath string
}
// NewSampleRepoTest creates a function for a new ginkgo test case that will instantiate a template
// from a url, kick off the buildconfig defined in that template, wait for the build/deploy,
// and then confirm the application is serving an expected string value.
func NewSampleRepoTest(c SampleRepoConfig) func() {
return func() {
defer g.GinkgoRecover()
var oc = exutil.NewCLI(c.repoName+"-repo-test", exutil.KubeConfigPath())
g.JustBeforeEach(func() {
g.By("Waiting for builder service account")
err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace()))
o.Expect(err).NotTo(o.HaveOccurred())
})
g.Describe("Building "+c.repoName+" app from new-app", func() {
g.It(fmt.Sprintf("should build a "+c.repoName+" image and run it in a pod"), func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
g.By(fmt.Sprintf("calling oc new-app with the " + c.repoName + " example template"))
err := oc.Run("new-app").Args("-f", c.templateURL).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
// all the templates automatically start a build.
buildName := c.buildConfigName + "-1"
g.By("expecting the build is in the Complete phase")
err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), buildName, exutil.CheckBuildSuccessFn, exutil.CheckBuildFailedFn)
if err != nil {
logs, _ := oc.Run("build-logs").Args(buildName).Output()
e2e.Failf("build failed: %s", logs)
}
g.By("expecting the deployment to be complete")
err = exutil.WaitForADeploymentToComplete(oc.KubeREST().ReplicationControllers(oc.Namespace()), c.deploymentConfigName)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("expecting the service is available")
serviceIP, err := oc.Run("get").Args("service", c.serviceName).Template("{{ .spec.clusterIP }}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(serviceIP).ShouldNot(o.Equal(""))
g.By("expecting an endpoint is available")
err = oc.KubeFramework().WaitForAnEndpoint(c.serviceName)
o.Expect(err).NotTo(o.HaveOccurred())
response, err := exutil.FetchURL("http://"+serviceIP+":8080"+c.appPath, time.Duration(30*time.Second))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(response).Should(o.ContainSubstring(c.expectedString))
})
})
}
}
var _ = g.Describe("[images][Slow] openshift sample application repositories", func() {
g.Describe("[images][ruby] test ruby images with rails-ex db repo", NewSampleRepoTest(
SampleRepoConfig{
"rails-postgresql",
"https://raw.githubusercontent.com/openshift/rails-ex/master/openshift/templates/rails-postgresql.json",
"rails-postgresql-example",
"rails-postgresql-example",
"rails-postgresql-example",
"Listing articles",
"/articles",
},
))
g.Describe("[images][python] test python images with django-ex db repo", NewSampleRepoTest(
SampleRepoConfig{
"django-psql",
"https://raw.githubusercontent.com/openshift/django-ex/master/openshift/templates/django-postgresql.json",
"django-psql-example",
"django-psql-example",
"django-psql-example",
"Page views: 1",
"",
},
))
g.Describe("[images][nodejs] test nodejs images with nodejs-ex db repo", NewSampleRepoTest(
SampleRepoConfig{
"nodejs-mongodb",
"https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs-mongodb.json",
"nodejs-mongodb-example",
"nodejs-mongodb-example",
"nodejs-mongodb-example",
"<span class=\"code\" id=\"count-value\">1</span>",
"",
},
))
var _ = g.Describe("[images][php] test php images with cakephp-ex db repo", NewSampleRepoTest(
SampleRepoConfig{
"cakephp-mysql",
"https://raw.githubusercontent.com/openshift/cakephp-ex/master/openshift/templates/cakephp-mysql.json",
"cakephp-mysql-example",
"cakephp-mysql-example",
"cakephp-mysql-example",
"<span class=\"code\" id=\"count-value\">1</span>",
"",
},
))
var _ = g.Describe("[images][perl] test perl images with dancer-ex db repo", NewSampleRepoTest(
SampleRepoConfig{
"dancer-mysql",
"https://raw.githubusercontent.com/openshift/dancer-ex/master/openshift/templates/dancer-mysql.json",
"dancer-mysql-example",
"dancer-mysql-example",
"dancer-mysql-example",
"<span class=\"code\" id=\"count-value\">1</span>",
"",
},
))
// test the no-db templates too
g.Describe("[images][python] test python images with django-ex repo", NewSampleRepoTest(
SampleRepoConfig{
"django",
"https://raw.githubusercontent.com/openshift/django-ex/master/openshift/templates/django.json",
"django-example",
"django-example",
"django-example",
"Welcome",
"",
},
))
g.Describe("[images][nodejs] images with nodejs-ex repo", NewSampleRepoTest(
SampleRepoConfig{
"nodejs",
"https://raw.githubusercontent.com/openshift/nodejs-ex/master/openshift/templates/nodejs.json",
"nodejs-example",
"nodejs-example",
"nodejs-example",
"Welcome",
"",
},
))
var _ = g.Describe("[images][php] test php images with cakephp-ex repo", NewSampleRepoTest(
SampleRepoConfig{
"cakephp",
"https://raw.githubusercontent.com/openshift/cakephp-ex/master/openshift/templates/cakephp.json",
"cakephp-example",
"cakephp-example",
"cakephp-example",
"Welcome",
"",
},
))
var _ = g.Describe("[images][perl] test perl images with dancer-ex repo", NewSampleRepoTest(
SampleRepoConfig{
"dancer",
"https://raw.githubusercontent.com/openshift/dancer-ex/master/openshift/templates/dancer.json",
"dancer-example",
"dancer-example",
"dancer-example",
"Welcome",
"",
},
))
})