new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItConfigDistributionStrategy.java
@Order(2)
  @Test
  @DisplayName("Test new overrides are applied as per the files in recreated configmap")
  public void testModifiedOverrideContent() {

    //store the pod creation timestamps
    storePodCreationTimestamps();

    //create first set of override
    List<Path> overrideFiles = new ArrayList<>();
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/config.xml"));
    overrideFiles.add(
        Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml"));
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/version.txt"));

    //create config override map
    createConfigMapFromFiles(overridecm, overrideFiles, domainNamespace);

    String introspectVersion = assertDoesNotThrow(() -> getNextIntrospectVersion(domainUid, domainNamespace));

    logger.info("patch the domain resource with overridesConfigMap and introspectVersion");
    String patchStr
        = "["
        + "{\"op\": \"add\", \"path\": \"/spec/configuration/overridesConfigMap\", \"value\": \"" + overridecm + "\"},"
        + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}"
        + "]";
    logger.info("Updating domain configuration using patch string: {0}", patchStr);
    V1Patch patch = new V1Patch(patchStr);
    assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
        "Failed to patch domain");

    verifyIntrospectorRuns();
    verifyPodsStateNotChanged();

    //wait until config is updated upto 5 minutes
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for server configuration to be updated"
                    + "(elapsed time {0} ms, remaining time {1} ms)",
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(configUpdated("9999999"));

    verifyConfigXMLOverride(true);
    verifyResourceJDBC0Override(true);

    logger.info("Deleting the old override configmap {0}", overridecm);
    deleteConfigMap(overridecm, domainNamespace);

    withStandardRetryPolicy.conditionEvaluationListener(
        condition -> logger.info("Waiting for configmap {0} to be deleted. Elapsed time{1}, remaining time {2}",
            overridecm, condition.getElapsedTimeInMS(), condition.getRemainingTimeInMS())).until(() -> {
              return listConfigMaps(domainNamespace).getItems().stream().noneMatch((cm)
                  -> (cm.getMetadata().getName().equals(overridecm)));
            });


    Path srcOverrideFile = Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/config1.xml");
    Path dstOverrideFile = Paths.get(WORK_DIR, "config.xml");
    assertDoesNotThrow(() -> Files.copy(srcOverrideFile, dstOverrideFile, StandardCopyOption.REPLACE_EXISTING));

    overrideFiles = new ArrayList<>();
    overrideFiles.add(dstOverrideFile);
    overrideFiles.add(
        Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml"));
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/version.txt"));

    //recreate config override map with new content
    logger.info("Recreating configmap {0} with new override files {1}", overridecm, overrideFiles);
    createConfigMapFromFiles(overridecm, overrideFiles, domainNamespace);

    introspectVersion = assertDoesNotThrow(() -> getNextIntrospectVersion(domainUid, domainNamespace));

    logger.info("patch the domain resource with overridesConfigMap and introspectVersion");
    patchStr
        = "["
        + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}"
        + "]";
    logger.info("Updating domain configuration using patch string: {0}", patchStr);
    patch = new V1Patch(patchStr);
    assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
        "Failed to patch domain");

    verifyIntrospectorRuns();
    verifyPodsStateNotChanged();

    //wait until config is updated upto 5 minutes
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for server configuration to be updated"
                    + "(elapsed time {0} ms, remaining time {1} ms)",
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(configUpdated("88888888"));

    verifyResourceJDBC0Override(true);

  }
/**
   * Test server configuration and JDBC datasource configurations are updated from previous overrides when underlying
   * override files are changed, configmap is recreated with new files with same name and introspector rerun.
   * a. Test sets the /spec/configuration/overridesConfigMap with configuration for config.xml and datasources.
   * b. Verifies after introspector runs the server configuration and JDBC datasource configurations are updated
   * as expected.
   * c. Recreate the same configmap with modified config.xml and recreates the map.
   * d. Reruns the introspector and verifies that the new configuration is applied as per the new config.xml override
   * file.
   */
