forked from eclipse-tractusx/item-relationship-service
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/tri 387 load and performance tests #199
Merged
ds-jhartmann
merged 9 commits into
main
from
feature/TRI-387-Load-and-Performance-Tests
Mar 16, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4fa77ae
feat(load-test):[TRI-387] Add gatling load test module
ds-jhartmann 636f497
feat(load-test):[TRI-387] Add JMeter test scenario
ds-jhartmann 84718f9
feat(load-test):[TRI-387] Add GitHub Action for load tests
ds-jhartmann 93bbf55
feat(load-test):[TRI-387] Adjust Env var names
ds-jhartmann 01536bf
feat(load-test):[TRI-387] Update globalAssetId for load test
ds-jhartmann a37cfef
feat(workflows):[TRI-387] Add step to upload load test report
ds-jhartmann 30459d2
feat(load-test):[TRI-387] Remove unnecessary load test steps
ds-jhartmann ca582a7
feat(load-test):[TRI-387] Remove JMeter after decision to use Gatling
ds-jhartmann 293a1fb
feat(Dockerfile):[TRI-387] Add missing module
ds-jhartmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: IRS Load Test | ||
|
||
on: | ||
workflow_dispatch: # Trigger manually | ||
inputs: | ||
irs-host: | ||
type: choice | ||
description: IRS environment to test | ||
default: 'https://irs-full.dev.demo.catena-x.net' | ||
required: true | ||
options: | ||
- 'https://irs-full.dev.demo.catena-x.net' | ||
- 'https://irs.dev.demo.catena-x.net' | ||
- 'https://irs.int.demo.catena-x.net' | ||
test-cycles: | ||
type: string | ||
description: Number of Test Cycles | ||
default: '20' | ||
required: false | ||
|
||
jobs: | ||
gatling-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run Gatling tests | ||
env: | ||
KEYCLOAK_HOST: ${{ secrets.KEYCLOAK_OAUTH2_CLIENT_TOKEN_URI }} | ||
KEYCLOAK_CLIENT_SECRET: ${{ secrets.KEYCLOAK_OAUTH2_CLIENT_ID }} | ||
KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_OAUTH2_CLIENT_ID }} | ||
IRS_HOST: ${{ github.event.inputs.irs-host || 'https://irs-full.dev.demo.catena-x.net' }} | ||
TEST_CYCLES: ${{ github.event.inputs.test-cycles || '20' }} | ||
run: | | ||
mvn gatling:test -pl irs-load-tests | ||
|
||
- name: Archive Report | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: gatling-report | ||
path: irs-load-tests/target/gatling/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.tractusx.irs</groupId> | ||
<artifactId>irs-parent-spring-boot</artifactId> | ||
<version>${revision}</version> | ||
<relativePath>../irs-parent-spring-boot</relativePath> | ||
</parent> | ||
|
||
<artifactId>irs-load-tests</artifactId> | ||
|
||
<name>IRS Load Tests</name> | ||
<description>Item Relationship Service Load Tests</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.gatling.highcharts</groupId> | ||
<artifactId>gatling-charts-highcharts</artifactId> | ||
<version>3.9.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.gatling</groupId> | ||
<artifactId>gatling-maven-plugin</artifactId> | ||
<version>4.3.0</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
59 changes: 59 additions & 0 deletions
59
irs-load-tests/src/test/java/org/eclipse/tractusx/irs/IRSLoadTestSimulation.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,59 @@ | ||
package org.eclipse.tractusx.irs; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.RawFileBody; | ||
import static io.gatling.javaapi.core.CoreDsl.StringBody; | ||
import static io.gatling.javaapi.core.CoreDsl.atOnceUsers; | ||
import static io.gatling.javaapi.core.CoreDsl.jsonPath; | ||
import static io.gatling.javaapi.core.CoreDsl.scenario; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
import static io.gatling.javaapi.http.HttpDsl.status; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import io.gatling.javaapi.core.ScenarioBuilder; | ||
import io.gatling.javaapi.core.Simulation; | ||
import io.gatling.javaapi.http.HttpProtocolBuilder; | ||
|
||
public class IRSLoadTestSimulation extends Simulation { | ||
{ | ||
final String keycloak_host = System.getenv("KEYCLOAK_HOST"); | ||
final String clientSecret = System.getenv("KEYCLOAK_CLIENT_SECRET"); | ||
final String clientId = System.getenv("KEYCLOAK_CLIENT_ID"); | ||
String body = "grant_type=client_credentials&client_id=" + clientId + "&client_secret=" + clientSecret; | ||
final String irsUrl = System.getenv("IRS_HOST"); | ||
final int testCycles = Integer.parseInt(System.getenv("TEST_CYCLES")); | ||
|
||
Map<CharSequence, String> headers_0 = new HashMap<>(); | ||
headers_0.put("Content-Type", "application/x-www-form-urlencoded"); | ||
|
||
HttpProtocolBuilder httpProtocol = http.baseUrl(irsUrl) | ||
.acceptHeader("*/*"); | ||
|
||
Map<CharSequence, String> headers_1 = new HashMap<>(); | ||
headers_1.put("Authorization", "Bearer #{access_token}"); | ||
headers_1.put("Content-Type", "application/json"); | ||
|
||
ScenarioBuilder scn = scenario("IRS Load Test") | ||
.exec(http("Get access token") | ||
.post(keycloak_host) | ||
.body(StringBody(body)) | ||
.asFormUrlEncoded() | ||
.headers(headers_0) | ||
.check(status().is(200)) | ||
.check(jsonPath( | ||
"$.access_token") | ||
.saveAs("access_token"))) | ||
.exec(http("Start Job") | ||
.post(irsUrl+"/irs/jobs") | ||
.headers(headers_1) | ||
.body(RawFileBody("org/eclipse/tractusx/irs/loadtest/IRS-start-job-body.json")) | ||
.check(jsonPath("$.id") | ||
.saveAs("id"))) | ||
.exec(http("Get Job") | ||
.get("/irs/jobs/#{id}?returnUncompletedJob=true") | ||
.headers(headers_1)); | ||
|
||
setUp(scn.injectOpen(atOnceUsers(testCycles))).protocols(httpProtocol); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
irs-load-tests/src/test/resources/org/eclipse/tractusx/irs/loadtest/IRS-start-job-body.json
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,10 @@ | ||
{ | ||
"bomLifecycle": "asBuilt", | ||
"aspects": [ | ||
"AssemblyPartRelationship" | ||
], | ||
"depth": 10, | ||
"direction": "downward", | ||
"collectAspects": true, | ||
"globalAssetId": "urn:uuid:d3c0bf85-d44f-47c5-990d-fec8a36065c6" | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException