-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move server restart tests to a separate module
- Loading branch information
1 parent
b65c7c3
commit 28b9989
Showing
218 changed files
with
38,407 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
862 changes: 862 additions & 0 deletions
862
modules/integration/tests-integration/tests-restart/pom.xml
Large diffs are not rendered by default.
Oops, something went wrong.
230 changes: 230 additions & 0 deletions
230
...t/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
...a/org/wso2/am/integration/tests/api/lifecycle/APIManagerConfigurationChangeTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.am.integration.tests.api.lifecycle; | ||
|
||
import org.testng.annotations.AfterTest; | ||
import org.testng.annotations.BeforeTest; | ||
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants; | ||
import org.wso2.carbon.automation.engine.context.AutomationContext; | ||
import org.wso2.carbon.automation.engine.context.TestUserMode; | ||
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Deploy jaxrs_basic webApp and monitoring webApp required to run tests | ||
* jaxrs_basic - Provides rest backend to run tests | ||
* <p/> | ||
* APIStatusMonitor - Can be used to retrieve API deployment status in worker and manager nodes | ||
*/ | ||
public class APIManagerConfigurationChangeTestSuite extends APIManagerLifecycleBaseTest { | ||
|
||
private AutomationContext superTenantKeyManagerContext; | ||
private ServerConfigurationManager serverConfigurationManager; | ||
|
||
@BeforeTest(alwaysRun = true) | ||
public void configureEnvironment() throws Exception { | ||
|
||
superTenantKeyManagerContext = new AutomationContext(APIMIntegrationConstants.AM_PRODUCT_GROUP_NAME, | ||
APIMIntegrationConstants.AM_KEY_MANAGER_INSTANCE, | ||
TestUserMode.SUPER_TENANT_ADMIN); | ||
serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); | ||
serverConfigurationManager.applyConfigurationWithoutRestart(new File(getAMResourceLocation() | ||
+ File.separator + "configFiles" + File.separator + "fileBaseAPIS" + File.separator + | ||
"deployment.toml")); | ||
serverConfigurationManager.restartGracefully(); | ||
} | ||
|
||
|
||
@AfterTest(alwaysRun = true) | ||
public void restoreConfiguration() throws Exception { | ||
|
||
serverConfigurationManager = new ServerConfigurationManager(superTenantKeyManagerContext); | ||
serverConfigurationManager.restoreToLastConfiguration(); | ||
} | ||
|
||
} |
675 changes: 675 additions & 0 deletions
675
...rc/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
...-restart/src/test/java/org/wso2/am/integration/tests/listener/APIMAlterSuiteListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.am.integration.tests.listener; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.testng.IAlterSuiteListener; | ||
import org.testng.xml.XmlClass; | ||
import org.testng.xml.XmlSuite; | ||
import org.testng.xml.XmlTest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class APIMAlterSuiteListener implements IAlterSuiteListener { | ||
@Override | ||
public void alter(List<XmlSuite> list) { | ||
String testsToRunCommaSeparated = System.getenv("PRODUCT_APIM_TESTS"); | ||
String testClassesToRunCommaSeparated = System.getenv("PRODUCT_APIM_TEST_CLASSES"); | ||
String testGroupsToRunCommaSeparated = System.getenv("PRODUCT_APIM_TEST_GROUPS"); | ||
if (StringUtils.isBlank(testsToRunCommaSeparated) && StringUtils.isBlank(testClassesToRunCommaSeparated) | ||
&& StringUtils.isBlank(testGroupsToRunCommaSeparated)) { | ||
return; | ||
} | ||
String[] enabledTests = new String[]{}; | ||
String[] enabledTestClasses = new String[]{}; | ||
String[] enableTestGroups = new String[]{}; | ||
if (!StringUtils.isBlank(testsToRunCommaSeparated)) { | ||
enabledTests = testsToRunCommaSeparated.split(","); | ||
} | ||
if (!StringUtils.isBlank(testClassesToRunCommaSeparated)) { | ||
enabledTestClasses = testClassesToRunCommaSeparated.split(","); | ||
} | ||
if (!StringUtils.isBlank(testGroupsToRunCommaSeparated)) { | ||
enableTestGroups = testGroupsToRunCommaSeparated.split(","); | ||
} | ||
for (XmlSuite suite: list) { | ||
if ("ApiManager-features-test-suite".equals(suite.getName())) { | ||
List<XmlTest> newXMLTests = new ArrayList<>(); | ||
for (XmlTest xmlTest: suite.getTests()) { | ||
// process PRODUCT_APIM_TESTS to select xml tests to run | ||
boolean xmlTestAdded = false; | ||
for (String enabledTest: enabledTests) { | ||
if (enabledTest.trim().equals(xmlTest.getName().trim())) { | ||
xmlTestAdded = true; | ||
newXMLTests.add(xmlTest); | ||
} | ||
} | ||
// Process PRODUCT_APIM_TEST_GROUPS to select xml tests to run. | ||
for (String enabledTestGroup: enableTestGroups) { | ||
if (enabledTestGroup.trim().equals(getTestGroup(xmlTest))) { | ||
xmlTestAdded = true; | ||
newXMLTests.add(xmlTest); | ||
} | ||
} | ||
|
||
List<XmlClass> selectedXmlClassList = new ArrayList<>(); | ||
// process PRODUCT_APIM_TEST_CLASSES to select xml test classes to run | ||
for (String enabledTestClass : enabledTestClasses) { | ||
List<XmlClass> xmlClassList = xmlTest.getClasses(); | ||
for (int i = 0; i < xmlClassList.size(); i++) { | ||
if (enabledTestClass.trim().equals(xmlClassList.get(i).getName().trim())) { | ||
// add first XML test class of the XML test always if any of the test xml class is | ||
// selected. | ||
if (i != 0) { | ||
selectedXmlClassList.add(xmlClassList.get(0)); | ||
} | ||
selectedXmlClassList.add(xmlClassList.get(i)); | ||
} | ||
} | ||
} | ||
// if any xml class is selected in the particular xml test, we need to run the xml test if it is | ||
// not added to the suite to run | ||
if (selectedXmlClassList.size() > 0) { | ||
xmlTest.setClasses(selectedXmlClassList); | ||
// when the xml is not added already from the PRODUCT_APIM_TESTS list, need to add them. | ||
if (!xmlTestAdded) { | ||
newXMLTests.add(xmlTest); | ||
} | ||
} | ||
} | ||
suite.setTests(newXMLTests); | ||
} | ||
} | ||
} | ||
|
||
private String getTestGroup(XmlTest xmlTest) { | ||
|
||
return xmlTest.getParameter("group"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...start/src/test/java/org/wso2/am/integration/tests/listener/APIMTestExecutionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.am.integration.tests.listener; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.testng.ITestContext; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
import org.wso2.am.integration.tests.workflow.WorkflowApprovalExecutorTest; | ||
|
||
public class APIMTestExecutionListener implements ITestListener { | ||
private static final Log log = LogFactory.getLog(WorkflowApprovalExecutorTest.class); | ||
|
||
private long startTime; | ||
|
||
@Override | ||
public void onStart(ITestContext iTestContext) { | ||
log.info("Starting test group - " + iTestContext.getCurrentXmlTest().getName()); | ||
startTime = System.currentTimeMillis() / 1000; | ||
} | ||
|
||
@Override | ||
public void onFinish(ITestContext iTestContext) { | ||
long endTime = System.currentTimeMillis() / 1000; | ||
log.info("Finished test group - " + iTestContext.getCurrentXmlTest().getName() | ||
+ " (Completed in " + (endTime - startTime) + "s)"); | ||
} | ||
|
||
@Override | ||
public void onTestStart(ITestResult iTestResult) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTestSuccess(ITestResult iTestResult) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTestFailure(ITestResult iTestResult) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTestSkipped(ITestResult iTestResult) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.