Skip to content

Commit 18a2841

Browse files
committed
changes to use ExecCommand and ExecResult
1 parent c400eca commit 18a2841

File tree

10 files changed

+298
-290
lines changed

10 files changed

+298
-290
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.nio.file.Paths;
99
import java.util.Properties;
1010
import java.util.logging.Logger;
11+
import oracle.kubernetes.operator.utils.ExecCommand;
12+
import oracle.kubernetes.operator.utils.ExecResult;
1113
import oracle.kubernetes.operator.utils.TestUtils;
1214

1315
/**
@@ -84,9 +86,10 @@ public static void initialize(String appPropsFile) throws Exception {
8486
if (System.getenv("WERCKER") == null && System.getenv("JENKINS") == null) {
8587
logger.info("Creating PVROOT " + pvRoot);
8688
Files.createDirectories(Paths.get(pvRoot));
87-
String output = TestUtils.executeCommand("chmod 777 " + pvRoot);
88-
if (!output.trim().equals("")) {
89-
throw new RuntimeException("FAILURE: Couldn't change permissions for PVROOT " + output);
89+
ExecResult result = ExecCommand.exec("chmod 777 " + pvRoot);
90+
if (result.exitValue() != 0) {
91+
throw new RuntimeException(
92+
"FAILURE: Couldn't change permissions for PVROOT " + result.stderr());
9093
}
9194
}
9295

@@ -135,10 +138,10 @@ public static String getLeaseId() {
135138
return leaseId;
136139
}
137140

138-
protected void logTestBegin() throws Exception {
141+
protected void logTestBegin(String testName) throws Exception {
139142
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
140-
logger.info("BEGIN");
141-
// renew lease at the begining for every test method, leaseId is set only for Wercker
143+
logger.info("BEGIN " + testName);
144+
// renew lease at the beginning for every test method, leaseId is set only for Wercker
142145
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
143146
}
144147
}

integration-tests/src/test/java/oracle/kubernetes/operator/ITSingleDomain.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import java.util.Properties;
88
import oracle.kubernetes.operator.utils.Domain;
9+
import oracle.kubernetes.operator.utils.ExecCommand;
10+
import oracle.kubernetes.operator.utils.ExecResult;
911
import oracle.kubernetes.operator.utils.Operator;
1012
import oracle.kubernetes.operator.utils.TestUtils;
1113
import org.junit.AfterClass;
@@ -86,15 +88,18 @@ public static void staticUnPrepare() throws Exception {
8688
if (domain != null) domain.destroy();
8789
if (operator != null) operator.destroy();
8890
} finally {
89-
// TestUtils.cleanupAll(getProjectRoot());
90-
TestUtils.executeCommandStrArray(
91+
String cmd =
9192
"export RESULT_ROOT="
9293
+ getResultRoot()
9394
+ " export PV_ROOT="
9495
+ getPvRoot()
9596
+ " && "
9697
+ getProjectRoot()
97-
+ "/src/integration-tests/bash/cleanup.sh");
98+
+ "/src/integration-tests/bash/cleanup.sh";
99+
ExecResult result = ExecCommand.exec(cmd);
100+
if (result.exitValue() != 0) {
101+
logger.info("FAILED: command to call cleanup script failed " + cmd + result.stderr());
102+
}
98103
}
99104
logger.info("SUCCESS");
100105
}
@@ -106,7 +111,7 @@ public static void staticUnPrepare() throws Exception {
106111
*/
107112
@Test
108113
public void testAdminServerExternalService() throws Exception {
109-
logTestBegin();
114+
logTestBegin("testAdminServerExternalService");
110115
domain.verifyAdminServerExternalService(getUsername(), getPassword());
111116
logger.info("SUCCESS");
112117
}
@@ -118,7 +123,7 @@ public void testAdminServerExternalService() throws Exception {
118123
*/
119124
@Test
120125
public void testAdminT3Channel() throws Exception {
121-
logTestBegin();
126+
logTestBegin("testAdminT3Channel");
122127
// check if the property is set to true
123128
Boolean exposeAdmint3Channel = new Boolean(domainProps.getProperty("exposeAdminT3Channel"));
124129

@@ -143,7 +148,7 @@ public void testAdminT3Channel() throws Exception {
143148
*/
144149
@Test
145150
public void testDomainLifecyle() throws Exception {
146-
logTestBegin();
151+
logTestBegin("testDomainLifecyle");
147152
domain.destroy();
148153
domain.create();
149154
operator.verifyExternalRESTService();
@@ -162,7 +167,7 @@ public void testDomainLifecyle() throws Exception {
162167
*/
163168
@Test
164169
public void testClusterScaling() throws Exception {
165-
logTestBegin();
170+
logTestBegin("testClusterScaling");
166171
String managedServerNameBase = domainProps.getProperty("managedServerNameBase");
167172
int replicas = 3;
168173
String podName = domainUid + "-" + managedServerNameBase + replicas;
@@ -219,7 +224,7 @@ public void testClusterScaling() throws Exception {
219224
*/
220225
@Test
221226
public void testOperatorLifecycle() throws Exception {
222-
logTestBegin();
227+
logTestBegin("testOperatorLifecycle");
223228
operator.destroy();
224229
operator.create();
225230
operator.verifyExternalRESTService();

0 commit comments

Comments
 (0)