new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItCrossDomainTransaction.java
@Test
  @DisplayName("Check cross domain transaction works")
  @Slow
  @MustNotRunInParallel
  public void testCrossDomainTransaction() {

    //build application archive

    Path distDir = BuildApplication.buildApplication(Paths.get(APP_DIR, "txforward"), null, null,
        "build", domain1Namespace);
    logger.info("distDir is {0}", distDir.toString());
    assertTrue(Paths.get(distDir.toString(),
        "txforward.ear").toFile().exists(),
        "Application archive is not available");
    String appSource = distDir.toString() + "/txforward.ear";
    logger.info("Application is in {0}", appSource);

    // create admin credential secret for domain1
    logger.info("Create admin credential secret for domain1");
    String domain1AdminSecretName = domainUid1 + "-weblogic-credentials";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
        domain1AdminSecretName, domain1Namespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
        String.format("createSecret %s failed for %s", domain1AdminSecretName, domainUid1));

    // create admin credential secret for domain2
    logger.info("Create admin credential secret for domain2");
    String domain2AdminSecretName = domainUid2 + "-weblogic-credentials";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
        domain2AdminSecretName, domain2Namespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
        String.format("createSecret %s failed for %s", domain2AdminSecretName, domainUid2));

    logger.info("Creating image with model file and verify");
    String domain1Image = createImageAndVerify(
        WDT_IMAGE_NAME1, WDT_MODEL_FILE_DOMAIN1, appSource, WDT_MODEL_DOMAIN1_PROPS, PROPS_TEMP_DIR, domainUid1);
    logger.info("Created {0} image", domain1Image);

    // docker login and push image to docker registry if necessary
    dockerLoginAndPushImageToRegistry(domain1Image);

    logger.info("Creating image with model file and verify");
    String domain2Image = createImageAndVerify(
        WDT_IMAGE_NAME2, WDT_MODEL_FILE_DOMAIN2, appSource, WDT_MODEL_DOMAIN2_PROPS, PROPS_TEMP_DIR, domainUid2);
    logger.info("Created {0} image", domain2Image);

    // docker login and push image to docker registry if necessary
    dockerLoginAndPushImageToRegistry(domain2Image);

    //create domain1
    createDomain(domainUid1, domain1Namespace, domain1AdminSecretName, domain1Image);
    //create domain2
    createDomain(domainUid2, domain2Namespace, domain2AdminSecretName, domain2Image);

    logger.info("Getting admin server external service node port");
    int adminServiceNodePort = assertDoesNotThrow(
        () -> getServiceNodePort(domain1Namespace, domain1AdminServerPodName + "-external", "default"),
        "Getting admin server node port failed");

    String curlRequest = String.format("curl -v --show-error --noproxy '*' "
            + "http://%s:%s/TxForward/TxForward?urls=t3://%s.%s:7001,t3://%s1.%s:8001,t3://%s1.%s:8001,t3://%s2.%s:8001",
        K8S_NODEPORT_HOST, adminServiceNodePort, domain1AdminServerPodName, domain1Namespace,
        domain1ManagedServerPrefix, domain1Namespace, domain2ManagedServerPrefix,domain2Namespace,
        domain2ManagedServerPrefix, domain2Namespace);

    ExecResult result = null;
    logger.info("curl command {0}", curlRequest);
    result = assertDoesNotThrow(
        () -> exec(curlRequest, true));
    if (result.exitValue() == 0) {
      logger.info("\n HTTP response is \n " + result.stdout());
      logger.info("curl command returned {0}", result.toString());
      assertTrue(result.stdout().contains("Status=Committed"), "crossDomainTransaction failed");
    }

  }
/*
   * This test verifies cross domain transaction is successful. domain in image using wdt is used
   * to create 2 domains in different namespaces. An app is deployed to both the domains and the servlet
   * is invoked which starts a transaction that spans both domains.
   */
