27
27
/** JUnit test class used for testing configuration override use cases. */
28
28
public class ITSitConfig extends BaseTest {
29
29
30
- private static String TESTSCRIPTDIR ;
30
+ private static String TEST_RES_DIR ;
31
31
private static String ADMINPODNAME ;
32
32
private static final String DOMAINUID = "customsitconfigdomain" ;
33
33
private static final String ADMINPORT = "30710" ;
@@ -38,7 +38,11 @@ public class ITSitConfig extends BaseTest {
38
38
private static String KUBE_EXEC_CMD ;
39
39
private static Domain domain ;
40
40
private static Operator operator1 ;
41
- private static String sitconfigDir = "" ;
41
+ private static String sitconfigTmpDir = "" ;
42
+ private static String mysqltmpDir = "" ;
43
+ private static String configOverrideDir = "" ;
44
+ private static String mysqlYamlFile = "" ;
45
+
42
46
/**
43
47
* This method gets called only once before any of the test methods are executed. It does the
44
48
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -55,11 +59,17 @@ public static void staticPrepare() throws Exception {
55
59
if (operator1 == null ) {
56
60
operator1 = TestUtils .createOperator (OPERATOR1_YAML );
57
61
}
58
- TESTSCRIPTDIR = BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/" ;
59
- sitconfigDir = BaseTest .getResultDir () + "/configoverridefiles" ;
62
+ TEST_RES_DIR = BaseTest .getProjectRoot () + "/integration-tests/src/test/resources/" ;
63
+ sitconfigTmpDir = BaseTest .getResultDir () + "/sitconfigtemp" ;
64
+ mysqltmpDir = sitconfigTmpDir + "/mysql" ;
65
+ configOverrideDir = sitconfigTmpDir + "/configoverridefiles" ;
66
+ mysqlYamlFile = mysqltmpDir + "/mysql-dbservices.yml" ;
67
+ Files .createDirectories (Paths .get (sitconfigTmpDir ));
68
+ Files .createDirectories (Paths .get (configOverrideDir ));
69
+ Files .createDirectories (Paths .get (mysqltmpDir ));
60
70
// Create the MySql db container
61
- ExecResult result =
62
- TestUtils .exec ("kubectl create -f " + TESTSCRIPTDIR + "/mysql/mysql-dbservices.yml" );
71
+ copyMySqlFile ();
72
+ ExecResult result = TestUtils .exec ("kubectl create -f " + mysqlYamlFile );
63
73
Assert .assertEquals (0 , result .exitValue ());
64
74
65
75
fqdn = TestUtils .getHostName ();
@@ -72,12 +82,12 @@ public static void staticPrepare() throws Exception {
72
82
// copy the jmx test client file the administratioin server weblogic server pod
73
83
ADMINPODNAME = domain .getDomainUid () + "-" + domain .getAdminServerName ();
74
84
TestUtils .copyFileViaCat (
75
- TESTSCRIPTDIR + "sitconfig/java/SitConfigTests.java" ,
85
+ TEST_RES_DIR + "sitconfig/java/SitConfigTests.java" ,
76
86
"SitConfigTests.java" ,
77
87
ADMINPODNAME ,
78
88
domain .getDomainNS ());
79
89
TestUtils .copyFileViaCat (
80
- TESTSCRIPTDIR + "sitconfig/scripts/runSitConfigTests.sh" ,
90
+ TEST_RES_DIR + "sitconfig/scripts/runSitConfigTests.sh" ,
81
91
"runSitConfigTests.sh" ,
82
92
ADMINPODNAME ,
83
93
domain .getDomainNS ());
@@ -97,7 +107,7 @@ public static void staticUnPrepare() throws Exception {
97
107
destroySitConfigDomain ();
98
108
tearDown ();
99
109
ExecResult result =
100
- TestUtils .exec ("kubectl delete -f " + TESTSCRIPTDIR + "/mysql/mysql-dbservices.yml" );
110
+ TestUtils .exec ("kubectl delete -f " + mysqlYamlFile );
101
111
}
102
112
}
103
113
@@ -242,11 +252,11 @@ public void testCustomSitConfigOverridesForWldf() throws Exception {
242
252
* @throws Exception - if it cannot create the domain
243
253
*/
244
254
private static Domain createSitConfigDomain () throws Exception {
245
- String createDomainScript = TESTSCRIPTDIR + "/domain-home-on-pv/create-domain.py" ;
255
+ String createDomainScript = TEST_RES_DIR + "/domain-home-on-pv/create-domain.py" ;
246
256
// load input yaml to map and add configOverrides
247
257
Map <String , Object > domainMap = TestUtils .loadYaml (DOMAINONPV_WLST_YAML );
248
258
domainMap .put ("configOverrides" , "sitconfigcm" );
249
- domainMap .put ("configOverridesFile" , sitconfigDir );
259
+ domainMap .put ("configOverridesFile" , configOverrideDir );
250
260
domainMap .put ("domainUID" , DOMAINUID );
251
261
domainMap .put ("adminNodePort" , new Integer (ADMINPORT ));
252
262
domainMap .put ("t3ChannelPort" , new Integer (T3CHANNELPORT ));
@@ -279,9 +289,8 @@ private static void destroySitConfigDomain() throws Exception {
279
289
* @throws IOException
280
290
*/
281
291
private static void copySitConfigFiles () throws IOException {
282
- String src_dir = TESTSCRIPTDIR + "/sitconfig/configoverrides" ;
283
- Files .createDirectories (Paths .get (sitconfigDir ));
284
- String dst_dir = sitconfigDir ;
292
+ String src_dir = TEST_RES_DIR + "/sitconfig/configoverrides" ;
293
+ String dst_dir = configOverrideDir ;
285
294
String files [] = {
286
295
"config.xml" ,
287
296
"jdbc-JdbcTestDataSource-0.xml" ,
@@ -301,6 +310,23 @@ private static void copySitConfigFiles() throws IOException {
301
310
}
302
311
}
303
312
313
+ /**
314
+ * a util method to copy MySql yaml template file replacing the NAMESPACE and DOMAINUID
315
+ *
316
+ * @throws IOException
317
+ */
318
+ private static void copyMySqlFile () throws IOException {
319
+ Path src = Paths .get (TEST_RES_DIR + "/mysql/mysql-dbservices.ymlt" );
320
+ Path dst = Paths .get (mysqlYamlFile );
321
+ logger .log (Level .INFO , "Copying {0}" , src .toString ());
322
+ Charset charset = StandardCharsets .UTF_8 ;
323
+ String content = new String (Files .readAllBytes (src ), charset );
324
+ content = content .replaceAll ("@NAMESPACE@" , "default" );
325
+ content = content .replaceAll ("@DOMAIN_UID@" , DOMAINUID );
326
+ logger .log (Level .INFO , "to {0}" , dst .toString ());
327
+ Files .write (dst , content .getBytes (charset ));
328
+ }
329
+
304
330
/**
305
331
* Verifies the test run result doesn't contain any errors and exit status is 0
306
332
*
0 commit comments