-
Notifications
You must be signed in to change notification settings - Fork 1k
Make backend integration test endpoints configurable #27664
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
base: archive_IS-7.3
Are you sure you want to change the base?
Changes from all commits
3ce88a2
87e5f3e
20342c3
e350998
d9ade3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,181 @@ | ||||||||||||||||||||
| # ✅ FIXED: External Server Testing Now Works | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The issue was that the `automation.config.file` system property was **NOT being passed to the test framework** by Maven's surefire plugin. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🔧 What Was Fixed | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Problem | ||||||||||||||||||||
| - The `-Dautomation.config.file=automation-external.xml` parameter was being passed to Maven but NOT to the test framework | ||||||||||||||||||||
| - The pom.xml surefire configuration didn't include this property in `<systemProperties>` | ||||||||||||||||||||
| - Result: Framework always used default `automation.xml` which tries to auto-start the server | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Solution | ||||||||||||||||||||
| 1. **Updated pom.xml** - Added `automation.config.file` system property to surefire plugin in BOTH profiles: | ||||||||||||||||||||
| - `integration` profile (default) | ||||||||||||||||||||
| - `testgrid` profile | ||||||||||||||||||||
| - Property defaults to `automation.xml` for backward compatibility | ||||||||||||||||||||
| - Can be overridden at runtime | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 2. **Created NoOpServerExtension** - New server extension that disables lifecycle management | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 3. **Updated automation-external.xml** - Uses `NoOpServerExtension` instead of `IdentityServerExtension` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🚀 How to Run Tests Against External IS | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Step 1: Ensure External IS is Running | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| # On your external machine or locally on different port | ||||||||||||||||||||
| cd /path/to/wso2is-7.3.0-rc1/bin | ||||||||||||||||||||
| ./wso2server.sh | ||||||||||||||||||||
| # Or on custom port: | ||||||||||||||||||||
| ./wso2server.sh -Dcom.sun.jndi.ldap.connect.pool=false -Dcom.sun.jndi.ldap.connect.timeout=5000 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Step 2: Run Tests with External Configuration | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Option A: External IS on Default Port (localhost:9853) | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| cd /Users/hasanthi/Applications/Source/Product_IS/product-is | ||||||||||||||||||||
| mvn -pl modules/integration/tests-integration/tests-backend test \ | ||||||||||||||||||||
| -Dautomation.config.file=automation-external.xml \ | ||||||||||||||||||||
| -Dintegration.test.is.host=localhost \ | ||||||||||||||||||||
| -Dintegration.test.is.https.port=9853 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Option B: External IS on Different Host/Port | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| mvn -pl modules/integration/tests-integration/tests-backend test \ | ||||||||||||||||||||
| -Dautomation.config.file=automation-external.xml \ | ||||||||||||||||||||
| -Dintegration.test.is.host=192.168.1.100 \ | ||||||||||||||||||||
| -Dintegration.test.is.https.port=9445 \ | ||||||||||||||||||||
| -Dintegration.test.sample.host=192.168.1.100 \ | ||||||||||||||||||||
| -Dintegration.test.sample.http.port=8490 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #### Option C: Run Single Test Suite | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| mvn -pl modules/integration/tests-integration/tests-backend test \ | ||||||||||||||||||||
| -Dautomation.config.file=automation-external.xml \ | ||||||||||||||||||||
| -Dtest=SAMLSSOTestCase \ | ||||||||||||||||||||
| -Dintegration.test.is.host=external-is.example.com \ | ||||||||||||||||||||
| -Dintegration.test.is.https.port=9853 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🎯 Key Points | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### ✅ DO THIS | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| mvn test -Dautomation.config.file=automation-external.xml ... | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
| - ✅ `mvn test` - Runs tests only | ||||||||||||||||||||
| - ✅ `mvn clean test` - Clean + run tests | ||||||||||||||||||||
| - ✅ `-Dautomation.config.file=automation-external.xml` - Use external config | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### ❌ DON'T DO THIS | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| mvn clean install -Dautomation.config.file=automation-external.xml | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
| - ❌ `mvn clean install` - Does NOT run tests (install goal doesn't execute tests) | ||||||||||||||||||||
| - ❌ Tests won't run, so the parameter is ignored | ||||||||||||||||||||
|
Comment on lines
+74
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Yes, in Apache Maven's default lifecycle, running mvn clean install executes the test phase (and thus Surefire tests) by default unless explicitly skipped (e.g., via -DskipTests or -Dmaven.test.skip=true). The clean phase runs the clean lifecycle (deleting the target directory). Then install runs the default lifecycle up to and including the install phase, which includes earlier phases in sequence: validate, compile, test, package, verify, install. The test phase is explicitly listed before package and install. The Maven Surefire Plugin's surefire:test goal is bound by default to the test phase, executing unit tests (JUnit/TestNG) and generating reports in target/surefire-reports unless skipped. Citations:
Correct the The statement on Line 78 is inaccurate. By default in Apache Maven, 🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 📋 System Properties Reference | ||||||||||||||||||||
|
|
||||||||||||||||||||
| | Parameter | Default | Purpose | | ||||||||||||||||||||
| |-----------|---------|---------| | ||||||||||||||||||||
| | `automation.config.file` | `automation.xml` | Which automation config to use | | ||||||||||||||||||||
| | `integration.test.is.host` | `localhost` | External IS hostname | | ||||||||||||||||||||
| | `integration.test.is.https.port` | `9853` | External IS HTTPS port | | ||||||||||||||||||||
| | `integration.test.sample.host` | `localhost` | Sample app hostname | | ||||||||||||||||||||
| | `integration.test.sample.http.port` | `8490` | Sample app HTTP port | | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 📝 Complete Example | ||||||||||||||||||||
|
|
||||||||||||||||||||
| **Running all backend integration tests against external IS on 192.168.1.10:9445** | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| cd /Users/hasanthi/Applications/Source/Product_IS/product-is | ||||||||||||||||||||
|
|
||||||||||||||||||||
| mvn -pl modules/integration/tests-integration/tests-backend test \ | ||||||||||||||||||||
| -Dautomation.config.file=automation-external.xml \ | ||||||||||||||||||||
| -Dintegration.test.is.host=192.168.1.10 \ | ||||||||||||||||||||
| -Dintegration.test.is.https.port=9445 \ | ||||||||||||||||||||
| -Dintegration.test.sample.host=192.168.1.10 \ | ||||||||||||||||||||
| -Dintegration.test.sample.http.port=8490 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🔍 How to Verify It's Working | ||||||||||||||||||||
|
|
||||||||||||||||||||
| When tests start, you should see: | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
| [INFO] NoOpServerExtension: Initiated. No server lifecycle management will be performed. | ||||||||||||||||||||
| [INFO] NoOpServerExtension: onExecutionStart() - No action taken. Expecting external IS to be running. | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Not this (which means it's trying to auto-start): | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
| ERROR [org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor] - Error on archive extraction | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
Comment on lines
+109
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language identifiers to fenced code blocks. The fenced blocks starting at Line 109 and Line 115 should include a language label to satisfy MD040. Suggested doc update-```
+```text
[INFO] NoOpServerExtension: Initiated. No server lifecycle management will be performed.
[INFO] NoOpServerExtension: onExecutionStart() - No action taken. Expecting external IS to be running.@@ 📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 109-109: Fenced code blocks should have a language specified (MD040, fenced-code-language) [warning] 115-115: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 📦 Files Modified | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 1. **pom.xml** (lines 76-114, 179-217) | ||||||||||||||||||||
| - Added `automation.config.file` system property to surefire | ||||||||||||||||||||
| - Applied to both `integration` and `testgrid` profiles | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 2. **automation-external.xml** (existing) | ||||||||||||||||||||
| - Uses `NoOpServerExtension` instead of `IdentityServerExtension` | ||||||||||||||||||||
| - Keeps `UserPopulateExtension` for user creation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 3. **README-EXTERNAL-TESTING.md** (existing) | ||||||||||||||||||||
| - Usage examples and troubleshooting guide | ||||||||||||||||||||
| - Clarification on Maven goals | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🐛 If Still Having Issues | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 1. **Verify automation-external.xml exists** | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| ls -la modules/integration/tests-integration/tests-backend/src/test/resources/automation-external.xml | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 2. **Check IS is accessible** | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| curl -k https://localhost:9853/carbon/ 2>&1 | grep -i "carbon\|error" | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 3. **Ensure using 'mvn test' goal** (not 'mvn clean install') | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| mvn test -Dautomation.config.file=automation-external.xml ... | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 4. **Check pom.xml was updated correctly** | ||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| grep -A 3 "automation.config.file" modules/integration/tests-integration/tests-backend/pom.xml | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🎓 Technical Details | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### How It Works | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 1. **Maven Surefire Plugin** passes system properties to test JVM | ||||||||||||||||||||
| 2. **`automation.config.file` property** tells the automation framework which config file to load | ||||||||||||||||||||
| 3. **automation-external.xml** specifies to use `NoOpServerExtension` | ||||||||||||||||||||
| 4. **NoOpServerExtension** overrides lifecycle methods to do nothing | ||||||||||||||||||||
| 5. **Tests run** against your pre-running IS instance | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Why This Approach | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - ✅ Backward compatible - defaults to `automation.xml` | ||||||||||||||||||||
| - ✅ No code changes to test files | ||||||||||||||||||||
| - ✅ Runtime configuration via system properties | ||||||||||||||||||||
| - ✅ Supports both internal and external testing | ||||||||||||||||||||
| - ✅ Clear separation of concerns (DefaultServerExtension vs NoOpServerExtension) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## 🚀 Ready to Test! | ||||||||||||||||||||
|
|
||||||||||||||||||||
| You can now run integration tests against ANY external IS instance by: | ||||||||||||||||||||
| 1. Starting your IS instance | ||||||||||||||||||||
| 2. Running tests with `-Dautomation.config.file=automation-external.xml` parameter | ||||||||||||||||||||
| 3. Configuring host/port with system properties | ||||||||||||||||||||
|
|
||||||||||||||||||||
| No code changes needed! 🎉 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright (c) 2024, WSO2 Inc. (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.identity.integration.common.extension.server; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * No-Op Server Extension for testing against external/pre-running IS instances. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * This extension overrides lifecycle methods but does nothing - it disables all server | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * lifecycle management (start/stop/extraction). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Use this when running tests against an external IS instance that's already running. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Configuration: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * <class> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * <name>org.wso2.identity.integration.common.extension.server.NoOpServerExtension</name> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * </class> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * System Properties: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * -Dintegration.test.is.host=<your-external-is-host> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * -Dintegration.test.is.https.port=<your-external-is-https-port> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * -Dintegration.test.sample.host=<your-sample-app-host> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * -Dintegration.test.sample.http.port=<your-sample-app-http-port> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Escape angle-bracket placeholders in Javadoc examples. On Line 34–42, raw Suggested doc fix- * Configuration:
- * <class>
- * <name>org.wso2.identity.integration.common.extension.server.NoOpServerExtension</name>
- * </class>
+ * Configuration:
+ * {`@code`
+ * <class>
+ * <name>org.wso2.identity.integration.common.extension.server.NoOpServerExtension</name>
+ * </class>
+ * }
*
* System Properties:
- * -Dintegration.test.is.host=<your-external-is-host>
- * -Dintegration.test.is.https.port=<your-external-is-https-port>
- * -Dintegration.test.sample.host=<your-sample-app-host>
- * -Dintegration.test.sample.http.port=<your-sample-app-http-port>
+ * -Dintegration.test.is.host=<your-external-is-host>
+ * -Dintegration.test.is.https.port=<your-external-is-https-port>
+ * -Dintegration.test.sample.host=<your-sample-app-host>
+ * -Dintegration.test.sample.http.port=<your-sample-app-http-port>As per coding guidelines, provide concise, actionable feedback focused on correctness and best practices. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| public class NoOpServerExtension extends CarbonServerExtension { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| private Logger log = LoggerFactory.getLogger(NoOpServerExtension.class); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||||
| public void initiate() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Override to prevent parent CarbonServerExtension from initializing server management | ||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("NoOpServerExtension: Initiated. No server lifecycle management will be performed."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||||
| public void onExecutionStart() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Override to prevent parent CarbonServerExtension from starting server | ||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("NoOpServerExtension: onExecutionStart() - No action taken. Expecting external IS to be running."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||||||||||||||||||||
| public void onExecutionFinish() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Override to prevent parent CarbonServerExtension from stopping server | ||||||||||||||||||||||||||||||||||||||||||||||||||
| log.info("NoOpServerExtension: onExecutionFinish() - No action taken. External IS will remain running."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use repository-relative paths in examples.
The hardcoded local paths on Line 38 and Line 96 are user-specific. Replace them with generic/project-relative paths to keep docs portable.
Suggested doc update
Also applies to: 96-99
🤖 Prompt for AI Agents