This test verifies cross domain transaction is successful. domain in image using wdt is used
to create 2 domains in different namespaces. An app is deployed to both the domains and the servlet
is invoked which starts a transaction that spans both domains.
This test verifies cross domain transaction is successful . domain in image using wdt is used to create 2 domains in different namespaces . An app is deployed to both the domains and the servlet is invoked which starts a transaction that spans both domains .
@Test
  @DisplayName("Check cross domain transaction works")
  @Slow
  @MustNotRunInParallel
  public void testCrossDomainTransaction() {
    Path distDir = BuildApplication.buildApplication(Paths.get(APP_DIR, "txforward"), null, null,
        "build", domain1Namespace);
    logger.info("distDir is {0}", distDir.toString());
    assertTrue(Paths.get(distDir.toString(),
        "txforward.ear").toFile().exists(),
        "Application archive is not available");
    String appSource = distDir.toString() + "/txforward.ear";
    logger.info("Application is in {0}", appSource);
    logger.info("Create admin credential secret for domain1");
    String domain1AdminSecretName = domainUid1 + "-weblogic-credentials";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
        domain1AdminSecretName, domain1Namespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
        String.format("createSecret %s failed for %s", domain1AdminSecretName, domainUid1));
    logger.info("Create admin credential secret for domain2");
    String domain2AdminSecretName = domainUid2 + "-weblogic-credentials";
    assertDoesNotThrow(() -> createSecretWithUsernamePassword(
        domain2AdminSecretName, domain2Namespace, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT),
        String.format("createSecret %s failed for %s", domain2AdminSecretName, domainUid2));
    logger.info("Creating image with model file and verify");
    String domain1Image = createImageAndVerify(
        WDT_IMAGE_NAME1, WDT_MODEL_FILE_DOMAIN1, appSource, WDT_MODEL_DOMAIN1_PROPS, PROPS_TEMP_DIR, domainUid1);
    logger.info("Created {0} image", domain1Image);
    dockerLoginAndPushImageToRegistry(domain1Image);
    logger.info("Creating image with model file and verify");
    String domain2Image = createImageAndVerify(
        WDT_IMAGE_NAME2, WDT_MODEL_FILE_DOMAIN2, appSource, WDT_MODEL_DOMAIN2_PROPS, PROPS_TEMP_DIR, domainUid2);
    logger.info("Created {0} image", domain2Image);
    dockerLoginAndPushImageToRegistry(domain2Image);
    createDomain(domainUid1, domain1Namespace, domain1AdminSecretName, domain1Image);
    createDomain(domainUid2, domain2Namespace, domain2AdminSecretName, domain2Image);
    logger.info("Getting admin server external service node port");
    int adminServiceNodePort = assertDoesNotThrow(
        () -> getServiceNodePort(domain1Namespace, domain1AdminServerPodName + "-external", "default"),
        "Getting admin server node port failed");
    String curlRequest = String.format("curl -v --show-error --noproxy '*' "
            + "http://%s:%s/TxForward/TxForward?urls=t3://%s.%s:7001,t3://%s1.%s:8001,t3://%s1.%s:8001,t3://%s2.%s:8001",
        K8S_NODEPORT_HOST, adminServiceNodePort, domain1AdminServerPodName, domain1Namespace,
        domain1ManagedServerPrefix, domain1Namespace, domain2ManagedServerPrefix,domain2Namespace,
        domain2ManagedServerPrefix, domain2Namespace);
    ExecResult result = null;
    logger.info("curl command {0}", curlRequest);
    result = assertDoesNotThrow(
        () -> exec(curlRequest, true));
    if (result.exitValue() == 0) {
      logger.info("\n HTTP response is \n " + result.stdout());
      logger.info("curl command returned {0}", result.toString());
      assertTrue(result.stdout().contains("Status=Committed"), "crossDomainTransaction failed");
    }
  }
