@@ -10,6 +10,7 @@ import (
10
10
exutil "github.com/openshift/origin/test/extended/util"
11
11
dbutil "github.com/openshift/origin/test/extended/util/db"
12
12
kapiv1 "k8s.io/api/core/v1"
13
+ e2e "k8s.io/kubernetes/test/e2e/framework"
13
14
)
14
15
15
16
var _ = g .Describe ("[Conformance][image_ecosystem][mongodb][Slow] openshift mongodb replication (with statefulset)" , func () {
@@ -22,103 +23,97 @@ var _ = g.Describe("[Conformance][image_ecosystem][mongodb][Slow] openshift mong
22
23
g .Context ("" , func () {
23
24
g .BeforeEach (func () {
24
25
exutil .DumpDockerInfo ()
26
+ _ , err := exutil .SetupNFSBackedPersistentVolumes (oc , "256Mi" , 3 )
27
+ o .Expect (err ).NotTo (o .HaveOccurred ())
25
28
})
26
29
27
30
g .AfterEach (func () {
31
+ defer exutil .RemoveNFSBackedPersistentVolumes (oc )
32
+ defer exutil .RemoveStatefulSets (oc , "mongodb-replicaset" )
33
+
28
34
if g .CurrentGinkgoTestDescription ().Failed {
29
35
exutil .DumpPodStates (oc )
30
36
exutil .DumpPodLogsStartingWith ("" , oc )
31
37
}
32
- })
33
-
34
- g .Describe ("creating from a template" , func () {
35
- g .AfterEach (func () {
36
- for i := 0 ; i < 3 ; i ++ {
37
- pod := fmt .Sprintf ("mongodb-replicaset-%d" , i )
38
- podLogs , err := oc .Run ("logs" ).Args (pod , "--timestamps" ).Output ()
39
- if err != nil {
40
- ginkgolog ("error retrieving pod logs for %s: %v" , pod , err )
41
- continue
42
- }
43
- ginkgolog ("pod logs for %s:\n %s" , podLogs , err )
44
- }
45
- })
46
- g .It (fmt .Sprintf ("should instantiate the template" ), func () {
47
- oc .SetOutputDir (exutil .TestContext .OutputDir )
48
-
49
- g .By ("creating persistent volumes" )
50
- _ , err := exutil .SetupHostPathVolumes (oc , "256Mi" , 3 )
51
- o .Expect (err ).NotTo (o .HaveOccurred ())
52
- defer exutil .RemoveHostPathVolumes (oc )
53
-
54
- g .By ("creating a new app" )
55
- o .Expect (
56
- oc .Run ("new-app" ).Args (
57
- "-f" , templatePath ,
58
- "-p" , "VOLUME_CAPACITY=256Mi" ,
59
- "-p" , "MEMORY_LIMIT=512Mi" ,
60
- "-p" , "MONGODB_IMAGE=centos/mongodb-32-centos7" ,
61
- "-p" , "MONGODB_SERVICE_NAME=mongodb-replicaset" ,
62
- ).Execute (),
63
- ).Should (o .Succeed ())
64
-
65
- g .By ("waiting for all pods to reach ready status" )
66
- podNames , err := exutil .WaitForPods (
67
- oc .KubeClient ().Core ().Pods (oc .Namespace ()),
68
- exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
69
- exutil .CheckPodIsReadyFn ,
70
- 3 ,
71
- 8 * time .Minute ,
72
- )
38
+ for i := 0 ; i < 3 ; i ++ {
39
+ podLogs , err := oc .Run ("logs" ).Args (fmt .Sprintf ("mongodb-replicaset-%d" , i ), "--timestamps" ).Output ()
73
40
if err != nil {
74
- desc , _ := oc .Run ("describe" ).Args ("statefulset" ).Output ()
75
- ginkgolog ("\n \n Statefulset at failure:\n %s\n \n " , desc )
76
- desc , _ = oc .Run ("describe" ).Args ("pods" ).Output ()
77
- ginkgolog ("\n \n Pods at statefulset failure:\n %s\n \n " , desc )
78
- }
79
- o .Expect (err ).NotTo (o .HaveOccurred ())
80
-
81
- g .By ("expecting that we can insert a new record on primary node" )
82
- mongo := dbutil .NewMongoDB (podNames [0 ])
83
- replicaSet := mongo .(exutil.ReplicaSet )
84
- out , err := replicaSet .QueryPrimary (oc , `db.test.save({ "status" : "passed" })` )
85
- ginkgolog ("save result: %s\n " , out )
86
- o .Expect (err ).ShouldNot (o .HaveOccurred ())
87
-
88
- g .By ("expecting that we can read a record from all members" )
89
- for _ , podName := range podNames {
90
- o .Expect (readRecordFromPod (oc , podName )).To (o .Succeed ())
41
+ e2e .Logf ("error retrieving pod logs for %s: %v" , fmt .Sprintf ("mongodb-replicaset-%d" , i ), err )
42
+ continue
91
43
}
44
+ e2e .Logf ("pod logs for %s:\n %s" , podLogs , err )
45
+ }
46
+ })
47
+ g .It (fmt .Sprintf ("should instantiate the template" ), func () {
48
+ oc .SetOutputDir (exutil .TestContext .OutputDir )
49
+
50
+ g .By ("creating a new app" )
51
+ o .Expect (
52
+ oc .Run ("new-app" ).Args (
53
+ "-f" , templatePath ,
54
+ "-p" , "VOLUME_CAPACITY=256Mi" ,
55
+ "-p" , "MEMORY_LIMIT=512Mi" ,
56
+ "-p" , "MONGODB_IMAGE=centos/mongodb-32-centos7" ,
57
+ "-p" , "MONGODB_SERVICE_NAME=mongodb-replicaset" ,
58
+ ).Execute (),
59
+ ).Should (o .Succeed ())
60
+
61
+ g .By ("waiting for all pods to reach ready status" )
62
+ podNames , err := exutil .WaitForPods (
63
+ oc .KubeClient ().Core ().Pods (oc .Namespace ()),
64
+ exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
65
+ exutil .CheckPodIsReadyFn ,
66
+ 3 ,
67
+ 8 * time .Minute ,
68
+ )
69
+ if err != nil {
70
+ desc , _ := oc .Run ("describe" ).Args ("statefulset" ).Output ()
71
+ e2e .Logf ("\n \n Statefulset at failure:\n %s\n \n " , desc )
72
+ desc , _ = oc .Run ("describe" ).Args ("pods" ).Output ()
73
+ e2e .Logf ("\n \n Pods at statefulset failure:\n %s\n \n " , desc )
74
+ }
75
+ o .Expect (err ).NotTo (o .HaveOccurred ())
76
+
77
+ g .By ("expecting that we can insert a new record on primary node" )
78
+ mongo := dbutil .NewMongoDB (podNames [0 ])
79
+ replicaSet := mongo .(exutil.ReplicaSet )
80
+ out , err := replicaSet .QueryPrimary (oc , `db.test.save({ "status" : "passed" })` )
81
+ e2e .Logf ("save result: %s\n " , out )
82
+ o .Expect (err ).ShouldNot (o .HaveOccurred ())
83
+
84
+ g .By ("expecting that we can read a record from all members" )
85
+ for _ , podName := range podNames {
86
+ o .Expect (readRecordFromPod (oc , podName )).To (o .Succeed ())
87
+ }
92
88
93
- g .By ("restarting replica set" )
94
- err = oc .Run ("delete" ).Args ("pods" , "--all" , "-n" , oc .Namespace ()).Execute ()
95
- o .Expect (err ).ShouldNot (o .HaveOccurred ())
96
-
97
- g .By ("waiting for all pods to be gracefully deleted" )
98
- podNames , err = exutil .WaitForPods (
99
- oc .KubeClient ().Core ().Pods (oc .Namespace ()),
100
- exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
101
- func (pod kapiv1.Pod ) bool { return pod .DeletionTimestamp != nil },
102
- 0 ,
103
- 4 * time .Minute ,
104
- )
105
- o .Expect (err ).NotTo (o .HaveOccurred ())
106
-
107
- g .By ("waiting for all pods to reach ready status" )
108
- podNames , err = exutil .WaitForPods (
109
- oc .KubeClient ().Core ().Pods (oc .Namespace ()),
110
- exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
111
- exutil .CheckPodIsReadyFn ,
112
- 3 ,
113
- 4 * time .Minute ,
114
- )
115
- o .Expect (err ).NotTo (o .HaveOccurred ())
116
-
117
- g .By ("expecting that we can read a record from all members after its restart" )
118
- for _ , podName := range podNames {
119
- o .Expect (readRecordFromPod (oc , podName )).To (o .Succeed ())
120
- }
121
- })
89
+ g .By ("restarting replica set" )
90
+ err = exutil .RemovePodsWithPrefixes (oc , "mongodb-replicaset" )
91
+ o .Expect (err ).ShouldNot (o .HaveOccurred ())
92
+
93
+ g .By ("waiting for all pods to be gracefully deleted" )
94
+ podNames , err = exutil .WaitForPods (
95
+ oc .KubeClient ().Core ().Pods (oc .Namespace ()),
96
+ exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
97
+ func (pod kapiv1.Pod ) bool { return pod .DeletionTimestamp != nil },
98
+ 0 ,
99
+ 4 * time .Minute ,
100
+ )
101
+ o .Expect (err ).NotTo (o .HaveOccurred ())
102
+
103
+ g .By ("waiting for all pods to reach ready status" )
104
+ podNames , err = exutil .WaitForPods (
105
+ oc .KubeClient ().Core ().Pods (oc .Namespace ()),
106
+ exutil .ParseLabelsOrDie ("name=mongodb-replicaset" ),
107
+ exutil .CheckPodIsReadyFn ,
108
+ 3 ,
109
+ 4 * time .Minute ,
110
+ )
111
+ o .Expect (err ).NotTo (o .HaveOccurred ())
112
+
113
+ g .By ("expecting that we can read a record from all members after its restart" )
114
+ for _ , podName := range podNames {
115
+ o .Expect (readRecordFromPod (oc , podName )).To (o .Succeed ())
116
+ }
122
117
})
123
118
})
124
119
})
0 commit comments