@@ -138,12 +138,22 @@ public void verifyPodsCreated() throws Exception {
138
138
}
139
139
140
140
/**
141
- * verify services are created
142
- *
141
+ *
143
142
* @throws Exception
144
143
*/
145
144
public void verifyServicesCreated () throws Exception {
146
- // check admin service
145
+ verifyServicesCreated (false );
146
+ }
147
+
148
+ /**
149
+ * verify services are created
150
+ *
151
+ * @param precreateService - if true check services are created for configuredManagedServerCount number of servers else
152
+ * check for initialManagedServerReplicas number of servers
153
+ * @throws Exception
154
+ */
155
+ public void verifyServicesCreated (boolean precreateService ) throws Exception {
156
+ // check admin service
147
157
logger .info ("Checking if admin service(" + domainUid + "-" + adminServerName + ") is created" );
148
158
TestUtils .checkServiceCreated (domainUid + "-" + adminServerName , domainNS );
149
159
@@ -159,7 +169,7 @@ public void verifyServicesCreated() throws Exception {
159
169
160
170
if (!serverStartPolicy .equals ("ADMIN_ONLY" )) {
161
171
// check managed server services
162
- for (int i = 1 ; i <= initialManagedServerReplicas ; i ++) {
172
+ for (int i = 1 ; i <= ( precreateService ? configuredManagedServerCount : initialManagedServerReplicas ) ; i ++) {
163
173
logger .info (
164
174
"Checking if managed service("
165
175
+ domainUid
@@ -598,9 +608,7 @@ public void destroy() throws Exception {
598
608
public void shutdown () throws Exception {
599
609
int replicas = TestUtils .getClusterReplicas (domainUid , clusterName , domainNS );
600
610
String cmd = "kubectl delete domain " + domainUid + " -n " + domainNS ;
601
- ExecResult result = TestUtils .exec (cmd .toString ());
602
- String output = result .stdout ().trim ();
603
- logger .info ("command to delete domain " + cmd + " \n returned " + output );
611
+ ExecResult result = TestUtils .exec (cmd .toString (), true );
604
612
verifyDomainDeleted (replicas );
605
613
}
606
614
@@ -611,15 +619,8 @@ public void shutdown() throws Exception {
611
619
*/
612
620
public void shutdownUsingServerStartPolicy () throws Exception {
613
621
int replicas = TestUtils .getClusterReplicas (domainUid , clusterName , domainNS );
614
- String cmd =
615
- "kubectl patch domain "
616
- + domainUid
617
- + " -n "
618
- + domainNS
619
- + " -p '{\" spec\" :{\" serverStartPolicy\" :\" NEVER\" }}' --type merge" ;
620
- ExecResult result = TestUtils .exec (cmd );
621
- String output = result .stdout ().trim ();
622
- logger .info ("command to shutdown domain " + cmd + " \n returned " + output );
622
+ String patchStr = "'{\" spec\" :{\" serverStartPolicy\" :\" NEVER\" }}' " ;
623
+ TestUtils .kubectlpatch (domainUid , domainNS , patchStr );
623
624
verifyServerPodsDeleted (replicas );
624
625
}
625
626
@@ -629,18 +630,23 @@ public void shutdownUsingServerStartPolicy() throws Exception {
629
630
* @throws Exception
630
631
*/
631
632
public void restartUsingServerStartPolicy () throws Exception {
632
- String cmd =
633
- "kubectl patch domain "
634
- + domainUid
635
- + " -n "
636
- + domainNS
637
- + " -p '{\" spec\" :{\" serverStartPolicy\" :\" IF_NEEDED\" }}' --type merge" ;
638
- ExecResult result = TestUtils .exec (cmd );
639
- String output = result .stdout ().trim ();
640
- logger .info ("command to restart domain " + cmd + " \n returned " + output );
633
+ String patchStr = "'{\" spec\" :{\" serverStartPolicy\" :\" IF_NEEDED\" }}'" ;
634
+ TestUtils .kubectlpatch (domainUid , domainNS , patchStr );
641
635
verifyPodsCreated ();
642
636
verifyServersReady ();
643
637
}
638
+
639
+ /**
640
+ * add precreateService true in domain.yaml
641
+ *
642
+ * @throws Exception
643
+ */
644
+ public void enablePrecreateService () throws Exception {
645
+ String patchStr = "'{\" spec\" :{\" serverService\" :{\" precreateService\" :true}}'" ;
646
+ TestUtils .kubectlpatch (domainUid , domainNS , patchStr );
647
+ verifyServicesCreated (true );
648
+ }
649
+
644
650
/**
645
651
* verify domain is deleted
646
652
*
@@ -1791,23 +1797,11 @@ public int getLoadBalancerWebPort() {
1791
1797
* @throws Exception
1792
1798
*/
1793
1799
public void shutdownManagedServerUsingServerStartPolicy (String msName ) throws Exception {
1794
- String cmd =
1795
- "kubectl patch domain "
1796
- + domainUid
1797
- + " -n "
1798
- + domainNS
1799
- + " -p '{\" spec\" :{\" managedServers\" :[{\" serverName\" :\" "
1800
+ logger .info ("About to shutdown managed server <" + msName + ">" );
1801
+ String patchStr = "'{\" spec\" :{\" managedServers\" :[{\" serverName\" :\" "
1800
1802
+ msName
1801
- + "\" ,\" serverStartPolicy\" :\" NEVER\" }]}}' --type merge" ;
1802
-
1803
- logger .info ("command to shutdown managed server <" + msName + "> is: " + cmd );
1804
-
1805
- ExecResult result = ExecCommand .exec (cmd );
1806
- if (result .exitValue () != 0 ) {
1807
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1808
- }
1809
- String output = result .stdout ().trim ();
1810
- logger .info ("output from shutting down managed server:\n " + output );
1803
+ + "\" ,\" serverStartPolicy\" :\" NEVER\" }]}}' " ;
1804
+ TestUtils .kubectlpatch (domainUid , domainNS , patchStr );
1811
1805
1812
1806
TestUtils .checkPodDeleted (domainUid + "-" + msName , domainNS );
1813
1807
}
@@ -1818,24 +1812,12 @@ public void shutdownManagedServerUsingServerStartPolicy(String msName) throws Ex
1818
1812
* @throws Exception
1819
1813
*/
1820
1814
public void restartManagedServerUsingServerStartPolicy (String msName ) throws Exception {
1821
- String cmd =
1822
- "kubectl patch domain "
1823
- + domainUid
1824
- + " -n "
1825
- + domainNS
1826
- + " -p '{\" spec\" :{\" managedServers\" :[{\" serverName\" :\" "
1815
+ logger .info ("About to restart managed server <" + msName + "> " );
1816
+ String patchStr = "'{\" spec\" :{\" managedServers\" :[{\" serverName\" :\" "
1827
1817
+ msName
1828
- + "\" ,\" serverStartPolicy\" :\" IF_NEEDED\" }]}}' --type merge" ;
1829
-
1830
- logger .info ("command to restart managed server <" + msName + "> is: " + cmd );
1831
-
1832
- ExecResult result = ExecCommand .exec (cmd );
1833
- if (result .exitValue () != 0 ) {
1834
- throw new Exception ("FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1835
- }
1836
- String output = result .stdout ().trim ();
1837
- logger .info ("output from restarting managed server:\n " + output );
1838
-
1818
+ + "\" ,\" serverStartPolicy\" :\" IF_NEEDED\" }]}}'" ;
1819
+ TestUtils .kubectlpatch (domainUid , domainNS , patchStr );
1820
+
1839
1821
TestUtils .checkPodCreated (domainUid + "-" + msName , domainNS );
1840
1822
TestUtils .checkPodReady (domainUid + "-" + msName , domainNS );
1841
1823
}
0 commit comments