Skip to content

Commit 3ce6eef

Browse files
committed
the mysql db will be labeled with domain uid for auto clean
also added mysql in the cleanup.sh
1 parent a7f6270 commit 3ce6eef

File tree

3 files changed

+41
-80
lines changed

3 files changed

+41
-80
lines changed

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

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/** JUnit test class used for testing configuration override use cases. */
2828
public class ITSitConfig extends BaseTest {
2929

30-
private static String TESTSCRIPTDIR;
30+
private static String TEST_RES_DIR;
3131
private static String ADMINPODNAME;
3232
private static final String DOMAINUID = "customsitconfigdomain";
3333
private static final String ADMINPORT = "30710";
@@ -38,7 +38,11 @@ public class ITSitConfig extends BaseTest {
3838
private static String KUBE_EXEC_CMD;
3939
private static Domain domain;
4040
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+
4246
/**
4347
* This method gets called only once before any of the test methods are executed. It does the
4448
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -55,11 +59,17 @@ public static void staticPrepare() throws Exception {
5559
if (operator1 == null) {
5660
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
5761
}
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));
6070
// 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);
6373
Assert.assertEquals(0, result.exitValue());
6474

6575
fqdn = TestUtils.getHostName();
@@ -72,12 +82,12 @@ public static void staticPrepare() throws Exception {
7282
// copy the jmx test client file the administratioin server weblogic server pod
7383
ADMINPODNAME = domain.getDomainUid() + "-" + domain.getAdminServerName();
7484
TestUtils.copyFileViaCat(
75-
TESTSCRIPTDIR + "sitconfig/java/SitConfigTests.java",
85+
TEST_RES_DIR + "sitconfig/java/SitConfigTests.java",
7686
"SitConfigTests.java",
7787
ADMINPODNAME,
7888
domain.getDomainNS());
7989
TestUtils.copyFileViaCat(
80-
TESTSCRIPTDIR + "sitconfig/scripts/runSitConfigTests.sh",
90+
TEST_RES_DIR + "sitconfig/scripts/runSitConfigTests.sh",
8191
"runSitConfigTests.sh",
8292
ADMINPODNAME,
8393
domain.getDomainNS());
@@ -97,7 +107,7 @@ public static void staticUnPrepare() throws Exception {
97107
destroySitConfigDomain();
98108
tearDown();
99109
ExecResult result =
100-
TestUtils.exec("kubectl delete -f " + TESTSCRIPTDIR + "/mysql/mysql-dbservices.yml");
110+
TestUtils.exec("kubectl delete -f " + mysqlYamlFile);
101111
}
102112
}
103113

@@ -242,11 +252,11 @@ public void testCustomSitConfigOverridesForWldf() throws Exception {
242252
* @throws Exception - if it cannot create the domain
243253
*/
244254
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";
246256
// load input yaml to map and add configOverrides
247257
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
248258
domainMap.put("configOverrides", "sitconfigcm");
249-
domainMap.put("configOverridesFile", sitconfigDir);
259+
domainMap.put("configOverridesFile", configOverrideDir);
250260
domainMap.put("domainUID", DOMAINUID);
251261
domainMap.put("adminNodePort", new Integer(ADMINPORT));
252262
domainMap.put("t3ChannelPort", new Integer(T3CHANNELPORT));
@@ -279,9 +289,8 @@ private static void destroySitConfigDomain() throws Exception {
279289
* @throws IOException
280290
*/
281291
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;
285294
String files[] = {
286295
"config.xml",
287296
"jdbc-JdbcTestDataSource-0.xml",
@@ -301,6 +310,23 @@ private static void copySitConfigFiles() throws IOException {
301310
}
302311
}
303312

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+
304330
/**
305331
* Verifies the test run result doesn't contain any errors and exit status is 0
306332
*

integration-tests/src/test/resources/mysql/mysql-dbservices.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/integration-tests/bash/cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ deleteWithLabels
342342
# arg3 - keywords in deletable artificats
343343

344344
echo @@ Starting genericDelete
345-
genericDelete "all,cm,pvc,roles,rolebindings,serviceaccount,secrets,ingress" "crd,pv,ns,clusterroles,clusterrolebindings" "logstash|kibana|elastisearch|weblogic|elk|domain|traefik|voyager|apache-webtier"
345+
genericDelete "all,cm,pvc,roles,rolebindings,serviceaccount,secrets,ingress" "crd,pv,ns,clusterroles,clusterrolebindings" "logstash|kibana|elastisearch|weblogic|elk|domain|traefik|voyager|apache-webtier|mysql"
346346
SUCCESS="$?"
347347

348348
if [ "${DELETE_FILES:-true}" = "true" ]; then

0 commit comments

Comments
 (0)