@ Test @ DisplayName ( "Check cross domain transaction works" ) @ Slow @ MustNotRunInParallel public void testCrossDomainTransaction ( ) { Path distDir = BuildApplication . buildApplication ( Paths . get ( APP_DIR , "txforward" ) , null , null , "build" , domain1Namespace ) ; logger . info ( "distDir is {0}" , distDir . toString ( ) ) ; assertTrue ( Paths . get ( distDir . toString ( ) , "txforward.ear" ) . toFile ( ) . exists ( ) , "Application archive is not available" ) ; String appSource = distDir . toString ( ) + "/txforward.ear" ; logger . info ( "Application is in {0}" , appSource ) ; logger . info ( "Create admin credential secret for domain1" ) ; String domain1AdminSecretName = domainUid1 + "-weblogic-credentials" ; assertDoesNotThrow ( ( ) -> createSecretWithUsernamePassword ( domain1AdminSecretName , domain1Namespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ) , String . format ( "createSecret %s failed for %s" , domain1AdminSecretName , domainUid1 ) ) ; logger . info ( "Create admin credential secret for domain2" ) ; String domain2AdminSecretName = domainUid2 + "-weblogic-credentials" ; assertDoesNotThrow ( ( ) -> createSecretWithUsernamePassword ( domain2AdminSecretName , domain2Namespace , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ) , String . format ( "createSecret %s failed for %s" , domain2AdminSecretName , domainUid2 ) ) ; logger . info ( "Creating image with model file and verify" ) ; String domain1Image = createImageAndVerify ( WDT_IMAGE_NAME1 , WDT_MODEL_FILE_DOMAIN1 , appSource , WDT_MODEL_DOMAIN1_PROPS , PROPS_TEMP_DIR , domainUid1 ) ; logger . info ( "Created {0} image" , domain1Image ) ; dockerLoginAndPushImageToRegistry ( domain1Image ) ; logger . info ( "Creating image with model file and verify" ) ; String domain2Image = createImageAndVerify ( WDT_IMAGE_NAME2 , WDT_MODEL_FILE_DOMAIN2 , appSource , WDT_MODEL_DOMAIN2_PROPS , PROPS_TEMP_DIR , domainUid2 ) ; logger . info ( "Created {0} image" , domain2Image ) ; dockerLoginAndPushImageToRegistry ( domain2Image ) ; createDomain ( domainUid1 , domain1Namespace , domain1AdminSecretName , domain1Image ) ; createDomain ( domainUid2 , domain2Namespace , domain2AdminSecretName , domain2Image ) ; logger . info ( "Getting admin server external service node port" ) ; int adminServiceNodePort = assertDoesNotThrow ( ( ) -> getServiceNodePort ( domain1Namespace , domain1AdminServerPodName + "-external" , "default" ) , "Getting admin server node port failed" ) ; String curlRequest = String . format ( "curl -v --show-error --noproxy '*' " + "http://%s:%s/TxForward/TxForward?urls=t3://%s.%s:7001,t3://%s1.%s:8001,t3://%s1.%s:8001,t3://%s2.%s:8001" , K8S_NODEPORT_HOST , adminServiceNodePort , domain1AdminServerPodName , domain1Namespace , domain1ManagedServerPrefix , domain1Namespace , domain2ManagedServerPrefix , domain2Namespace , domain2ManagedServerPrefix , domain2Namespace ) ; ExecResult result = null ; logger . info ( "curl command {0}" , curlRequest ) ; result = assertDoesNotThrow ( ( ) -> exec ( curlRequest , true ) ) ; if ( result . exitValue ( ) == 0 ) { logger . info ( "\n HTTP response is \n " + result . stdout ( ) ) ; logger . info ( "curl command returned {0}" , result . toString ( ) ) ; assertTrue ( result . stdout ( ) . contains ( "Status=Committed" ) , "crossDomainTransaction failed" ) ; } }
This test verifies cross domain transaction is successful.
This test verifies cross domain transaction is successful .
//build application archive // create admin credential secret for domain1 // create admin credential secret for domain2 // docker login and push image to docker registry if necessary // docker login and push image to docker registry if necessary //create domain1 //create domain2