diff --git a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeContainerLauncher.groovy b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeContainerLauncher.groovy index 32e91095ce5..1859df5a2ac 100644 --- a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeContainerLauncher.groovy +++ b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeContainerLauncher.groovy @@ -36,14 +36,13 @@ class ReposeContainerLauncher extends ReposeLauncher { String rootWarLocation String[] appWars String debugPort - def classPaths = [] - def boolean debugEnabled - def boolean doSuspend + boolean debugEnabled + boolean doSuspend def clock = new SystemClock() - def ReposeConfigurationProvider configurationProvider + ReposeConfigurationProvider configurationProvider ReposeContainerLauncher(ReposeConfigurationProvider configurationProvider, String containerJar, String clusterId, String nodeId, @@ -54,7 +53,6 @@ class ReposeContainerLauncher extends ReposeLauncher { this.nodeId = nodeId this.reposePort = reposePort this.rootWarLocation = rootWarLocation - this.appWars = appWars } @@ -62,7 +60,7 @@ class ReposeContainerLauncher extends ReposeLauncher { void start() { String configDirectory = configurationProvider.getReposeConfigDir() - String webXmlOverrides = ""; + String webXmlOverrides = "" if (debugEnabled) { if (!debugPort) { @@ -91,8 +89,8 @@ class ReposeContainerLauncher extends ReposeLauncher { def th = new Thread({ this.process = cmd.execute() // TODO: This should probably go somewhere else and not just be consumed to the garbage. - this.process.consumeProcessOutput(System.out, System.err) - }); + this.process.consumeProcessOutput(System.out as Appendable, System.err as Appendable) + }) th.run() th.join() @@ -116,7 +114,7 @@ class ReposeContainerLauncher extends ReposeLauncher { void stop(int timeout, boolean throwExceptionOnKill) { try { - println("Stopping Repose"); + println("Stopping Repose") this.process.destroy() print("Waiting for Repose Container to shutdown") @@ -128,39 +126,12 @@ class ReposeContainerLauncher extends ReposeLauncher { println() } catch (IOException ioex) { this.process.waitForOrKill(5000) - killIfUp() if (throwExceptionOnKill) { - throw new TimeoutException("An error occurred while attempting to stop Repose Controller. Reason: " + ioex.getMessage()); - } - } - } - - private void killIfUp() { - String processes = TestUtils.getJvmProcesses() - def regex = /(\d*) ROOT.war .*/ - def matcher = (processes =~ regex) - if (matcher.size() > 0) { - - for (int i = 1; i <= matcher.size(); i++) { - String pid = matcher[0][i] - - if (pid != null && !pid.isEmpty()) { - println("Killing running repose-valve process: " + pid) - Runtime rt = Runtime.getRuntime(); - if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) - rt.exec("taskkill " + pid.toInteger()); - else - rt.exec("kill -9 " + pid.toInteger()); - } + throw new TimeoutException("An error occurred while attempting to stop Repose Controller. Reason: " + ioex.getMessage()) } } } - @Override - boolean areAnyUp() { - return TestUtils.getJvmProcesses().contains("ROOT.war") - } - @Override void enableDebug() { this.debugEnabled = true @@ -171,9 +142,4 @@ class ReposeContainerLauncher extends ReposeLauncher { this.debugEnabled = true this.doSuspend = true } - - @Override - void addToClassPath(String path) { - classPaths.add(path) - } } diff --git a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeLauncher.groovy b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeLauncher.groovy index 72ca2c98e2f..a9e599fe280 100644 --- a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeLauncher.groovy +++ b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeLauncher.groovy @@ -19,10 +19,10 @@ */ package org.openrepose.framework.test -import org.apache.http.client.ClientProtocolException import org.apache.http.client.HttpClient import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.DefaultHttpClient +import org.linkedin.util.clock.SystemClock import static org.linkedin.groovy.util.concurrent.GroovyConcurrentUtils.waitForCondition @@ -36,8 +36,6 @@ abstract class ReposeLauncher { abstract void enableDebug() - abstract boolean areAnyUp() - boolean isUp() { this.process?.isAlive() ?: false } @@ -49,28 +47,22 @@ abstract class ReposeLauncher { */ abstract void enableSuspend() - abstract void addToClassPath(String path) - - def waitForNon500FromUrl(url, int timeoutInSeconds = 60, int intervalInSeconds = 2) { - + static def waitForNon500FromUrl(String url, int timeoutInSeconds = 60, int intervalInSeconds = 2) { waitForResponseCodeFromUrl(url, timeoutInSeconds, intervalInSeconds) { code -> code < 500 } } - def waitForDesiredResponseCodeFromUrl(url, desiredCodes, timeoutInSeconds = 60, int intervalInSeconds = 2) { - + static def waitForDesiredResponseCodeFromUrl(String url, desiredCodes, timeoutInSeconds = 60, int intervalInSeconds = 2) { waitForResponseCodeFromUrl(url, timeoutInSeconds, intervalInSeconds) { code -> code in desiredCodes } } - def waitForResponseCodeFromUrl(url, timeoutInSeconds, int intervalInSeconds, isResponseAcceptable) { - + static def waitForResponseCodeFromUrl(String url, timeoutInSeconds, int intervalInSeconds, isResponseAcceptable) { print("\n\nWaiting for repose to start at ${url} \n\n") - waitForCondition(clock, "${timeoutInSeconds}s", "${intervalInSeconds}s") { + waitForCondition(SystemClock.INSTANCE, "${timeoutInSeconds}s", "${intervalInSeconds}s") { try { print(".") HttpClient client = new DefaultHttpClient() isResponseAcceptable(client.execute(new HttpGet(url)).statusLine.statusCode) } catch (IOException ignored) { - } catch (ClientProtocolException ignored) { } } println() diff --git a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveLauncher.groovy b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveLauncher.groovy index 8594756439c..09d5a2eca64 100644 --- a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveLauncher.groovy +++ b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveLauncher.groovy @@ -79,11 +79,6 @@ class ReposeValveLauncher extends ReposeLauncher { } void start(Map params) { - - boolean killOthersBeforeStarting = true - if (params.containsKey("killOthersBeforeStarting")) { - killOthersBeforeStarting = params.killOthersBeforeStarting - } boolean waitOnJmxAfterStarting = true if (params.containsKey("waitOnJmxAfterStarting")) { waitOnJmxAfterStarting = params.waitOnJmxAfterStarting @@ -92,15 +87,14 @@ class ReposeValveLauncher extends ReposeLauncher { String clusterId = params.get('clusterId', "") String nodeId = params.get('nodeId', "") - start(killOthersBeforeStarting, waitOnJmxAfterStarting, clusterId, nodeId) + start(waitOnJmxAfterStarting, clusterId, nodeId) } /** * TODO: need to know what node in the system model we care about. There might be many, for multiple local node testing... - * @param killOthersBeforeStarting * @param waitOnJmxAfterStarting */ - void start(boolean killOthersBeforeStarting, boolean waitOnJmxAfterStarting, String clusterId, String nodeId) { + void start(boolean waitOnJmxAfterStarting, String clusterId, String nodeId) { File jarFile = new File(reposeJar) if (!jarFile.exists() || !jarFile.isFile()) { @@ -112,14 +106,6 @@ class ReposeValveLauncher extends ReposeLauncher { throw new FileNotFoundException("Missing or invalid configuration folder.") } - if (killOthersBeforeStarting) { - waitForCondition(clock, '5s', '1s') { - killIfUp() - !isUp() - } - } - - def jmxprops = "" def debugProps = "" def jacocoProps = "" def classPath = "" @@ -140,7 +126,7 @@ class ReposeValveLauncher extends ReposeLauncher { if (!jmxPort) { jmxPort = PortFinder.instance.getNextOpenPort() } - jmxprops = "-Dspock=spocktest -Dcom.sun.management.jmxremote.port=${jmxPort} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=true" + def jmxprops = "-Dspock=spocktest -Dcom.sun.management.jmxremote.port=${jmxPort} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=true" if (!classPaths.isEmpty()) { classPath = "-cp " + (classPaths as Set).join(";") @@ -162,11 +148,11 @@ class ReposeValveLauncher extends ReposeLauncher { newEnv.putAll(System.getenv()) additionalEnvironment.each { k, v -> - newEnv.put(k, v) //Should override anything, if there's anything to override + newEnv.put(k as String, v as String) //Should override anything, if there's anything to override } def envList = newEnv.collect { k, v -> "$k=$v" } this.process = cmd.execute(envList, null) - this.process.consumeProcessOutput(System.out, System.err) + this.process.consumeProcessOutput(System.out as Appendable, System.err as Appendable) }) th.run() @@ -184,17 +170,17 @@ class ReposeValveLauncher extends ReposeLauncher { print("Waiting for repose auto-guessed node to start: ") } - waitForCondition(clock, '60s', '1s') { + waitForCondition(clock, '180s', '1s') { isReposeNodeUp(clusterId, nodeId) } } } - def connectViaJmxRemote(jmxUrl) { + def connectViaJmxRemote(String jmxUrl) { try { jmx = new JmxClient(jmxUrl) return true - } catch (Exception ex) { + } catch (Exception ignored) { return false } } @@ -217,7 +203,7 @@ class ReposeValveLauncher extends ReposeLauncher { void stop(int timeout, boolean throwExceptionOnKill) { try { - println("Stopping Repose"); + println("Stopping Repose") this.process?.destroy() print("Waiting for Repose to shutdown") @@ -229,12 +215,9 @@ class ReposeValveLauncher extends ReposeLauncher { println() } catch (IOException ioex) { this.process.waitForOrKill(5000) - killIfUp() if (throwExceptionOnKill) { - throw new TimeoutException("An error occurred while attempting to stop Repose Controller. Reason: ${ioex.getMessage()}", ioex) + throw new TimeoutException("An error occurred while attempting to stop Repose Controller. Reason: ${ioex.getMessage()}") } - } finally { - configurationProvider.cleanConfigDirectory() } } @@ -249,11 +232,6 @@ class ReposeValveLauncher extends ReposeLauncher { this.doSuspend = true } - @Override - void addToClassPath(String path) { - classPaths.add(path) - } - /** * This takes a single string and will append it to the list of environment vars to be set for the .execute() method * Following docs from: http://groovy.codehaus.org/groovy-jdk/java/lang/String.html#execute%28java.util.List,%20java.io.File%29 @@ -296,12 +274,12 @@ class ReposeValveLauncher extends ReposeLauncher { } // First query for the mbean. The name of the mbean is partially configurable, so search for a match. - def HashSet cfgBean = (HashSet) jmx.getMBeans("*org.openrepose.core.services.jmx:type=ConfigurationInformation") + HashSet cfgBean = (HashSet) jmx.getMBeans("*org.openrepose.core.services.jmx:type=ConfigurationInformation") if (cfgBean == null || cfgBean.isEmpty()) { return false } - def String beanName = cfgBean.iterator().next().name.toString() + String beanName = cfgBean.iterator().next().name.toString() //Doing the JMX invocation here, because it's kinda ugly Object[] opParams = [clusterId, nodeId] @@ -311,31 +289,4 @@ class ReposeValveLauncher extends ReposeLauncher { def nodeIsReady = jmx.server.invoke(new ObjectName(beanName), "isNodeReady", opParams, opSignature) return nodeIsReady } - - @Override - boolean areAnyUp() { - println TestUtils.getJvmProcesses() - return TestUtils.getJvmProcesses().contains("repose-valve.jar") - } - - private static void killIfUp() { - String processes = TestUtils.getJvmProcesses() - def regex = /(\d*) repose-valve.jar .*spocktest .*/ - def matcher = (processes =~ regex) - if (matcher.size() > 0) { - - for (int i = 1; i <= matcher.size(); i++) { - String pid = matcher[0][i] - - if (pid != null && !pid.isEmpty()) { - println("Killing running repose-valve process: " + pid) - Runtime rt = Runtime.getRuntime(); - if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) - rt.exec("taskkill " + pid.toInteger()); - else - rt.exec("kill -9 " + pid.toInteger()); - } - } - } - } } diff --git a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveTest.groovy b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveTest.groovy index d6779ea35f5..5e76dda6392 100644 --- a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveTest.groovy +++ b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/ReposeValveTest.groovy @@ -40,22 +40,18 @@ abstract class ReposeValveTest extends Specification { String jmxHostname = InetAddress.getLocalHost().getHostName() @Shared - def ReposeValveLauncher repose + ReposeValveLauncher repose @Shared - def Deproxy deproxy + Deproxy deproxy @Shared - def TestProperties properties + TestProperties properties @Shared - def ReposeLogSearch reposeLogSearch - - @Shared - int clientId = 0 + ReposeLogSearch reposeLogSearch def setupSpec() { - String className = this.getClass().canonicalName properties = new TestProperties(className.replace('.', '/')) @@ -64,30 +60,17 @@ abstract class ReposeValveTest extends Specification { configureReposeValve() repose.configurationProvider.cleanConfigDirectory() break - case "tomcat": - throw new UnsupportedOperationException("Please implement me") - case "multinode": - String glassfishJar = properties.glassfishJar - configureReposeGlassfish(glassfishJar) - break default: throw new UnsupportedOperationException("Unknown container: " + reposeContainer) } } - def configureReposeGlassfish(String glassfishJar) { - repose = new ReposeContainerLauncher(glassfishJar) - repose.enableDebug() - } - - def configureReposeValve() { - ReposeConfigurationProvider reposeConfigProvider = new ReposeConfigurationProvider(properties) repose = new ReposeValveLauncher(reposeConfigProvider, properties) repose.enableDebug() - reposeLogSearch = new ReposeLogSearch(logFile); + reposeLogSearch = new ReposeLogSearch(logFile) } def cleanupSpec() { @@ -99,6 +82,10 @@ abstract class ReposeValveTest extends Specification { FileUtils.deleteQuietly(new File(logFile)) } + def waitUntilReposeIsReady(int timeout = 180) { + reposeLogSearch.awaitByString("Repose ready", 1, timeout) + } + /** * This needs to be the default way to determine if repose is ready to serve requests I think... * @param responseCode @@ -111,9 +98,8 @@ abstract class ReposeValveTest extends Specification { boolean checkLogMessage = false) { def clock = new SystemClock() def innerDeproxy = new Deproxy() - def logSearch = new ReposeLogSearch(properties.logFile) if (checkLogMessage) - logSearch.cleanLog() + reposeLogSearch.cleanLog() MessageChain mc try { waitForCondition(clock, '35s', '1s', { @@ -122,17 +108,17 @@ abstract class ReposeValveTest extends Specification { //This needs to do a bit more regexp // ClusterId and NodeID need to be known for what node we expect to be alive // .*PowerFilter.* clusterId-nodeId: Repose Ready - logSearch.awaitByString( + reposeLogSearch.awaitByString( "Repose ready", 1, 35, TimeUnit.SECONDS).size() > 0) { return true } try { mc = innerDeproxy.makeRequest([url: reposeEndpoint]) - } catch (Exception e) { + } catch (Exception ignored) { } if (mc != null) { println mc.receivedResponse.code - return mc.receivedResponse.code.equals(responseCode) + return mc.receivedResponse.code == responseCode } else { return false } @@ -144,7 +130,6 @@ abstract class ReposeValveTest extends Specification { return false } } - } // Helper methods to minimize refactoring in all test classes @@ -171,6 +156,4 @@ abstract class ReposeValveTest extends Specification { def getReposeContainer() { return properties.getReposeContainer() } - - } diff --git a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/client/jmx/JmxClient.groovy b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/client/jmx/JmxClient.groovy index 2b2b7b68d87..0f8f5ea6d3e 100644 --- a/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/client/jmx/JmxClient.groovy +++ b/repose-aggregator/tests/functional-test-framework/src/main/groovy/org/openrepose/framework/test/client/jmx/JmxClient.groovy @@ -36,7 +36,7 @@ import javax.management.remote.JMXServiceURL class JmxClient { public static final String COUNT_ATTRIBUTE = "Count" - def String jmxUrl + String jmxUrl def clock = new SystemClock() MBeanServerConnection server @@ -60,7 +60,6 @@ class JmxClient { conditions.eventually { try { tehCode.call() - whyFail = null } catch (Exception e) { //Don't actually care, because eventually a thingy whyFail = e @@ -70,13 +69,12 @@ class JmxClient { } catch (SpockTimeoutError ste) { throw new SpockAssertionError(ste.getMessage(), whyFail) } - } int getMBeanCountAttribute(String name) { try { server.getAttribute(new ObjectName(name), COUNT_ATTRIBUTE) as int - } catch (Exception e) { + } catch (Exception ignored) { 0 } } @@ -102,11 +100,11 @@ class JmxClient { * @param attr * @return */ - def quickMBeanAttribute(name, attr) { - def obj = null + def quickMBeanAttribute(String name, String attr) { + def obj try { obj = server.getAttribute(new ObjectName(name), attr) - } catch (Exception e) { + } catch (Exception ignored) { obj = null } return obj @@ -118,7 +116,7 @@ class JmxClient { * @param name - complete MBean name, to be passed into ObjectName * @return */ - def getMBeanAttribute(name, attr) { + def getMBeanAttribute(String name, String attr) { def obj = null eventually { obj = server.getAttribute(new ObjectName(name), attr) @@ -140,7 +138,7 @@ class JmxClient { try { def beansInDomain = server.queryMBeans(new ObjectName(domain), null) mbeans = beansInDomain.findAll { it.className == expectedClassName } - } catch (Exception e) { + } catch (Exception ignored) { //Nothing at all! } @@ -153,7 +151,7 @@ class JmxClient { * @param beanName * @return */ - Collection getMBeans(domain, expectedClassName, expectedCount) { + Collection getMBeans(String domain, expectedClassName, expectedCount) { def mbeans = null eventually { @@ -170,7 +168,7 @@ class JmxClient { * @param beanName * @return */ - def getMBeans(domain) { + def getMBeans(String domain) { def mbeans = null eventually { mbeans = server.queryMBeans(new ObjectName(domain), null) @@ -186,10 +184,10 @@ class JmxClient { * @param domain * @return */ - def quickMBeanNames(domain) { + def quickMBeanNames(String domain) { try { return server.queryNames(new ObjectName(domain), null) - } catch (Exception e) { + } catch (Exception ignored) { return [] } } @@ -201,7 +199,7 @@ class JmxClient { * @param beanName * @return */ - def getMBeanNames(domain) { + def getMBeanNames(String domain) { def mbeans = [] try { diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlAttributeMappingTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlAttributeMappingTest.groovy index 49546d75d52..c4854f36270 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlAttributeMappingTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlAttributeMappingTest.groovy @@ -62,7 +62,7 @@ class SamlAttributeMappingTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlBasicValidationTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlBasicValidationTest.groovy index fac93dcf9f8..ac81fc9c639 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlBasicValidationTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlBasicValidationTest.groovy @@ -53,7 +53,7 @@ class SamlBasicValidationTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheDisabledTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheDisabledTest.groovy index 90e9bb321f1..8d8bc5b5721 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheDisabledTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheDisabledTest.groovy @@ -51,7 +51,7 @@ class SamlCacheDisabledTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheFeedInvalidationTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheFeedInvalidationTest.groovy index e35b811f5ca..64d8926ce76 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheFeedInvalidationTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheFeedInvalidationTest.groovy @@ -66,7 +66,7 @@ class SamlCacheFeedInvalidationTest extends ReposeValveTest { fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() } def setup() { @@ -115,6 +115,8 @@ class SamlCacheFeedInvalidationTest extends ReposeValveTest { when: "the atom feed entry is made available and we wait until Repose logs that it processed the entry" atomEndpoint.defaultHandler = atomFeedHandlerWithEntry reposeLogSearch.awaitByString(ATOM_FEED_LOG_SEARCH_STRING, 1, FEED_POLLING_FREQUENCY_SEC + 1, TimeUnit.SECONDS) + // Let the cache entry actually clear + sleep(250) and: "a request is sent after the cache entry is supposed to be invalidated" atomEndpoint.defaultHandler = fakeAtomFeed.handler @@ -123,14 +125,14 @@ class SamlCacheFeedInvalidationTest extends ReposeValveTest { requestBody = asUrlEncodedForm((PARAM_SAML_RESPONSE): encodeBase64(saml)) mc = deproxy.makeRequest(url: url, method: HTTP_POST, headers: headers, requestBody: requestBody) - then: "the IDP and Mapping Policy endpoints are called again" - fakeIdentityV2Service.getGetIdpFromIssuerCount() == 1 - fakeIdentityV2Service.getGetMappingPolicyForIdpCount() == 1 - - and: "the request is overall successful" + then: "the request is overall successful" mc.receivedResponse.code as Integer == SC_OK mc.handlings[0] + and: "the IDP and Mapping Policy endpoints are called again" + fakeIdentityV2Service.getGetIdpFromIssuerCount() == 1 + fakeIdentityV2Service.getGetMappingPolicyForIdpCount() == 1 + where: eventType << ["CREATE", "UPDATE", "DELETE", "Surprise"] } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheTtlTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheTtlTest.groovy index 1a714bb0696..ad20d068c54 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheTtlTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlCacheTtlTest.groovy @@ -55,7 +55,7 @@ class SamlCacheTtlTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlConnectionHeadersTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlConnectionHeadersTest.groovy index 430c04ebe9e..ace6f0351d0 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlConnectionHeadersTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlConnectionHeadersTest.groovy @@ -55,7 +55,7 @@ class SamlConnectionHeadersTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlContentLengthTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlContentLengthTest.groovy index db0b4de8dd1..3d5a5fe2cb1 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlContentLengthTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlContentLengthTest.groovy @@ -63,7 +63,7 @@ class SamlContentLengthTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFeedConfigLiveUpdateTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFeedConfigLiveUpdateTest.groovy index 04d790124a0..54e61537b2c 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFeedConfigLiveUpdateTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFeedConfigLiveUpdateTest.groovy @@ -41,7 +41,6 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { static final int FEED_POLLING_FREQUENCY_MILLIS = FEED_POLLING_FREQUENCY_SEC * 1_000 static final String ATOM_FEED_LOG_SEARCH_STRING = "" - static final int REPOSE_START_WAIT_SEC = 30 static final int CONFIG_REFRESH_WAIT_SEC = 20 static final String CONFIG_DIR_SRC = "features/filters/samlpolicy/feedconfigliveupdate" @@ -87,7 +86,7 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { given: "we start Repose with no atom feed configured for the SAML filter" repose.configurationProvider.applyConfigs("$CONFIG_DIR_SRC/nofeed", params) repose.start(killOthersBeforeStarting: false, waitOnJmxAfterStarting: false) - waitForReposeToStart() + waitUntilReposeIsReady() and: "a unique issuer will be used when generating each saml:response" def samlIssuer = generateUniqueIssuer() @@ -186,7 +185,7 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { given: "we start Repose with no atom feed configured for the SAML filter" repose.configurationProvider.applyConfigs("$CONFIG_DIR_SRC/nofeed", params) repose.start(killOthersBeforeStarting: false, waitOnJmxAfterStarting: false) - waitForReposeToStart() + waitUntilReposeIsReady() and: "a unique issuer will be used when generating each saml:response" def samlIssuer = generateUniqueIssuer() @@ -240,7 +239,7 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { given: "we start Repose with an atom feed configured for the SAML filter" repose.configurationProvider.applyConfigs("$CONFIG_DIR_SRC/feedone", params) repose.start(killOthersBeforeStarting: false, waitOnJmxAfterStarting: false) - waitForReposeToStart() + waitUntilReposeIsReady() and: "two unique issuers will be used when generating each saml:response, one to prove the atom feed works and another to prove it stops working" def samlIssuer = generateUniqueIssuer() @@ -363,7 +362,7 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { given: "we start Repose with a particular atom feed configured for the SAML filter" repose.configurationProvider.applyConfigs("$CONFIG_DIR_SRC/feedone", params) repose.start(killOthersBeforeStarting: false, waitOnJmxAfterStarting: false) - waitForReposeToStart() + waitUntilReposeIsReady() and: "a unique issuer will be used when generating each saml:response" def samlIssuer = generateUniqueIssuer() @@ -506,10 +505,6 @@ class SamlFeedConfigLiveUpdateTest extends ReposeValveTest { requestBody: asUrlEncodedForm((PARAM_SAML_RESPONSE): encodeBase64(saml))) } - def waitForReposeToStart() { - reposeLogSearch.awaitByString("Repose ready", 1, REPOSE_START_WAIT_SEC) - } - def waitForReposeToLoadConfiguration() { reposeLogSearch.awaitByString("Configuration Updated:", 1, CONFIG_REFRESH_WAIT_SEC) } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow10Test.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow10Test.groovy index b60b641a7b7..711ba55e656 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow10Test.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow10Test.groovy @@ -64,7 +64,7 @@ class SamlFlow10Test extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow20Test.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow20Test.groovy index c03254b5a9d..4b7149e5ff7 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow20Test.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlFlow20Test.groovy @@ -65,7 +65,7 @@ class SamlFlow20Test extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlKeystoneCredentialsTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlKeystoneCredentialsTest.groovy index 75ddd0b6cc4..f3be52ad869 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlKeystoneCredentialsTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlKeystoneCredentialsTest.groovy @@ -55,7 +55,7 @@ class SamlKeystoneCredentialsTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() fakeIdentityV2Service.resetCounts() diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlNoTracingHeaderTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlNoTracingHeaderTest.groovy index 0fc39c27aa3..b6e25a3db19 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlNoTracingHeaderTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/filters/samlpolicy/SamlNoTracingHeaderTest.groovy @@ -55,7 +55,7 @@ class SamlNoTracingHeaderTest extends ReposeValveTest { deproxy.addEndpoint(properties.identityPort, 'identity service', null, fakeIdentityV2Service.handler) repose.start() - reposeLogSearch.awaitByString("Repose ready", 1, 30) + waitUntilReposeIsReady() fakeIdentityV2Service.admin_token = UUID.randomUUID().toString() } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/datastore/RemoteDatastoreServiceTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/datastore/RemoteDatastoreServiceTest.groovy index b80b660268d..2624d5ff2a4 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/datastore/RemoteDatastoreServiceTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/datastore/RemoteDatastoreServiceTest.groovy @@ -95,7 +95,7 @@ class RemoteDatastoreServiceTest extends Specification { reposeValveLauncher.configurationProvider.applyConfigs("features/services/datastore/remote", params) reposeValveLauncher.configurationProvider.applyConfigs("features/services/datastore/remote/$type", params) - reposeValveLauncher.start(false, false, "repose", type) + reposeValveLauncher.start(false, "repose", type) return [reposeValveLauncher, reposeLogSearch] } diff --git a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/healthcheck/HealthCheckServiceTest.groovy b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/healthcheck/HealthCheckServiceTest.groovy index a178e43865a..38228461f27 100644 --- a/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/healthcheck/HealthCheckServiceTest.groovy +++ b/repose-aggregator/tests/functional-tests/src/integrationTest/groovy/features/services/healthcheck/HealthCheckServiceTest.groovy @@ -33,7 +33,7 @@ class HealthCheckServiceTest extends ReposeValveTest { repose.configurationProvider.applyConfigs("common", params) repose.configurationProvider.applyConfigs("features/core/proxy", params) repose.configurationProvider.applyConfigs("features/services/datastore/badconfig", params) - repose.start(true, false, "repose", "node1") + repose.start(false, "repose", "node1") repose.waitForDesiredResponseCodeFromUrl(reposeEndpoint, [503], 120) }