new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItStickySession.java
@Test
  @DisplayName("Create a Voyager ingress controller and verify that two HTTP connections are sticky to the same server")
  @Slow
  @MustNotRunInParallel
  public void testSameSessionStickiness() {
    final String ingressName = domainUid + "-ingress-host-routing";
    final String ingressServiceName = VOYAGER_CHART_NAME + "-" + ingressName;
    final String channelName = "tcp-80";
    final int counterNum = 4;
    final String webServiceSetUrl = SESSMIGR_APP_WAR_NAME + "/?setCounter=" + counterNum;
    final String webServiceGetUrl = SESSMIGR_APP_WAR_NAME + "/?getCounter";
    final String serverNameAttr = "servername";
    final String sessionIdAttr = "sessionid";
    final String countAttr = "count";

    // create Voyager ingress resource
    Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
    clusterNameMsPortMap.put(clusterName, managedServerPort);
    List<String>  hostNames =
        installVoyagerIngressAndVerify(domainUid, domainNamespace, ingressName, clusterNameMsPortMap);

    // get ingress service Nodeport
    int ingressServiceNodePort = assertDoesNotThrow(
        () -> getServiceNodePort(domainNamespace, ingressServiceName, channelName),
        "Getting admin server node port failed");
    logger.info("Node port for {0} is: {1} :", ingressServiceName, ingressServiceNodePort);

    // send a HTTP request to set http session state(count number) and save HTTP session info
    Map<String, String> httpDataInfo =
        getServerAndSessionInfoAndVerify(hostNames.get(0),
            ingressServiceNodePort, webServiceSetUrl, " -D ");
    // get server and session info from web service deployed on the cluster
    String serverName1 = httpDataInfo.get(serverNameAttr);
    String sessionId1 = httpDataInfo.get(sessionIdAttr);
    logger.info("Got the server {0} and session ID {1} from the first HTTP connection",
        serverName1, sessionId1);

    // send a HTTP request again to get server and session info
    httpDataInfo =
        getServerAndSessionInfoAndVerify(hostNames.get(0),
            ingressServiceNodePort, webServiceGetUrl, " -b ");
    // get server and session info from web service deployed on the cluster
    String serverName2 = httpDataInfo.get(serverNameAttr);
    String sessionId2 = httpDataInfo.get(sessionIdAttr);
    String countStr = httpDataInfo.get(countAttr);
    int count = Optional.ofNullable(countStr).map(Ints::tryParse).orElse(0);
    logger.info("Got the server {0}, session ID {1} and session state {2} "
        + "from the second HTTP connection", serverName2, sessionId2, count);

    // verify that two HTTP connections are sticky to the same server
    assertAll("Check that teh sticky session is supported",
        () -> assertEquals(serverName1, serverName2,
            "HTTP connections should be sticky to the server " + serverName1),
        () -> assertEquals(sessionId1, sessionId2,
            "HTTP session ID should be same for all HTTP connections " + sessionId1),
        () -> assertEquals(count, SESSION_STATE,
            "HTTP session state should equels " + SESSION_STATE)
    );

    logger.info("SUCCESS --- testSameSessionStickiness \n"
        + "Two HTTP connections are sticky to server {0} The session state "
        + "from the econd HTTP connections is {2}", serverName2, SESSION_STATE);
  }
/**
   * Verify that two HTTP requests sent to WebLogic are directed to same WebLogic server.
   * The test uses a web application deployed on WebLogic cluster to track HTTP session.
   * server-affinity is achieved by Voyager ingress controller based on HTTP session information.
   */
Verify that two HTTP requests sent to WebLogic are directed to same WebLogic server.
The test uses a web application deployed on WebLogic cluster to track HTTP session.
server-affinity is achieved by Voyager ingress controller based on HTTP session information.
Verify that two HTTP requests sent to WebLogic are directed to same WebLogic server . The test uses a web application deployed on WebLogic cluster to track HTTP session . server - affinity is achieved by Voyager ingress controller based on HTTP session information .
@Test
  @DisplayName("Create a Voyager ingress controller and verify that two HTTP connections are sticky to the same server")
  @Slow
  @MustNotRunInParallel
  public void testSameSessionStickiness() {
    final String ingressName = domainUid + "-ingress-host-routing";
    final String ingressServiceName = VOYAGER_CHART_NAME + "-" + ingressName;
    final String channelName = "tcp-80";
    final int counterNum = 4;
    final String webServiceSetUrl = SESSMIGR_APP_WAR_NAME + "/?setCounter=" + counterNum;
    final String webServiceGetUrl = SESSMIGR_APP_WAR_NAME + "/?getCounter";
    final String serverNameAttr = "servername";
    final String sessionIdAttr = "sessionid";
    final String countAttr = "count";
    Map<String, Integer> clusterNameMsPortMap = new HashMap<>();
    clusterNameMsPortMap.put(clusterName, managedServerPort);
    List<String>  hostNames =
        installVoyagerIngressAndVerify(domainUid, domainNamespace, ingressName, clusterNameMsPortMap);
    int ingressServiceNodePort = assertDoesNotThrow(
        () -> getServiceNodePort(domainNamespace, ingressServiceName, channelName),
        "Getting admin server node port failed");
    logger.info("Node port for {0} is: {1} :", ingressServiceName, ingressServiceNodePort);
    Map<String, String> httpDataInfo =
        getServerAndSessionInfoAndVerify(hostNames.get(0),
            ingressServiceNodePort, webServiceSetUrl, " -D ");
    String serverName1 = httpDataInfo.get(serverNameAttr);
    String sessionId1 = httpDataInfo.get(sessionIdAttr);
    logger.info("Got the server {0} and session ID {1} from the first HTTP connection",
        serverName1, sessionId1);
    httpDataInfo =
        getServerAndSessionInfoAndVerify(hostNames.get(0),
            ingressServiceNodePort, webServiceGetUrl, " -b ");
    String serverName2 = httpDataInfo.get(serverNameAttr);
    String sessionId2 = httpDataInfo.get(sessionIdAttr);
    String countStr = httpDataInfo.get(countAttr);
    int count = Optional.ofNullable(countStr).map(Ints::tryParse).orElse(0);
    logger.info("Got the server {0}, session ID {1} and session state {2} "
        + "from the second HTTP connection", serverName2, sessionId2, count);
    assertAll("Check that teh sticky session is supported",
        () -> assertEquals(serverName1, serverName2,
            "HTTP connections should be sticky to the server " + serverName1),
        () -> assertEquals(sessionId1, sessionId2,
            "HTTP session ID should be same for all HTTP connections " + sessionId1),
        () -> assertEquals(count, SESSION_STATE,
            "HTTP session state should equels " + SESSION_STATE)
    );
    logger.info("SUCCESS --- testSameSessionStickiness \n"
        + "Two HTTP connections are sticky to server {0} The session state "
        + "from the econd HTTP connections is {2}", serverName2, SESSION_STATE);
  }
