5
5
package oracle .kubernetes .operator ;
6
6
7
7
import java .util .Map ;
8
- import oracle .kubernetes .operator .utils .CoherenceUtils ;
9
8
import oracle .kubernetes .operator .utils .Domain ;
10
- import oracle .kubernetes .operator .utils .K8sTestUtils ;
11
9
import oracle .kubernetes .operator .utils .Operator ;
12
10
import oracle .kubernetes .operator .utils .TestUtils ;
13
11
import org .junit .AfterClass ;
14
12
import org .junit .Assert ;
15
13
import org .junit .Assume ;
16
14
import org .junit .BeforeClass ;
17
15
import org .junit .FixMethodOrder ;
18
- import org .junit .Ignore ;
19
16
import org .junit .Test ;
20
17
import org .junit .runners .MethodSorters ;
21
18
/**
@@ -28,9 +25,14 @@ public class ITCoherenceTests extends BaseTest {
28
25
29
26
private static Domain domain = null ;
30
27
private static Operator operator1 ;
31
- private static String domainUid = "" ;
32
- private static String restartTmpDir = "" ;
33
- private static String originalYaml ;
28
+
29
+ private static final String testAppName = "coherence-proxy-client" ;
30
+
31
+ private static final String PROXY_CLIENT_SCRIPT = "buildRunProxyClient.sh" ;
32
+ private static final String PROXY_CLIENT_APP_NAME = "coherence-proxy-client" ;
33
+ private static final String OP_CACHE_LOAD = "load" ;
34
+ private static final String OP_CACHE_VALIDATE = "validate" ;
35
+ private static final String PROXY_PORT = "9000" ;
34
36
35
37
/**
36
38
* This method gets called only once before any of the test methods are executed. It does the
@@ -46,12 +48,6 @@ public static void staticPrepare() throws Exception {
46
48
if (!QUICKTEST ) {
47
49
initialize (APP_PROPS_FILE );
48
50
49
- // The default cmd loop sleep is too long and we could miss states like terminating. Change the
50
- // sleep and iterations
51
- //
52
- setWaitTimePod (2 );
53
- setMaxIterationsPod (125 );
54
-
55
51
if (operator1 == null ) {
56
52
operator1 = TestUtils .createOperator (OPERATOR1_YAML );
57
53
}
@@ -67,26 +63,80 @@ public static void staticPrepare() throws Exception {
67
63
public static void staticUnPrepare () throws Exception {
68
64
if (!QUICKTEST ) {
69
65
tearDown (new Object () {}.getClass ().getEnclosingClass ().getSimpleName ());
70
- logger .info ("SUCCESS" );
71
66
}
72
67
}
73
68
74
69
@ Test
75
70
public void testRollingRestart () throws Exception {
76
-
77
- CoherenceUtils utils = new CoherenceUtils ( );
71
+ String testMethodName = new Object () {}. getClass (). getEnclosingMethod (). getName ();
72
+ logTestBegin ( testMethodName );
78
73
79
74
domain = createDomain ();
80
75
Assert .assertNotNull (domain );
81
76
82
- utils .loadCache ();
77
+ try {
78
+ copyAndExecuteProxyClientInPod (OP_CACHE_LOAD );
83
79
84
- // Do the rolling restart
85
- testServerPodsRestartByChangingEnvProperty ();
80
+ // Do the rolling restart
81
+ restartDomainByChangingEnvProperty ();
86
82
87
- utils .validateCache ();
83
+ copyAndExecuteProxyClientInPod (OP_CACHE_VALIDATE );
84
+ } finally {
85
+ destroyDomain ();
86
+ }
87
+ logger .info ("SUCCESS - " + testMethodName );
88
+ }
88
89
89
- destroyDomain ();
90
+ /**
91
+ * Copy the shell script file and all App files over to the admin pod the run the script to build
92
+ * the proxy client and run the proxy test.
93
+ *
94
+ * @param cacheOp - cache operation
95
+ * @throws Exception exception
96
+ */
97
+ private static void copyAndExecuteProxyClientInPod (String cacheOp ) {
98
+ try {
99
+ final String adminServerPod = domain .getDomainUid () + "-" + domain .getAdminServerName ();
100
+
101
+ final String domainNS = domain .getDomainNs ();
102
+
103
+ // Use the proxy running on Managed Server 1, get the internal POD IP
104
+ String podName = domain .getManagedSeverPodName (1 );
105
+ String ProxyIP = TestUtils .getPodIP (domainNS , "" , podName );
106
+
107
+ String cohAppLocationOnHost = BaseTest .getAppLocationOnHost () + "/" + PROXY_CLIENT_APP_NAME ;
108
+ String cohAppLocationInPod = BaseTest .getAppLocationInPod () + "/" + PROXY_CLIENT_APP_NAME ;
109
+ final String cohScriptPathOnHost = cohAppLocationOnHost + "/" + PROXY_CLIENT_SCRIPT ;
110
+ final String cohScriptPathInPod = cohAppLocationInPod + "/" + PROXY_CLIENT_SCRIPT ;
111
+ final String successMarker = "CACHE-SUCCESS" ;
112
+
113
+ logger .info ("Copying files to admin pod for App " + PROXY_CLIENT_APP_NAME );
114
+
115
+ // Create app dir in the admin pod
116
+ StringBuffer mkdirCmd = new StringBuffer (" -- bash -c 'mkdir -p " );
117
+ mkdirCmd .append (cohAppLocationInPod ).append ("'" );
118
+ TestUtils .kubectlexec (adminServerPod , domainNS , mkdirCmd .toString ());
119
+
120
+ // Copy shell script to the pod
121
+ TestUtils .copyFileViaCat (cohScriptPathOnHost , cohScriptPathInPod , adminServerPod , domainNS );
122
+
123
+ // Copy all App files to the admin pod
124
+ TestUtils .copyAppFilesToPod (
125
+ cohAppLocationOnHost , cohAppLocationInPod , adminServerPod , domainNS );
126
+
127
+ logger .info (
128
+ "Executing script "
129
+ + PROXY_CLIENT_SCRIPT
130
+ + " for App "
131
+ + PROXY_CLIENT_APP_NAME
132
+ + " in the admin pod" );
133
+
134
+ // Run the script to on the admin pod (note first arg is app directory is applocation in pod)
135
+ domain .callShellScriptInAdminPod (
136
+ successMarker , cohScriptPathInPod , cohAppLocationInPod , cacheOp , ProxyIP , PROXY_PORT );
137
+ } catch (Exception e ) {
138
+ throw new RuntimeException (e );
139
+ }
90
140
}
91
141
92
142
/**
@@ -96,21 +146,17 @@ public void testRollingRestart() throws Exception {
96
146
*
97
147
* @throws Exception
98
148
*/
99
- public void testServerPodsRestartByChangingEnvProperty () throws Exception {
149
+ private void restartDomainByChangingEnvProperty () throws Exception {
100
150
101
- Assume .assumeFalse (QUICKTEST );
102
- String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
103
- logTestBegin (testMethodName );
104
-
105
- logger .info (
106
- "About to verifyDomainServerPodRestart for Domain: "
107
- + domain .getDomainUid ()
108
- + " env property: StdoutDebugEnabled=false to StdoutDebugEnabled=true" );
151
+ // The default cmd loop sleep is too long and we could miss states like terminating. Change
152
+ // the
153
+ // sleep and iterations
154
+ //
155
+ setWaitTimePod (2 );
156
+ setMaxIterationsPod (125 );
109
157
110
158
domain .verifyDomainServerPodRestart (
111
159
"\" -Dweblogic.StdoutDebugEnabled=false\" " , "\" -Dweblogic.StdoutDebugEnabled=true\" " );
112
-
113
- logger .info ("SUCCESS - " + testMethodName );
114
160
}
115
161
116
162
private static void destroyDomain () throws Exception {
@@ -136,4 +182,4 @@ private Domain createDomain() throws Exception {
136
182
domain .verifyDomainCreated ();
137
183
return domain ;
138
184
}
139
- }
185
+ }
0 commit comments