Skip to content

Commit

Permalink
Issue OpenLiberty#10041 fix Infinispan and Hazelcast session cache fa…
Browse files Browse the repository at this point in the history
…t test in windows
  • Loading branch information
gjwatts committed Dec 6, 2019
1 parent afc0332 commit 10647bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 IBM Corporation and others.
* Copyright (c) 2018, 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -11,6 +11,7 @@
package com.ibm.ws.session.cache.config.fat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -192,11 +193,16 @@ public void testScheduleInvalidation() throws Exception {
httpSessionCache.setScheduleInvalidationSecondHour(Integer.toString(hour2));
httpSessionCache.setWriteFrequency("TIME_BASED_WRITE");
httpSessionCache.setWriteInterval("15s");
server.setMarkToEndOfLog();
server.setMarkToEndOfLog(); // Only marks messages.log, does not mark the trace file
server.setTraceMarkToEndOfDefaultTrace();
server.updateServerConfiguration(config);
server.waitForConfigUpdateInLogUsingMark(APP_NAMES, EMPTY_RECYCLE_LIST);
String messageToCheckFor = "doScheduledInvalidation scheduled hours are " + Integer.toString(hour1) + " and " + Integer.toString(hour2);

TimeUnit.SECONDS.sleep(10); // Due to invalidation thread delay
// Monitor trace.log and wait for the message "doScheduledInvalidation scheduled hours are X and Y" before the test should continue
// This replaces the TimeUnit.SECONDS.sleep(10) used before
assertNotNull("Could not find Infinispan message \"" + messageToCheckFor + "\" Has the Infinispan message changed?",
server.waitForStringInTraceUsingMark(messageToCheckFor));

ArrayList<String> session = new ArrayList<>();
String response = run("testSetAttributeWithTimeout&attribute=testScheduleInvalidation&value=si1&maxInactiveInterval=1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package com.ibm.ws.session.cache.config.fat.infinispan;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

import java.time.ZonedDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -61,6 +62,14 @@ public void cleanUpPerTest() throws Exception {
server.updateServerConfiguration(savedConfig);
server.waitForConfigUpdateInLogUsingMark(APP_NAMES, cleanupList);
cleanupList = EMPTY_RECYCLE_LIST;

// In addition to starting the application, must also wait for asynchronous web module initialization to complete,
// otherwise tests which attempt a configuration update could end up triggering a deactivate and close of the CachingProvider
// while the servlet initialization code is still attempting to use the CachingProvider and/or the CacheManager and Caches that it creates.
List<String> session = new ArrayList<>();
run("getSessionId", session);
run("invalidateSession", session);

System.out.println("server configuration restored");
}

Expand Down Expand Up @@ -153,11 +162,16 @@ public void testScheduleInvalidation() throws Exception {
httpSessionCache.setScheduleInvalidationSecondHour(Integer.toString(hour2));
httpSessionCache.setWriteFrequency("TIME_BASED_WRITE");
httpSessionCache.setWriteInterval("15s");
server.setMarkToEndOfLog();
server.setMarkToEndOfLog(); // Only marks messages.log, does not mark the trace file
server.setTraceMarkToEndOfDefaultTrace();
server.updateServerConfiguration(config);
server.waitForConfigUpdateInLogUsingMark(APP_NAMES, EMPTY_RECYCLE_LIST);
String messageToCheckFor = "doScheduledInvalidation scheduled hours are " + Integer.toString(hour1) + " and " + Integer.toString(hour2);

TimeUnit.SECONDS.sleep(10); // Due to invalidation thread delay
// Monitor trace.log and wait for the message "doScheduledInvalidation scheduled hours are X and Y" before the test should continue
// This replaces the TimeUnit.SECONDS.sleep(10) used before
assertNotNull("Could not find Infinispan message \"" + messageToCheckFor + "\" Has the Infinispan message changed?",
server.waitForStringInTraceUsingMark(messageToCheckFor));

ArrayList<String> session = new ArrayList<>();
String response = run("testSetAttributeWithTimeout&attribute=testScheduleInvalidation&value=si1&maxInactiveInterval=1",
Expand Down

0 comments on commit 10647bd

Please sign in to comment.