Test server configuration and JDBC datasource configurations are updated from previous overrides when underlying
override files are changed, configmap is recreated with new files with same name and introspector rerun.
a. Test sets the /spec/configuration/overridesConfigMap with configuration for config.xml and datasources.
b. Verifies after introspector runs the server configuration and JDBC datasource configurations are updated
as expected.
c. Recreate the same configmap with modified config.xml and recreates the map.
d. Reruns the introspector and verifies that the new configuration is applied as per the new config.xml override
file.
Test server configuration and JDBC datasource configurations are updated from previous overrides when underlying override files are changed configmap is recreated with new files with same name and introspector rerun . a . Test sets the / spec / configuration / overridesConfigMap with configuration for config . xml and datasources . b . Verifies after introspector runs the server configuration and JDBC datasource configurations are updated as expected . c . Recreate the same configmap with modified config . xml and recreates the map . d . Reruns the introspector and verifies that the new configuration is applied as per the new config . xml override file .
@Order(2)
  @Test
  @DisplayName("Test new overrides are applied as per the files in recreated configmap")
  public void testModifiedOverrideContent() {
    storePodCreationTimestamps();
    List<Path> overrideFiles = new ArrayList<>();
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/config.xml"));
    overrideFiles.add(
        Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml"));
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/version.txt"));
    createConfigMapFromFiles(overridecm, overrideFiles, domainNamespace);
    String introspectVersion = assertDoesNotThrow(() -> getNextIntrospectVersion(domainUid, domainNamespace));
    logger.info("patch the domain resource with overridesConfigMap and introspectVersion");
    String patchStr
        = "["
        + "{\"op\": \"add\", \"path\": \"/spec/configuration/overridesConfigMap\", \"value\": \"" + overridecm + "\"},"
        + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}"
        + "]";
    logger.info("Updating domain configuration using patch string: {0}", patchStr);
    V1Patch patch = new V1Patch(patchStr);
    assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
        "Failed to patch domain");
    verifyIntrospectorRuns();
    verifyPodsStateNotChanged();
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for server configuration to be updated"
                    + "(elapsed time {0} ms, remaining time {1} ms)",
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(configUpdated("9999999"));
    verifyConfigXMLOverride(true);
    verifyResourceJDBC0Override(true);
    logger.info("Deleting the old override configmap {0}", overridecm);
    deleteConfigMap(overridecm, domainNamespace);
    withStandardRetryPolicy.conditionEvaluationListener(
        condition -> logger.info("Waiting for configmap {0} to be deleted. Elapsed time{1}, remaining time {2}",
            overridecm, condition.getElapsedTimeInMS(), condition.getRemainingTimeInMS())).until(() -> {
              return listConfigMaps(domainNamespace).getItems().stream().noneMatch((cm)
                  -> (cm.getMetadata().getName().equals(overridecm)));
            });
    Path srcOverrideFile = Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/config1.xml");
    Path dstOverrideFile = Paths.get(WORK_DIR, "config.xml");
    assertDoesNotThrow(() -> Files.copy(srcOverrideFile, dstOverrideFile, StandardCopyOption.REPLACE_EXISTING));
    overrideFiles = new ArrayList<>();
    overrideFiles.add(dstOverrideFile);
    overrideFiles.add(
        Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml"));
    overrideFiles.add(Paths.get(RESOURCE_DIR, "configfiles/configoverridesset1/version.txt"));
    logger.info("Recreating configmap {0} with new override files {1}", overridecm, overrideFiles);
    createConfigMapFromFiles(overridecm, overrideFiles, domainNamespace);
    introspectVersion = assertDoesNotThrow(() -> getNextIntrospectVersion(domainUid, domainNamespace));
    logger.info("patch the domain resource with overridesConfigMap and introspectVersion");
    patchStr
        = "["
        + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}"
        + "]";
    logger.info("Updating domain configuration using patch string: {0}", patchStr);
    patch = new V1Patch(patchStr);
    assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
        "Failed to patch domain");
    verifyIntrospectorRuns();
    verifyPodsStateNotChanged();
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for server configuration to be updated"
                    + "(elapsed time {0} ms, remaining time {1} ms)",
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(configUpdated("88888888"));
    verifyResourceJDBC0Override(true);
  }
