forked from eclipse-tractusx/item-relationship-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from catenax-ng/feature/TRI-387-Load-and-Perf…
…ormance-Tests Feature/tri 387 load and performance tests
- Loading branch information
Showing
6 changed files
with
148 additions
and
0 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
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