@ Test @ DisplayName ( "Create a Voyager ingress controller and verify that two HTTP connections are sticky to the same server" ) @ Slow @ MustNotRunInParallel public void testSameSessionStickiness ( ) { final String ingressName = domainUid + "-ingress-host-routing" ; final String ingressServiceName = VOYAGER_CHART_NAME + "-" + ingressName ; final String channelName = "tcp-80" ; final int counterNum = 4 ; final String webServiceSetUrl = SESSMIGR_APP_WAR_NAME + "/?setCounter=" + counterNum ; final String webServiceGetUrl = SESSMIGR_APP_WAR_NAME + "/?getCounter" ; final String serverNameAttr = "servername" ; final String sessionIdAttr = "sessionid" ; final String countAttr = "count" ; Map < String , Integer > clusterNameMsPortMap = new HashMap < > ( ) ; clusterNameMsPortMap . put ( clusterName , managedServerPort ) ; List < String > hostNames = installVoyagerIngressAndVerify ( domainUid , domainNamespace , ingressName , clusterNameMsPortMap ) ; int ingressServiceNodePort = assertDoesNotThrow ( ( ) -> getServiceNodePort ( domainNamespace , ingressServiceName , channelName ) , "Getting admin server node port failed" ) ; logger . info ( "Node port for {0} is: {1} :" , ingressServiceName , ingressServiceNodePort ) ; Map < String , String > httpDataInfo = getServerAndSessionInfoAndVerify ( hostNames . get ( 0 ) , ingressServiceNodePort , webServiceSetUrl , " -D " ) ; String serverName1 = httpDataInfo . get ( serverNameAttr ) ; String sessionId1 = httpDataInfo . get ( sessionIdAttr ) ; logger . info ( "Got the server {0} and session ID {1} from the first HTTP connection" , serverName1 , sessionId1 ) ; httpDataInfo = getServerAndSessionInfoAndVerify ( hostNames . get ( 0 ) , ingressServiceNodePort , webServiceGetUrl , " -b " ) ; String serverName2 = httpDataInfo . get ( serverNameAttr ) ; String sessionId2 = httpDataInfo . get ( sessionIdAttr ) ; String countStr = httpDataInfo . get ( countAttr ) ; int count = Optional . ofNullable ( countStr ) . map ( Ints :: tryParse ) . orElse ( 0 ) ; logger . info ( "Got the server {0}, session ID {1} and session state {2} " + "from the second HTTP connection" , serverName2 , sessionId2 , count ) ; assertAll ( "Check that teh sticky session is supported" , ( ) -> assertEquals ( serverName1 , serverName2 , "HTTP connections should be sticky to the server " + serverName1 ) , ( ) -> assertEquals ( sessionId1 , sessionId2 , "HTTP session ID should be same for all HTTP connections " + sessionId1 ) , ( ) -> assertEquals ( count , SESSION_STATE , "HTTP session state should equels " + SESSION_STATE ) ) ; logger . info ( "SUCCESS --- testSameSessionStickiness \n" + "Two HTTP connections are sticky to server {0} The session state " + "from the econd HTTP connections is {2}" , serverName2 , SESSION_STATE ) ; }
Verify that two HTTP requests sent to WebLogic are directed to same WebLogic server.
Verify that two HTTP requests sent to WebLogic are directed to same WebLogic server .
// create Voyager ingress resource // get ingress service Nodeport // send a HTTP request to set http session state(count number) and save HTTP session info // get server and session info from web service deployed on the cluster // send a HTTP request again to get server and session info // get server and session info from web service deployed on the cluster // verify that two HTTP connections are sticky to the same server