Skip to content

Commit

Permalink
Merge pull request #28 from soramitsu/feature/DOPS-2816/load-tool-ci
Browse files Browse the repository at this point in the history
DOPS-2816: Add iroha2-perf CI
  • Loading branch information
BAStos525 authored Nov 14, 2023
2 parents 7088b5f + 04e8520 commit d38cdf3
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 45 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/iroha2-perf-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: I2-PERF::CI::Publish

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: [master]
workflow_dispatch:
inputs:
GITHUB_IROHA2_BRANCH:
description: "iroha2 repo branch to take the image tag release"
required: false
default: iroha2-stable

env:
IROHA2_RELEASE: ${{ github.event.inputs.GITHUB_IROHA2_BRANCH || 'iroha2-stable' }}

jobs:
registry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Bump version and save the semver tag
uses: anothrNick/github-tag-action@a2c70ae13a881faf2b4953baaa9e49731997ab36
id: tag_id
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: none
- name: Get the release from a branch name
run: |
RELEASE=$(curl -s https://raw.githubusercontent.com/hyperledger/iroha/${{ ENV.IROHA2_RELEASE }}/Cargo.toml \
| sed -n '3p' | sed -e 's/version = "//g' -e 's/"$//' | tr -d '\n')
echo "RELEASE=$RELEASE" >>$GITHUB_ENV
- name: Login to Soramitsu Harbor
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: docker.soramitsu.co.jp
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Build and push iroha2-perf image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
with:
push: true
tags: docker.soramitsu.co.jp/iroha2/iroha2-perf:${{ steps.tag_id.outputs.new_tag }}-${{ env.RELEASE }}
file: Dockerfile
context: .
38 changes: 33 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
FROM maven:3.9.5-eclipse-temurin-11-alpine
FROM maven:3.9.5-eclipse-temurin-11-alpine as builder

RUN apk add wget && \
wget https://github.com/JetBrains/kotlin/releases/download/v1.8.0/kotlin-compiler-1.8.0.zip && \
RUN wget https://github.com/JetBrains/kotlin/releases/download/v1.8.0/kotlin-compiler-1.8.0.zip && \
unzip kotlin-compiler-1.8.0.zip -d /opt && \
rm kotlin-compiler-1.8.0.zip

WORKDIR /app
COPY . /app
RUN mvn clean package
COPY pom.xml ./
COPY ./src ./src
RUN mvn clean package

FROM maven:3.9.5-eclipse-temurin-11-alpine

ENV USER=iroha
ENV UID=1000
ENV GID=1000
ENV MAVEN_CONFIG=/var/maven/.m2
USER root

RUN set -ex && \
addgroup -g $GID $USER && \
adduser \
--disabled-password \
--gecos "" \
--home /app \
--ingroup "$USER" \
--uid "$UID" \
"$USER" && \
mkdir -p $MAVEN_CONFIG && \
chown $USER:$USER -R $MAVEN_CONFIG

WORKDIR /app
COPY --from=builder /app/pom.xml ./
COPY --from=builder /app/target/ ./target/

USER $USER

ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ mvn gatling:test -D gatling.simulationClass=jp.co.soramitsu.load.simulation.Load
-DrampUpTest=20 \
-DduringTest=10 \
-DstepDurationTest=1200

