Skip to content

Commit

Permalink
Merge pull request #199 from catenax-ng/feature/TRI-387-Load-and-Perf…
Browse files Browse the repository at this point in the history
…ormance-Tests

Feature/tri 387 load and performance tests
  • Loading branch information
ds-jhartmann authored Mar 16, 2023
2 parents 9532385 + 293a1fb commit 0ab27c9
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/irs-load-test.yaml
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/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COPY irs-testing irs-testing
COPY irs-report-aggregate irs-report-aggregate
COPY cucumber-tests cucumber-tests
COPY docs docs
COPY irs-load-tests irs-load-tests

# the --mount option requires BuildKit.
RUN --mount=type=cache,target=/root/.m2 mvn -B clean package -pl :$BUILD_TARGET -am -DskipTests
Expand Down
36 changes: 36 additions & 0 deletions irs-load-tests/pom.xml
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>
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);
}
}
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"
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<module>irs-report-aggregate</module>
<module>cucumber-tests</module>
<module>docs</module>
<module>irs-load-tests</module>
</modules>

<properties>
Expand Down

0 comments on commit 0ab27c9

Please sign in to comment.