diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 4d10fe860d2..7fd74b700e2 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -1,4 +1,4 @@ - @@ -266,6 +266,28 @@ + + crio-pipeline + + false + + **/ItConfigDistributionStrategy, + **/ItIstioDomainInPV, + **/ItIstioMiiDomain, + **/ItMiiSampleWlsAux, + **/ItMiiServiceMigration, + **/ItMiiDomain, + **/ItMiiDynamicUpdate, + **/ItMiiSampleWlsMain, + **/ItMonitoringExporter, + **/ItPodsShutdownOption, + **/ItProductionSecureMode, + **/ItWlsSamples, + **/ItSessionMigration, + **/ItSystemResOverrides + + + fmw-image-cert diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLogging.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLogging.java index a8959e38e95..21b03becfa1 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLogging.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLogging.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes; @@ -39,8 +39,16 @@ import static oracle.weblogic.kubernetes.TestConstants.COPY_WLS_LOGGING_EXPORTER_FILE_NAME; import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION; import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HOST; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTPS_PORT; import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTP_PORT; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_IMAGE; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_NAME; +import static oracle.weblogic.kubernetes.TestConstants.ELKSTACK_NAMESPACE; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_IMAGE; import static oracle.weblogic.kubernetes.TestConstants.KIBANA_INDEX_KEY; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_NAME; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_PORT; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_TYPE; import static oracle.weblogic.kubernetes.TestConstants.LOGSTASH_INDEX_KEY; import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME; import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME; @@ -52,7 +60,6 @@ import static oracle.weblogic.kubernetes.actions.ActionConstants.SNAKE_DOWNLOADED_FILENAME; import static oracle.weblogic.kubernetes.actions.ActionConstants.WLE_DOWNLOAD_FILENAME_DEFAULT; import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR; -import static oracle.weblogic.kubernetes.actions.TestActions.deleteDomainCustomResource; import static oracle.weblogic.kubernetes.actions.TestActions.execCommand; import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists; @@ -202,24 +209,33 @@ public static void init(@Namespaces(2) List namespaces) { */ @AfterAll void tearDown() { - // uninstall ELK Stack - if (elasticsearchParams != null) { + if (System.getenv("SKIP_CLEANUP") == null + || (System.getenv("SKIP_CLEANUP") != null + && System.getenv("SKIP_CLEANUP").equalsIgnoreCase("false"))) { + + // uninstall ELK Stack + elasticsearchParams = new LoggingExporterParams() + .elasticsearchName(ELASTICSEARCH_NAME) + .elasticsearchImage(ELASTICSEARCH_IMAGE) + .elasticsearchHttpPort(ELASTICSEARCH_HTTP_PORT) + .elasticsearchHttpsPort(ELASTICSEARCH_HTTPS_PORT) + .loggingExporterNamespace(ELKSTACK_NAMESPACE); + + kibanaParams = new LoggingExporterParams() + .kibanaName(KIBANA_NAME) + .kibanaImage(KIBANA_IMAGE) + .kibanaType(KIBANA_TYPE) + .loggingExporterNamespace(ELKSTACK_NAMESPACE) + .kibanaContainerPort(KIBANA_PORT); + logger.info("Uninstall Elasticsearch pod"); assertDoesNotThrow(() -> uninstallAndVerifyElasticsearch(elasticsearchParams), "uninstallAndVerifyElasticsearch failed with ApiException"); - } - if (kibanaParams != null) { - logger.info("Uninstall Elasticsearch pod"); + logger.info("Uninstall Kibana pod"); assertDoesNotThrow(() -> uninstallAndVerifyKibana(kibanaParams), "uninstallAndVerifyKibana failed with ApiException"); } - - // delete domain custom resource - logger.info("Delete domain custom resource in namespace {0}", domainNamespace); - assertDoesNotThrow(() -> deleteDomainCustomResource(domainUid, domainNamespace), - "deleteDomainCustomResource failed with ApiException"); - logger.info("Deleted Domain Custom Resource " + domainUid + " from " + domainNamespace); } /** diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLoggingFluentd.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLoggingFluentd.java index 38a610b15ab..a845d350113 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLoggingFluentd.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItElasticLoggingFluentd.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes; @@ -53,10 +53,18 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION; import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HOST; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTPS_PORT; import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTP_PORT; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_IMAGE; +import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_NAME; +import static oracle.weblogic.kubernetes.TestConstants.ELKSTACK_NAMESPACE; import static oracle.weblogic.kubernetes.TestConstants.FLUENTD_IMAGE; import static oracle.weblogic.kubernetes.TestConstants.FLUENTD_INDEX_KEY; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_IMAGE; import static oracle.weblogic.kubernetes.TestConstants.KIBANA_INDEX_KEY; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_NAME; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_PORT; +import static oracle.weblogic.kubernetes.TestConstants.KIBANA_TYPE; import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME; import static oracle.weblogic.kubernetes.TestConstants.OCIR_SECRET_NAME; import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME; @@ -203,18 +211,29 @@ void tearDown() { if (System.getenv("SKIP_CLEANUP") == null || (System.getenv("SKIP_CLEANUP") != null && System.getenv("SKIP_CLEANUP").equalsIgnoreCase("false"))) { + + elasticsearchParams = new LoggingExporterParams() + .elasticsearchName(ELASTICSEARCH_NAME) + .elasticsearchImage(ELASTICSEARCH_IMAGE) + .elasticsearchHttpPort(ELASTICSEARCH_HTTP_PORT) + .elasticsearchHttpsPort(ELASTICSEARCH_HTTPS_PORT) + .loggingExporterNamespace(ELKSTACK_NAMESPACE); + + kibanaParams = new LoggingExporterParams() + .kibanaName(KIBANA_NAME) + .kibanaImage(KIBANA_IMAGE) + .kibanaType(KIBANA_TYPE) + .loggingExporterNamespace(ELKSTACK_NAMESPACE) + .kibanaContainerPort(KIBANA_PORT); + // uninstall ELK Stack - if (elasticsearchParams != null) { - logger.info("Uninstall Elasticsearch pod"); - assertDoesNotThrow(() -> uninstallAndVerifyElasticsearch(elasticsearchParams), - "uninstallAndVerifyElasticsearch failed with ApiException"); - } - - if (kibanaParams != null) { - logger.info("Uninstall Elasticsearch pod"); - assertDoesNotThrow(() -> uninstallAndVerifyKibana(kibanaParams), - "uninstallAndVerifyKibana failed with ApiException"); - } + logger.info("Uninstall Elasticsearch pod"); + assertDoesNotThrow(() -> uninstallAndVerifyElasticsearch(elasticsearchParams), + "uninstallAndVerifyElasticsearch failed with ApiException"); + + logger.info("Uninstall Kibana pod"); + assertDoesNotThrow(() -> uninstallAndVerifyKibana(kibanaParams), + "uninstallAndVerifyKibana failed with ApiException"); } } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java index 4dcba03c15f..500ec660508 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIntrospectVersion.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes; @@ -75,6 +75,8 @@ import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR; import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR; +import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolume; +import static oracle.weblogic.kubernetes.actions.TestActions.deletePersistentVolumeClaim; import static oracle.weblogic.kubernetes.actions.TestActions.deleteSecret; import static oracle.weblogic.kubernetes.actions.TestActions.dockerTag; import static oracle.weblogic.kubernetes.actions.TestActions.execCommand; @@ -90,6 +92,7 @@ import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource; import static oracle.weblogic.kubernetes.actions.impl.Pod.getPod; import static oracle.weblogic.kubernetes.assertions.TestAssertions.podStateNotChanged; +import static oracle.weblogic.kubernetes.assertions.TestAssertions.pvNotExists; import static oracle.weblogic.kubernetes.assertions.TestAssertions.verifyRollingRestartOccurred; import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyPodsNotRolled; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists; @@ -254,6 +257,21 @@ void testDomainIntrospectVersionNotRolling() { // create persistent volume and persistent volume claim for domain // these resources should be labeled with domainUid for cleanup after testing + // delete the PV first in case it exists + String labelSelector = String.format("weblogic.domainUID in (%s)", domainUid); + deletePersistentVolumeClaim(pvcName, introDomainNamespace); + deletePersistentVolume(pvName); + // wait until the pv is deleted + withStandardRetryPolicy + .conditionEvaluationListener( + condition -> logger.info("Waiting for persistent volume {0} deleted " + + "(elapsed time {1}ms, remaining time {2}ms)", + pvName, + condition.getElapsedTimeInMS(), + condition.getRemainingTimeInMS())) + .until(assertDoesNotThrow(() -> pvNotExists(pvName, labelSelector), + String.format("pvNotExists failed with ApiException when checking pv %s", pvName))); + createPV(pvName, domainUid, this.getClass().getSimpleName()); createPVC(pvName, pvcName, domainUid, introDomainNamespace); diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImageCluster.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImageCluster.java index e8073ffefaa..da1c9b76388 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImageCluster.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImageCluster.java @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Oracle and/or its affiliates. +// Copyright (c) 2021, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes; @@ -73,7 +73,7 @@ class ItMiiAuxiliaryImageCluster { private final String clusterName = "cluster-1"; private final int replicaCount = 2; private final int clusterIndex = 0; - private final String miiAuxiliaryImagePrefix = MII_AUXILIARY_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG; + private final String miiAuxiliaryImagePrefix = MII_AUXILIARY_IMAGE_NAME + "-cluster:" + MII_BASIC_IMAGE_TAG; private final String auxiliaryImageVolumeName = "auxiliaryImageVolumeCluster"; private final String auxiliaryImagePath = "/auxiliary"; private final String customDir = "customdir"; diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItWlsSamples.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItWlsSamples.java index ddad77201a0..79c4cf8d0bb 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItWlsSamples.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/ItWlsSamples.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes; @@ -32,9 +32,11 @@ import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT; import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT; import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET; +import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_IMAGES_REPO; import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION; import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST; import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO; +import static oracle.weblogic.kubernetes.TestConstants.OCIR_WEBLOGIC_IMAGE_TAG; import static oracle.weblogic.kubernetes.TestConstants.PV_ROOT; import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC; import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR; @@ -47,6 +49,7 @@ import static oracle.weblogic.kubernetes.assertions.TestAssertions.secretExists; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkClusterReplicaCountMatches; import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists; +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getDateAndTimeStamp; import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile; import static oracle.weblogic.kubernetes.utils.ImageUtils.createOcirRepoSecret; import static oracle.weblogic.kubernetes.utils.ImageUtils.createSecretForBaseImages; @@ -88,7 +91,7 @@ class ItWlsSamples { private static String domainNamespace = null; private static final String domainName = "domain1"; private static final String diiImageNameBase = "domain-home-in-image"; - private static final String diiImageTag = "12.2.1.4"; + private static final String diiImageTag = getDateAndTimeStamp(); private final int replicaCount = 2; private final String clusterName = "cluster-1"; private final String managedServerNameBase = "managed-server"; @@ -157,9 +160,7 @@ public static void initAll(@Namespaces(5) List namespaces) { void testSampleDomainInImage(String model) { String domainName = model.split(":")[1]; String script = model.split(":")[0]; - String imageName = (KIND_REPO != null - ? KIND_REPO + diiImageNameBase + "_" + script + ":" + diiImageTag - : diiImageNameBase + "_" + script + ":" + diiImageTag); + String imageName = DOMAIN_IMAGES_REPO + diiImageNameBase + "-" + script + ":" + diiImageTag; //copy the samples directory to a temporary location setupSample(); @@ -174,7 +175,7 @@ void testSampleDomainInImage(String model) { // update domainHomeImageBase with right values in create-domain-inputs.yaml assertDoesNotThrow(() -> { replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), - "domainHomeImageBase: container-registry.oracle.com/middleware/weblogic:" + diiImageTag, + "domainHomeImageBase: container-registry.oracle.com/middleware/weblogic:" + OCIR_WEBLOGIC_IMAGE_TAG, "domainHomeImageBase: " + WEBLOGIC_IMAGE_TO_USE_IN_SPEC); replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), "#image:", @@ -247,7 +248,7 @@ void testSampleDomainInPv(String model) { replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), "createDomainFilesDir: wlst", "createDomainFilesDir: " + script); replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), - "image: container-registry.oracle.com/middleware/weblogic:12.2.1.4", + "image: container-registry.oracle.com/middleware/weblogic:" + OCIR_WEBLOGIC_IMAGE_TAG, "image: " + WEBLOGIC_IMAGE_TO_USE_IN_SPEC); }); @@ -550,6 +551,10 @@ private void updateDomainInputsFile(String domainName, Path sampleBase) { "#t3PublicAddress:", "t3PublicAddress: " + K8S_NODEPORT_HOST); replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), "#imagePullSecretName:", "imagePullSecretName: " + BASE_IMAGES_REPO_SECRET); + if (KIND_REPO == null) { + replaceStringInFile(Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString(), + "imagePullPolicy: IfNotPresent", "imagePullPolicy: Always"); + } }); } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/WebLogicImageTool.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/WebLogicImageTool.java index 7aedf74ddab..ed97669f830 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/WebLogicImageTool.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/primitive/WebLogicImageTool.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes.actions.impl.primitive; @@ -75,7 +75,8 @@ public boolean updateImage() { defaultCommandParams() .command(buildiWitCommand()) .env(params.env()) - .redirect(params.redirect())) + .redirect(params.redirect()) + .verbose(true)) .execute(); } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java index d5386855dc8..e10245810cb 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/TestAssertions.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes.assertions; @@ -667,7 +667,7 @@ public static Callable isGrafanaReady(String namespace) { return Grafana.isReady(namespace); } - /* + /** * Check whether persistent volume with pvName exists. * * @param pvName persistent volume to check @@ -678,6 +678,17 @@ public static Callable pvExists(String pvName, String labelSelector) { return PersistentVolume.pvExists(pvName, labelSelector); } + /** + * Check whether persistent volume with pvName NOT exists. + * + * @param pvName persistent volume to check + * @param labelSelector String containing the labels the PV is decorated with + * @return true if the persistent volume exists, false otherwise + */ + public static Callable pvNotExists(String pvName, String labelSelector) { + return PersistentVolume.pvNotExists(pvName, labelSelector); + } + /** * Check whether persistent volume claims with pvcName exists in the specified namespace. * diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/PersistentVolume.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/PersistentVolume.java index b6e32a37a3e..2aedb4ff129 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/PersistentVolume.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/PersistentVolume.java @@ -1,4 +1,4 @@ -// Copyright (c) 2020, 2021, Oracle and/or its affiliates. +// Copyright (c) 2020, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes.assertions.impl; @@ -7,6 +7,7 @@ import java.util.List; import java.util.concurrent.Callable; +import io.kubernetes.client.openapi.ApiException; import io.kubernetes.client.openapi.models.V1PersistentVolume; import io.kubernetes.client.openapi.models.V1PersistentVolumeList; @@ -20,26 +21,45 @@ public class PersistentVolume { * @return true if the persistent volume exists, false otherwise */ public static Callable pvExists(String pvName, String labelSelector) { - return () -> { + return () -> doesPVExist(pvName, labelSelector); + } - List v1PersistentVolumes = new ArrayList<>(); + /** + * Check whether persistent volume with pvName NOT exists. + * + * @param pvName persistent volume to check + * @param labelSelector String containing the labels the PV is decorated with + * @return true if the persistent volume exists, false otherwise + */ + public static Callable pvNotExists(String pvName, String labelSelector) { + return () -> !doesPVExist(pvName, labelSelector); + } - V1PersistentVolumeList v1PersistentVolumeList = Kubernetes.listPersistentVolumes(labelSelector); - if (v1PersistentVolumeList != null) { - v1PersistentVolumes = v1PersistentVolumeList.getItems(); - } + /** + * Check whether persistent volume with pvName exists. + * + * @param pvName persistent volume to check + * @param labelSelector String containing the labels the PV is decorated with + * @return true if the persistent volume exists, false otherwise + */ + public static boolean doesPVExist(String pvName, String labelSelector) throws ApiException { + List v1PersistentVolumes = new ArrayList<>(); + + V1PersistentVolumeList v1PersistentVolumeList = Kubernetes.listPersistentVolumes(labelSelector); + if (v1PersistentVolumeList != null) { + v1PersistentVolumes = v1PersistentVolumeList.getItems(); + } - for (V1PersistentVolume v1PersistentVolume : v1PersistentVolumes) { - if (v1PersistentVolume.getMetadata() != null) { - if (v1PersistentVolume.getMetadata().getName() != null) { - if (v1PersistentVolume.getMetadata().getName().equals(pvName)) { - return true; - } + for (V1PersistentVolume v1PersistentVolume : v1PersistentVolumes) { + if (v1PersistentVolume.getMetadata() != null) { + if (v1PersistentVolume.getMetadata().getName() != null) { + if (v1PersistentVolume.getMetadata().getName().equals(pvName)) { + return true; } } } + } - return false; - }; + return false; } } diff --git a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java index b5259da20dd..cd42607c300 100644 --- a/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java +++ b/integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Oracle and/or its affiliates. +// Copyright (c) 2021, 2022, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package oracle.weblogic.kubernetes.utils; @@ -142,7 +142,7 @@ public static void cloneMonitoringExporter(String monitoringExporterSrcDir) { assertDoesNotThrow(() -> Files.createDirectories(monitoringTemp)); String monitoringExporterBranch = Optional.ofNullable(System.getenv("MONITORING_EXPORTER_BRANCH")) - .orElse("master"); + .orElse("main"); CommandParams params = Command.defaultCommandParams() .command("git clone -b " + monitoringExporterBranch