Skip to content

Commit 24b1cd9

Browse files
committed
Restructure the create domain/operator tests so they're easier to understand and modify
1 parent 7d14a9f commit 24b1cd9

23 files changed

+1414
-1284
lines changed

src/test/java/oracle/kubernetes/operator/create/CreateDomainGeneratedFilesBaseTest.java

Lines changed: 653 additions & 0 deletions
Large diffs are not rendered by default.

src/test/java/oracle/kubernetes/operator/create/CreateDomainGeneratedFilesOptionalFeaturesDisabledTest.java

Lines changed: 10 additions & 400 deletions
Large diffs are not rendered by default.

src/test/java/oracle/kubernetes/operator/create/CreateDomainGeneratedFilesOptionalFeaturesEnabledTest.java

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,53 @@
77
import static oracle.kubernetes.operator.create.KubernetesArtifactUtils.*;
88
import static oracle.kubernetes.operator.create.YamlUtils.*;
99
import oracle.kubernetes.weblogic.domain.v1.Domain;
10-
import static org.hamcrest.MatcherAssert.assertThat;
11-
import org.junit.AfterClass;
1210
import org.junit.BeforeClass;
13-
import org.junit.Test;
1411

1512
/**
1613
* Tests that the all artifacts in the yaml files that create-domain-operator.sh
1714
* creates are correct when the admin node port is enabled, the t3 channel is enabled,
18-
* there is no image pull secret, and production mode is enabled
15+
* there is an image pull secret, production mode is enabled, and the persistence type
16+
* is nfs
1917
*/
20-
public class CreateDomainGeneratedFilesOptionalFeaturesEnabledTest {
21-
22-
private static CreateDomainInputs inputs;
23-
private static GeneratedDomainYamlFiles generatedFiles;
18+
public class CreateDomainGeneratedFilesOptionalFeaturesEnabledTest extends CreateDomainGeneratedFilesBaseTest {
2419

2520
@BeforeClass
2621
public static void setup() throws Exception {
27-
inputs =
22+
setup(
2823
CreateDomainInputs.newInputs()
2924
.exposeAdminNodePort("true")
3025
.exposeAdminT3Channel("true")
3126
.imagePullSecretName("test-weblogic-image-pull-secret-name")
3227
.loadBalancer(LOAD_BALANCER_TRAEFIK)
3328
.persistenceType(PERSISTENCE_TYPE_NFS)
34-
.productionModeEnabled("true");
35-
generatedFiles = GeneratedDomainYamlFiles.generateDomainYamlFiles(inputs);
36-
}
37-
38-
@AfterClass
39-
public static void tearDown() throws Exception {
40-
if (generatedFiles != null) {
41-
generatedFiles.remove();
42-
}
29+
.productionModeEnabled("true")
30+
);
4331
}
4432

45-
@Test
46-
public void generatesCorrect_createWeblogicDomainYaml_createWeblogicDomainJob() throws Exception {
47-
V1Job want = generatedFiles.getCreateWeblogicDomainJobYaml().getExpectedBaseCreateWeblogicDomainJob();
48-
want.getSpec().getTemplate().getSpec().addImagePullSecretsItem(newLocalObjectReference()
49-
.name(inputs.getImagePullSecretName()));
50-
assertThat(
51-
generatedFiles.getCreateWeblogicDomainJobYaml().getCreateWeblogicDomainJob(),
52-
yamlEqualTo(want));
33+
@Override
34+
protected V1Job getExpectedCreateWeblogicDomainJob() {
35+
V1Job expected = super.getExpectedCreateWeblogicDomainJob();
36+
expected.getSpec().getTemplate().getSpec().addImagePullSecretsItem(newLocalObjectReference()
37+
.name(getInputs().getImagePullSecretName()));
38+
return expected;
5339
}
5440

55-
@Test
56-
public void generatesCorrect_domainCustomResourceYaml_domain() throws Exception {
57-
Domain want = generatedFiles.getDomainCustomResourceYaml().getBaseExpectedDomain();
58-
want.getSpec().withExportT3Channels(newStringList().addElement("T3Channel"));
41+
@Override
42+
protected Domain getExpectedDomain() {
43+
Domain expected = super.getExpectedDomain();
44+
expected.getSpec().withExportT3Channels(newStringList().addElement("T3Channel"));
5945
// there is only one server startup item in the base domain config - set its node port:
60-
want.getSpec().getServerStartup().get(0).withNodePort(Integer.parseInt(inputs.getAdminNodePort()));
61-
assertThat(
62-
generatedFiles.getDomainCustomResourceYaml().getDomain(),
63-
yamlEqualTo(want));
46+
expected.getSpec().getServerStartup().get(0).withNodePort(Integer.parseInt(getInputs().getAdminNodePort()));
47+
return expected;
6448
}
6549

66-
@Test
67-
public void generatesCorrect_weblogicDomainPersistentVolumeYaml_weblogicDomainPersistentVolume() throws Exception {
68-
V1PersistentVolume want =
69-
generatedFiles.getWeblogicDomainPersistentVolumeYaml().getExpectedBaseCreateWeblogicDomainPersistentVolume();
70-
want.getSpec()
50+
@Override
51+
protected V1PersistentVolume getExpectedWeblogicDomainPersistentVolume() {
52+
V1PersistentVolume expected = super.getExpectedWeblogicDomainPersistentVolume();
53+
expected.getSpec()
7154
.nfs(newNFSVolumeSource()
72-
.server(inputs.getNfsServer())
73-
.path(inputs.getPersistencePath()));
74-
assertThat(
75-
generatedFiles.getWeblogicDomainPersistentVolumeYaml().getWeblogicDomainPersistentVolume(),
76-
yamlEqualTo(want));
55+
.server(getInputs().getNfsServer())
56+
.path(getInputs().getPersistencePath()));
57+
return expected;
7758
}
7859
}

0 commit comments

Comments
 (0)