Skip to content

owls-92094 Resolution to Intermittent CrossDomain MDB tests failure #2530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import oracle.weblogic.kubernetes.logging.LoggingFacade;
import oracle.weblogic.kubernetes.utils.ExecResult;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -53,7 +54,7 @@
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppIsActive;
import static oracle.weblogic.kubernetes.utils.BuildApplication.buildApplication;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
import static oracle.weblogic.kubernetes.utils.DbUtils.getDBNodePort;
Expand All @@ -66,8 +67,6 @@
import static oracle.weblogic.kubernetes.utils.ImageUtils.createSecretForBaseImages;
import static oracle.weblogic.kubernetes.utils.ImageUtils.dockerLoginAndPushImageToRegistry;
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodExists;
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
import static oracle.weblogic.kubernetes.utils.PodUtils.getExternalServicePodName;
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
Expand Down Expand Up @@ -156,10 +155,26 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {

// install and verify operator
installAndVerifyOperator(opNamespace, domain1Namespace, domain2Namespace);

buildApplicationsAndDomains();
}

/**
* Verify all server pods are running.
* Verify k8s services for all servers are created.
*/
@BeforeEach
public void beforeEach() {
int replicaCount = 2;
for (int i = 1; i <= replicaCount; i++) {
checkPodReadyAndServiceExists(domain2ManagedServerPrefix + i,
domainUid2, domain2Namespace);
}
for (int i = 1; i <= replicaCount; i++) {
checkPodReadyAndServiceExists(domain1ManagedServerPrefix + i,
domainUid1, domain1Namespace);
}
}

private static void updatePropertyFile() {
//create a temporary directory to copy and update the properties file
Path target = Paths.get(PROPS_TEMP_DIR);
Expand Down Expand Up @@ -482,38 +497,16 @@ private static void createDomain(String domainUid, String domainNamespace, Strin
);

// check admin server pod exists
// check admin server services created
logger.info("Check for admin server pod {0} existence in namespace {1}",
adminServerPodName, domainNamespace);
checkPodExists(adminServerPodName, domainUid, domainNamespace);

checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace);
// check managed server pods exist
for (int i = 1; i <= replicaCount; i++) {
logger.info("Check for managed server pod {0} existence in namespace {1}",
managedServerPrefix + i, domainNamespace);
checkPodExists(managedServerPrefix + i, domainUid, domainNamespace);
}

// check admin server pod is ready
logger.info("Wait for admin server pod {0} to be ready in namespace {1}",
adminServerPodName, domainNamespace);
checkPodReady(adminServerPodName, domainUid, domainNamespace);

// check managed server pods are ready
for (int i = 1; i <= replicaCount; i++) {
logger.info("Wait for managed server pod {0} to be ready in namespace {1}",
managedServerPrefix + i, domainNamespace);
checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
}

logger.info("Check admin service {0} is created in namespace {1}",
adminServerPodName, domainNamespace);
checkServiceExists(adminServerPodName, domainNamespace);

// check managed server services created
for (int i = 1; i <= replicaCount; i++) {
logger.info("Check managed server service {0} is created in namespace {1}",
logger.info("Check for managed server pod {0} existence in namespace {1}",
managedServerPrefix + i, domainNamespace);
checkServiceExists(managedServerPrefix + i, domainNamespace);
checkPodReadyAndServiceExists(managedServerPrefix + i, domainUid, domainNamespace);
}

logger.info("Getting node port");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import oracle.weblogic.kubernetes.logging.LoggingFacade;
import oracle.weblogic.kubernetes.utils.ExecResult;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand All @@ -55,6 +56,7 @@
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppIsActive;
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
import static oracle.weblogic.kubernetes.utils.BuildApplication.buildApplication;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
Expand Down Expand Up @@ -162,12 +164,26 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
assertDoesNotThrow(() -> addLabelsToNamespace(domain1Namespace,labelMap));
assertDoesNotThrow(() -> addLabelsToNamespace(domain2Namespace,labelMap));
assertDoesNotThrow(() -> addLabelsToNamespace(opNamespace,labelMap));

// install and verify operator
installAndVerifyOperator(opNamespace, domain1Namespace, domain2Namespace);

buildApplicationsAndDomains();
}

/**
* Verify all server pods are running.
* Verify k8s services for all servers are created.
*/
@BeforeEach
public void beforeEach() {
int replicaCount = 2;
for (int i = 1; i <= replicaCount; i++) {
checkPodReadyAndServiceExists(domain2ManagedServerPrefix + i,
domainUid2, domain2Namespace);
}
for (int i = 1; i <= replicaCount; i++) {
checkPodReadyAndServiceExists(domain1ManagedServerPrefix + i,
domainUid1, domain1Namespace);
}
}

private static void updatePropertyFile() {
Expand Down Expand Up @@ -539,7 +555,6 @@ private static void createDomain(String domainUid, String domainNamespace, Strin
managedServerPrefix + i, domainNamespace);
checkPodReady(managedServerPrefix + i, domainUid, domainNamespace);
}

}

private static void createDomainResource(String domainUid, String domNamespace, String adminSecretName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

public class JmsServlet extends HttpServlet {

private static int s1count=0;
private static int s2count=0;

protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
Expand Down Expand Up @@ -113,8 +116,6 @@ protected void doGet(HttpServletRequest request,
out.println("Receiving message from ["+destination+"]");
Message msg=null;
int count = 0;
int s1count=0;
int s2count=0;
JMSConsumer consumer = (JMSConsumer) context.createConsumer(d);
do {
// msg = consumer.receiveNoWait();
Expand All @@ -129,22 +130,32 @@ protected void doGet(HttpServletRequest request,
}
} while( msg != null);

out.println("Found ("+s1count+") message from [managed-server1]");
out.println("Found ("+s2count+") message from [managed-server2]");
out.println("Recorded ("+s1count+") message from [managed-server1]");
out.println("Recorded ("+s2count+") message from [managed-server2]");

if ( count == rcount ) {
out.println("Drained ("+count+") message from ["+destination+"]");
// Intermittently, in a single attempt all 20 messages are not
// received on accouting Queue. So the logic is modified to make sure
// the accounting Queue get 20 messages all together with multiple
// attempts. Here the s1count, s2count variables have been made static
// to keep a record of the message received from managed-server1 and
// managed-server2 of domain2 respectively.
// Finally it make sure that s1count and s2count are same

if ( s1count == s2count )
int ccount = s1count + s2count;
if ( ccount == rcount ) {
if ( s1count == s2count ) {
out.println("Messages are distributed across MDB instances");
else
} else {
out.println("Messages are NOT distributed across MDB instances");

}
// reset the message counter once all messages are received
s1count=0;
s2count=0;
} else {
out.println("Found ("+count+") message on ["+destination+"] instead of ["+rcount+"]");
}
}

out.println("Total messages received so far is ["+ccount+"]");
out.println("Waiting for more messages to appears on accounting queue");
}
}
} catch (Exception e) {
out.println("Send/Receive FAILED with Unknown Exception " + e);
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void onMessage (Message msg) {
JMSContext context = cf.createContext();
tmsg = context.createTextMessage("(On Server) " + serverRuntime.getName());
context.createProducer().send(rq,tmsg);
System.out.println("["+dateFormat.format(date)+"]<TMDB> message added to [@FWD_DEST_URL@]");
System.out.println("["+dateFormat.format(date)+"]<TMDB> message forwarded to [t3://domain1-admin-server:7001]");
} catch (Exception e) {
e.printStackTrace ();
}
Expand Down