|
6 | 6 | import java.util.Map; |
7 | 7 | import static java.util.Arrays.asList; |
8 | 8 |
|
| 9 | +import io.kubernetes.client.models.ExtensionsV1beta1Deployment; |
9 | 10 | import io.kubernetes.client.models.V1beta1ClusterRole; |
10 | 11 | import io.kubernetes.client.models.V1beta1ClusterRoleBinding; |
11 | 12 | import io.kubernetes.client.models.V1ConfigMap; |
|
14 | 15 | import io.kubernetes.client.models.V1PersistentVolumeClaim; |
15 | 16 | import io.kubernetes.client.models.V1Service; |
16 | 17 | import io.kubernetes.client.models.V1ServiceAccount; |
| 18 | +import static oracle.kubernetes.operator.create.CreateDomainInputs.readInputsYamlFile; |
17 | 19 | import static oracle.kubernetes.operator.create.KubernetesArtifactUtils.*; |
18 | | -import static oracle.kubernetes.operator.create.YamlUtils.*; |
| 20 | +import static oracle.kubernetes.operator.create.YamlUtils.yamlEqualTo; |
19 | 21 | import oracle.kubernetes.weblogic.domain.v1.Domain; |
20 | 22 | import static org.hamcrest.MatcherAssert.assertThat; |
21 | 23 | import static org.hamcrest.Matchers.*; |
22 | 24 | import org.junit.AfterClass; |
23 | 25 | import org.junit.Test; |
24 | 26 |
|
25 | 27 | /** |
26 | | - * Tests that the all artifacts in the yaml files that create-domain-operator.sh |
| 28 | + * Tests that the all artifacts in the yaml files that create-weblogic-domain.sh |
27 | 29 | * creates are correct when the admin node port is disabled, the t3 channel is disabled, |
28 | 30 | * there is no image pull secret, and production mode is disabled. |
29 | 31 | */ |
@@ -84,8 +86,10 @@ public static void tearDown() throws Exception { |
84 | 86 | } |
85 | 87 |
|
86 | 88 | @Test |
87 | | - public void generatedCorrect_weblogicDomainInputsYaml() { |
88 | | - // TBD |
| 89 | + public void generatedCorrect_weblogicDomainInputsYaml() throws Exception { |
| 90 | + assertThat( |
| 91 | + readInputsYamlFile(generatedFiles.getDomainFiles().getCreateWeblogicDomainInputsYamlPath()), |
| 92 | + yamlEqualTo(readInputsYamlFile(generatedFiles.getInputsYamlPath()))); |
89 | 93 | } |
90 | 94 |
|
91 | 95 | @Test |
@@ -410,80 +414,80 @@ protected V1ServiceAccount getExpectedTraefikServiceAccount() { |
410 | 414 | .putLabelsItem("weblogic.clusterName", getClusterNameLC())); |
411 | 415 | } |
412 | 416 |
|
413 | | -/* |
414 | 417 | @Test |
415 | 418 | public void generatesCorrect_traefikDeployment() throws Exception { |
416 | | -//System.out.println("MOREAUT_DEBUG traefik deployment =\n" + newYaml().dump(generatedFiles.getTraefikYaml().getTraefikDeployment())); |
417 | | -
|
418 | | -// |
419 | | -kind: Deployment |
420 | | -apiVersion: extensions/v1beta1 |
421 | | -metadata: |
422 | | - name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
423 | | - namespace: %NAMESPACE% |
424 | | - labels: |
425 | | - app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
426 | | - weblogic.domainUID: %DOMAIN_UID% |
427 | | - weblogic.clusterName: %CLUSTER_NAME_LC% |
428 | | -spec: |
429 | | - replicas: 1 |
430 | | - selector: |
431 | | - matchLabels: |
432 | | - app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
433 | | - template: |
434 | | - metadata: |
435 | | - labels: |
436 | | - app: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
437 | | - weblogic.domainUID: %DOMAIN_UID% |
438 | | - weblogic.clusterName: %CLUSTER_NAME_LC% |
439 | | - spec: |
440 | | - serviceAccountName: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
441 | | - terminationGracePeriodSeconds: 60 |
442 | | - containers: |
443 | | - - image: traefik:1.4.5 |
444 | | - name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
445 | | - resources: |
446 | | - requests: |
447 | | - cpu: "100m" |
448 | | - memory: "20Mi" |
449 | | - limits: |
450 | | - cpu: "100m" |
451 | | - memory: "30Mi" |
452 | | - readinessProbe: |
453 | | - tcpSocket: |
454 | | - port: 80 |
455 | | - failureThreshold: 1 |
456 | | - initialDelaySeconds: 10 |
457 | | - periodSeconds: 10 |
458 | | - successThreshold: 1 |
459 | | - timeoutSeconds: 2 |
460 | | - livenessProbe: |
461 | | - tcpSocket: |
462 | | - port: 80 |
463 | | - failureThreshold: 3 |
464 | | - initialDelaySeconds: 10 |
465 | | - periodSeconds: 10 |
466 | | - successThreshold: 1 |
467 | | - timeoutSeconds: 2 |
468 | | - volumeMounts: |
469 | | - - mountPath: /config |
470 | | - name: config |
471 | | - ports: |
472 | | - - name: http |
473 | | - containerPort: 80 |
474 | | - protocol: TCP |
475 | | - - name: dash |
476 | | - containerPort: 8080 |
477 | | - protocol: TCP |
478 | | - args: |
479 | | - - --configfile=/config/traefik.toml |
480 | | - volumes: |
481 | | - - name: config |
482 | | - configMap: |
483 | | - name: %DOMAIN_UID%-%CLUSTER_NAME_LC%-traefik |
484 | | -// |
485 | | - } |
486 | | -*/ |
| 419 | + assertThat( |
| 420 | + getActualTraefikDeployment(), |
| 421 | + yamlEqualTo(getExpectedTraefikDeployment())); |
| 422 | + } |
| 423 | + |
| 424 | + protected ExtensionsV1beta1Deployment getActualTraefikDeployment() { |
| 425 | + return getTraefikYaml().getTraefikDeployment(); |
| 426 | + } |
| 427 | + |
| 428 | + protected ExtensionsV1beta1Deployment getExpectedTraefikDeployment() { |
| 429 | + return |
| 430 | + newDeployment() |
| 431 | + .apiVersion(API_VERSION_EXTENSIONS_V1BETA1) // TBD - why is traefik using this older version? |
| 432 | + .metadata(newObjectMeta() |
| 433 | + .name(getTraefikScope()) |
| 434 | + .namespace(getInputs().getNamespace()) |
| 435 | + .putLabelsItem("app", getTraefikScope()) |
| 436 | + .putLabelsItem("weblogic.domainUID", getInputs().getDomainUid()) |
| 437 | + .putLabelsItem("weblogic.clusterName", getClusterNameLC())) |
| 438 | + .spec(newDeploymentSpec() |
| 439 | + .replicas(1) |
| 440 | + .selector(newLabelSelector() |
| 441 | + .putMatchLabelsItem("app", getTraefikScope())) |
| 442 | + .template(newPodTemplateSpec() |
| 443 | + .metadata(newObjectMeta() |
| 444 | + .putLabelsItem("app", getTraefikScope()) |
| 445 | + .putLabelsItem("weblogic.domainUID", getInputs().getDomainUid()) |
| 446 | + .putLabelsItem("weblogic.clusterName", getClusterNameLC())) |
| 447 | + .spec(newPodSpec() |
| 448 | + .serviceAccountName(getTraefikScope()) |
| 449 | + .terminationGracePeriodSeconds(60L) |
| 450 | + .addContainersItem(newContainer() |
| 451 | + .name(getTraefikScope()) |
| 452 | + .image("traefik:1.4.5") |
| 453 | + .resources(newResourceRequirements() |
| 454 | + .putRequestsItem("cpu", "100m") |
| 455 | + .putRequestsItem("memory", "20Mi") |
| 456 | + .putLimitsItem("cpu", "100m") |
| 457 | + .putLimitsItem("memory", "30Mi")) |
| 458 | + .readinessProbe(newProbe() |
| 459 | + .tcpSocket(newTCPSocketAction() |
| 460 | + .port(newIntOrString(80))) |
| 461 | + .failureThreshold(1) |
| 462 | + .initialDelaySeconds(10) |
| 463 | + .periodSeconds(10) |
| 464 | + .successThreshold(1) |
| 465 | + .timeoutSeconds(2)) |
| 466 | + .livenessProbe(newProbe() |
| 467 | + .tcpSocket(newTCPSocketAction() |
| 468 | + .port(newIntOrString(80))) |
| 469 | + .failureThreshold(3) |
| 470 | + .initialDelaySeconds(10) |
| 471 | + .periodSeconds(10) |
| 472 | + .successThreshold(1) |
| 473 | + .timeoutSeconds(2)) |
| 474 | + .addVolumeMountsItem(newVolumeMount() |
| 475 | + .name("config") |
| 476 | + .mountPath("/config")) |
| 477 | + .addPortsItem(newContainerPort() |
| 478 | + .name("http") |
| 479 | + .containerPort(80) |
| 480 | + .protocol("TCP")) |
| 481 | + .addPortsItem(newContainerPort() |
| 482 | + .name("dash") |
| 483 | + .containerPort(8080) |
| 484 | + .protocol("TCP")) |
| 485 | + .addArgsItem("--configfile=/config/traefik.toml")) |
| 486 | + .addVolumesItem(newVolume() |
| 487 | + .name("config") |
| 488 | + .configMap(newConfigMapVolumeSource() |
| 489 | + .name(getTraefikScope())))))); |
| 490 | + } |
487 | 491 |
|
488 | 492 | @Test |
489 | 493 | public void generatesCorrect_traefikConfigMap() throws Exception { |
|
0 commit comments