# Image publishing policy
We use a composite tag naming for `iroha2-perf` image. It's constructed as:
`iroha2-perf:<semver-version>-<iroha2-release>`
Bump tag with minor version unless the merge commit message contains #major or #patch.
For more information, take a look to the [reference](https://github.com/anothrNick/github-tag-action#bumping)
Chanhe the iroha2 release value for image tag by running workflow within `dispatch` event and set the value in `GITHUB_IROHA2_BRANCH` variable.
72 changes: 58 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,81 @@ version: "3"
services:
gatling:
container_name: iroha2-perf
restart: unless-stopped
mem_limit: 4G
cpus: 4
build:
context: .
dockerfile: ./Dockerfile
working_dir: /app
read_only: true
tmpfs:
- /tmp
- /app/target/gatling
- /var/log
environment:
MAVEN_CONFIG: /var/maven/.m2
command: >
mvn gatling:test
-Dgatling.simulationClass=jp.co.soramitsu.load.simulation.MaximumSearchSimulation
-DtargetProtocol=
mvn gatling:test
-Duser.home=/var/maven
-Dgatling.simulationClass=jp.co.soramitsu.load.simulation.MaximumSearchSimulation
-DtargetProtocol=https
-DtargetURL=
-DtargetPath=peer-0/api
-DtargetPath=
-DremoteLogin=
-DremotePass=
-DconcurrentUsers=1
-Dtimes=10000
-DeachLevelLasting=15
-DseparatedByRampsLasting=1
-DstartingFrom=0
-DdomainSetUpRampUp=5
-DduringSetUp=120
-DconcurrentUsers=1
-Dtimes=10000
-DeachLevelLasting=15
-DseparatedByRampsLasting=1
-DstartingFrom=0
-DdomainSetUpRampUp=5
-DduringSetUp=120
-DsetUpUsersOnEachDomain=10
networks:
- iroha2-perf-net
volumes:
- gatling-volume:/var/maven/.m2
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
labels:
- 'filebeat.fields.app=iroha2-perf'
- 'filebeat.fields.env=tst'
- 'filebeat.fields.project=iroha2-perf'
- 'filebeat.fields.logtype=iroha2'
- 'filebeat.module=docker'
#healthcheck:

pushgateway:
image: prom/pushgateway:latest
image: prom/pushgateway:v1.6.2
restart: unless-stopped
mem_limit: 256M
cpus: 1
read_only: true
container_name: pushgateway
ports:
- "9091:9091"
networks:
- iroha2-perf-net
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
labels:
- 'filebeat.fields.app=iroha2-push-gw'
- 'filebeat.fields.env=tst'
- 'filebeat.fields.project=iroha2-perf'
- 'filebeat.fields.logtype=iroha2'
- 'filebeat.module=docker'
#healthcheck:

networks:
iroha2-perf-net:
external:
name: iroha2-perf-net
driver: bridge

volumes:
gatling-volume:
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<owner.version>1.0.12</owner.version>
<iroha-java.version>007a9ac</iroha-java.version>
<iroha-java.version>50cb33b</iroha-java.version>
<jackson.versaion>2.14.1</jackson.versaion>
<commons-codec.version>1.15</commons-codec.version>
<lombok.version>1.18.24</lombok.version>
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/jp/co/soramitsu/load/toolbox/Grinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
import java.util.ArrayList;

public class Grinder {
String baseUrl = "http://pushgateway:9091/metrics/job/";
String baseUrl = "http://0.0.0.0:9091/metrics/job/";
URL transactionUrl = new URL(baseUrl + "transaction/");
URL subscriptionUrl = new URL(baseUrl + "subscription/");
URL queryUrl = new URL(baseUrl + "query/");
URL histogramUrl = new URL(baseUrl + "histogram/");
ArrayList<URL> query = new ArrayList<>();




public Grinder() throws MalformedURLException {
cleanUpMetrics();
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/kotlin/jp/co/soramitsu/load/Iroha2SetUp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ class Iroha2SetUp : Wrench13() {

val iroha2SetUpScn = scenario("Iroha2SetUp")
.exec { Session ->
val randomIndex = (0 until peers.size).random()
/*val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
Iroha2Client = buildClient(randomPeer)*/

timer = CustomHistogram.subscriptionToBlockStreamTimer.labels(
"gatling"
, System.getProperty("user.dir").substringAfterLast("/").substringAfterLast("\\")
Expand Down Expand Up @@ -91,9 +92,9 @@ class Iroha2SetUp : Wrench13() {
//accounts on each domain = threads * anotherDevDomainIdList.size * setUpUsersOnEachDomain
repeat(SimulationConfig.simulation.setUpUsersOnEachDomain).on(
exec { Session ->
val randomIndex = (0 until peers.size).random()
/*val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
Iroha2Client = buildClient(randomPeer)*/
timer = CustomHistogram.subscriptionToBlockStreamTimer.labels(
"gatling"
, System.getProperty("user.dir").substringAfterLast("/").substringAfterLast("\\")
Expand All @@ -113,8 +114,8 @@ class Iroha2SetUp : Wrench13() {
val anotherDev = AnotherDev()
anotherDev.anotherDevDomainId = Session.get<DomainId>("domainId")!!
anotherDev.anotherDevAccountId = AccountId(
Name("anotherDev${UUID.randomUUID()}_${UUID.randomUUID()}"),
anotherDev.anotherDevDomainId
anotherDev.anotherDevDomainId,
Name("anotherDev${UUID.randomUUID()}_${UUID.randomUUID()}")
)
anotherDev.anotherDevKeyPair = generateKeyPair()
timer = CustomHistogram.accountRegisterTimer.labels(
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/jp/co/soramitsu/load/TransactionOnly.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class TransactionOnly: Wrench13() {
Session
}
.exec { Session ->
val randomIndex = (0 until peers.size).random()
/*val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
val Iroha2Client: Iroha2Client = buildClient(randomPeer)*/
timer = CustomHistogram.subscriptionToBlockStreamTimer.labels(
"gatling",
System.getProperty("user.dir").substringAfterLast("/").substringAfterLast("\\"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TransferAssetsQueryStatus: Wrench13() {

val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
//val Iroha2Client: Iroha2Client = buildClient(randomPeer)

val transferAssetsQueryStatusScn = CoreDsl.scenario("TransferAssets")
.repeat(SimulationConfig.simulation.attemptsToTransaction)
Expand All @@ -51,7 +51,7 @@ class TransferAssetsQueryStatus: Wrench13() {
.exec { Session ->
val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
Iroha2Client = buildClient(randomPeer)
timer = CustomHistogram.findAssetsByAccountIdQueryTimer.labels(
"gatling"
, System.getProperty("user.dir").substringAfterLast("/").substringAfterLast("\\")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TransferAssetsTransactionStatus: Wrench13() {
}
val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
val Iroha2Client: Iroha2Client = buildClient(randomPeer)
//val Iroha2Client: Iroha2Client = buildClient(randomPeer)


val transferAssetsScn = CoreDsl.scenario("TransferAssets")
.repeat(userRequestCounter)
Expand Down Expand Up @@ -79,7 +80,11 @@ class TransferAssetsTransactionStatus: Wrench13() {
}
}.doIf{ Session -> Session.getBoolean("condition") }
.then(

exec { Session ->
val randomIndex = (0 until peers.size).random()
val randomPeer = peers[randomIndex]
Iroha2Client = buildClient(randomPeer)
timer = CustomHistogram.subscriptionToBlockStreamTimer.labels(
"gatling"
, System.getProperty("user.dir").substringAfterLast("/").substringAfterLast("\\")
Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/jp/co/soramitsu/load/toolbox/Wrench13.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class Wrench13 {

val urls: MutableList<URL> = mutableListOf()

val admin = AccountId("bob".asName(), "wonderland".asDomainId())
val admin = AccountId("wonderland".asDomainId(), "bob".asName())
val adminKeyPair = keyPairFromHex(
"7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0",
"9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e",
Expand All @@ -34,8 +34,10 @@ open class Wrench13 {
var attemptsPersentage: Int = 2
var attempt: Int = -1
var anotherDevDomainIdList: MutableList<DomainId> = mutableListOf()
var Iroha2Client: Iroha2Client = buildClient("peer-0/api")

//lateinit var anotherDevDomainId: DomainId

var pushGateway = PushGateway("0.0.0.0:9091");
lateinit var currentDevAccountId: AccountId
lateinit var currentDevKeyPair: KeyPair
lateinit var currentDevAssetId: AssetId
Expand All @@ -47,8 +49,6 @@ open class Wrench13 {
lateinit var subscription: BlockStreamSubscription
lateinit var timer: Timer



val peers = arrayOf("peer-0/api", "peer-1/api", "peer-2/api", "peer-3/api", "peer-4/api")

fun buildClient(peer : String): Iroha2Client {
Expand All @@ -71,7 +71,6 @@ open class Wrench13 {
eventReadMaxAttempts = 20
)
}
var pushGateway = PushGateway("pushgateway:9091");

fun sendMetricsToPrometheus(histogram: Histogram, job: String) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MaximumSearchSimulation extends Simulation {
setUp(
jp.co.soramitsu.load.SetUp.Companion.apply().injectOpen(OpenInjectionStep.atOnceUsers(1))
.andThen(Iroha2SetUp.Companion.apply().injectOpen(LoadProfiles.setupModel())
.andThen(TransferAssetsQueryStatus.Companion.apply().injectClosed(LoadProfiles.getMaxPerformanceClosedProfile()))
.andThen(TransactionOnly.Companion.apply().injectClosed(LoadProfiles.getMaxPerformanceClosedProfile()))
).andThen(CleanUp.Companion.apply().injectOpen(OpenInjectionStep.atOnceUsers(1)))
).protocols(Protocols.httpProtocol);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>./logs/logFile.log</file>
<file>/var/log/performance-gatling.log</file>
<append>false</append>
<!--set immediateFlush to false for much higher logging throughput-->
<immediateFlush>true</immediateFlush>
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/simulation.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ remoteLogin=iroha2-dev
remotePass=4H7L&KN25%$2jisV8&NTVtiX

#SetUp section
domainSetUpRumpUp=5
duringSetUp=2
setUpUsersOnEachDomain=3
domainSetUpRumpUp=0
duringSetUp=0
setUpUsersOnEachDomain=0

#Load model
rampUpTest=3
Expand Down

0 comments on commit d38cdf3

Please sign in to comment.