@ Order ( 2 ) @ Test @ DisplayName ( "Test new overrides are applied as per the files in recreated configmap" ) public void testModifiedOverrideContent ( ) { storePodCreationTimestamps ( ) ; List < Path > overrideFiles = new ArrayList < > ( ) ; overrideFiles . add ( Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/config.xml" ) ) ; overrideFiles . add ( Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml" ) ) ; overrideFiles . add ( Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/version.txt" ) ) ; createConfigMapFromFiles ( overridecm , overrideFiles , domainNamespace ) ; String introspectVersion = assertDoesNotThrow ( ( ) -> getNextIntrospectVersion ( domainUid , domainNamespace ) ) ; logger . info ( "patch the domain resource with overridesConfigMap and introspectVersion" ) ; String patchStr = "[" + "{\"op\": \"add\", \"path\": \"/spec/configuration/overridesConfigMap\", \"value\": \"" + overridecm + "\"}," + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}" + "]" ; logger . info ( "Updating domain configuration using patch string: {0}" , patchStr ) ; V1Patch patch = new V1Patch ( patchStr ) ; assertTrue ( patchDomainCustomResource ( domainUid , domainNamespace , patch , V1Patch . PATCH_FORMAT_JSON_PATCH ) , "Failed to patch domain" ) ; verifyIntrospectorRuns ( ) ; verifyPodsStateNotChanged ( ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for server configuration to be updated" + "(elapsed time {0} ms, remaining time {1} ms)" , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( configUpdated ( "9999999" ) ) ; verifyConfigXMLOverride ( true ) ; verifyResourceJDBC0Override ( true ) ; logger . info ( "Deleting the old override configmap {0}" , overridecm ) ; deleteConfigMap ( overridecm , domainNamespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for configmap {0} to be deleted. Elapsed time{1}, remaining time {2}" , overridecm , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( ( ) -> { return listConfigMaps ( domainNamespace ) . getItems ( ) . stream ( ) . noneMatch ( ( cm ) -> ( cm . getMetadata ( ) . getName ( ) . equals ( overridecm ) ) ) ; } ) ; Path srcOverrideFile = Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/config1.xml" ) ; Path dstOverrideFile = Paths . get ( WORK_DIR , "config.xml" ) ; assertDoesNotThrow ( ( ) -> Files . copy ( srcOverrideFile , dstOverrideFile , StandardCopyOption . REPLACE_EXISTING ) ) ; overrideFiles = new ArrayList < > ( ) ; overrideFiles . add ( dstOverrideFile ) ; overrideFiles . add ( Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-0.xml" ) ) ; overrideFiles . add ( Paths . get ( RESOURCE_DIR , "configfiles/configoverridesset1/version.txt" ) ) ; logger . info ( "Recreating configmap {0} with new override files {1}" , overridecm , overrideFiles ) ; createConfigMapFromFiles ( overridecm , overrideFiles , domainNamespace ) ; introspectVersion = assertDoesNotThrow ( ( ) -> getNextIntrospectVersion ( domainUid , domainNamespace ) ) ; logger . info ( "patch the domain resource with overridesConfigMap and introspectVersion" ) ; patchStr = "[" + "{\"op\": \"replace\", \"path\": \"/spec/introspectVersion\", \"value\": \"" + introspectVersion + "\"}" + "]" ; logger . info ( "Updating domain configuration using patch string: {0}" , patchStr ) ; patch = new V1Patch ( patchStr ) ; assertTrue ( patchDomainCustomResource ( domainUid , domainNamespace , patch , V1Patch . PATCH_FORMAT_JSON_PATCH ) , "Failed to patch domain" ) ; verifyIntrospectorRuns ( ) ; verifyPodsStateNotChanged ( ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for server configuration to be updated" + "(elapsed time {0} ms, remaining time {1} ms)" , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( configUpdated ( "88888888" ) ) ; verifyResourceJDBC0Override ( true ) ; }
Test server configuration and JDBC datasource configurations are updated from previous overrides when underlying
 override files are changed, configmap is recreated with new files with same name and introspector rerun.
Test server configuration and JDBC datasource configurations are updated from previous overrides when underlying override files are changed configmap is recreated with new files with same name and introspector rerun .
//store the pod creation timestamps //create first set of override //create config override map //wait until config is updated upto 5 minutes //recreate config override map with new content //wait until config is updated upto 5 minutes