Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
notdryft committed Oct 17, 2024
1 parent 6da688a commit 86c7b20
Show file tree
Hide file tree
Showing 44 changed files with 2,561 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/gatling"
commit-message:
prefix: "chore"
schedule:
interval: "weekly"
day: "sunday"
ignore:
- dependency-name: "com.google.protobuf:protoc"
versions: ['>= 4'] # https://github.com/grpc/grpc-java/issues/11015
- package-ecosystem: "gradle"
directory: "/server"
commit-message:
prefix: "chore"
groups:
grpc:
patterns:
- "io.grpc:*"
schedule:
interval: "weekly"
day: "sunday"
ignore:
- dependency-name: "com.google.protobuf:protoc"
versions: ['>= 4'] # https://github.com/grpc/grpc-java/issues/11015
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
push:
branches:
- main
pull_request:

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

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
JAVA_OPTS: "-Xmx4G"
SBT_OPTS: "-Dsbt.ci=true"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'

- name: Build Gatling
working-directory: gatling
run: ./mvnw --batch-mode -Dstyle.color=always --no-transfer-progress test-compile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
.certs/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Gatling gRPC training

This training project contains:

- A [Java with Maven Gatling gRPC project](https://github.com/gatling/gatling-grpc-training/tree/main/gatling)
- A [training server](https://github.com/gatling/gatling-grpc-training/tree/main/server)

Check each project for their usage details.

## Certificates

The script we used to generate all the certificates present in the training projects can be found
[here](https://github.com/gatling/gatling-grpc-training/blob/main/certificates.sh).
76 changes: 76 additions & 0 deletions certificates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

set -e
[[ "$DEBUG" ]] && set -x

CA_CN=gatling-grpc-training-test-ca

CLIENT_CN_PREFIX=gatling-grpc-training-test-client
SERVER_CN=gatling-grpc-training-test-server

certs_dir=.certs
mkdir -p $certs_dir
rm -rf "${certs_dir:?}/*"

server_dir=server/src/main
client_dir=gatling/src/test

## Certificate Authority

# Generate CA private key
openssl genrsa -passout pass:1111 -des3 -out $certs_dir/ca.key 4096

# Generate CA certificate
openssl req \
-new -x509 \
-key $certs_dir/ca.key -out $certs_dir/ca.crt \
-days 3650 -passin pass:1111 \
-subj "/C=FR/ST=Ile-de-France/L=Paris/O=Gatling gRPC Training/OU=IT/CN=$CA_CN"

## Clients certificates

for i in {1..5}; do
# Generate the client private key
openssl genrsa -out $certs_dir/client$i.key 4096

# Generate a Certificate Signing Request for the client
openssl req -new \
-key $certs_dir/client$i.key \
-out $certs_dir/client$i.csr \
-subj "/C=FR/ST=Ile-de-France/L=Paris/O=Gatling gRPC Training/OU=IT/CN=${CLIENT_CN_PREFIX}$i"
#openssl req -text -noout -verify -in $certs_dir/client$i.csr

# Sign the request with the CA
openssl x509 -req \
-CA $certs_dir/ca.crt -CAkey $certs_dir/ca.key \
-in $certs_dir/client$i.csr -out $certs_dir/client$i.crt \
-days 3650 -passin pass:1111
openssl x509 -in $certs_dir/client$i.crt -noout -serial
openssl verify -verbose -CAfile $certs_dir/ca.crt $certs_dir/client$i.crt
done

## Server certificate

# Generate the server private key
openssl genrsa -out $certs_dir/server.key 4096

# Generate a Certificate Signing Request for the server
openssl req -new \
-key $certs_dir/server.key -out $certs_dir/server.csr \
-subj "/C=FR/ST=Ile-de-France/L=Paris/O=Gatling gRPC Training/OU=IT/CN=$SERVER_CN"
#openssl req -text -noout -verify -in $certs_dir/server.csr

# Sign the request with the CA
openssl x509 -req \
-CA $certs_dir/ca.crt -CAkey $certs_dir/ca.key \
-in $certs_dir/server.csr -out $certs_dir/server.crt \
-days 3650 -passin pass:1111
openssl x509 -in $certs_dir/server.crt -noout -serial
openssl verify -verbose -CAfile $certs_dir/ca.crt $certs_dir/server.crt

# Copy certificate and private key into the different projects

cp $certs_dir/ca.key $certs_dir/ca.crt $certs_dir/server.key $certs_dir/server.crt $server_dir/resources/certs

rm $client_dir/resources/certs/*
cp $certs_dir/ca.crt $certs_dir/client*.key $certs_dir/client*.crt $client_dir/resources/certs
8 changes: 8 additions & 0 deletions gatling/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.bsp/
.idea/
.metals/
target/

*.iml

.mvn/wrapper/*.jar
18 changes: 18 additions & 0 deletions gatling/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
40 changes: 40 additions & 0 deletions gatling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Gatling gRPC - Java with Maven training project

This folder contain a Maven project that shows how to use the Gatling gRPC DSL with Java.

If you want to run the scenarios over a working server, make sure to check the [server training project](../server)
beforehand.

## Usage

Both scenarios use a system property called `grpc.scenario` as a gRPC method switch. A value of `unary` is used to run
the scenario which implements a gRPC scenario using a unary method, and so on.

### Greeting simulation

The system property `grpc.scenario` can take the following values:

- unary
- deadlines

To run the Greeting simulation, use the `gatling:test` Maven goal:

```console
mvn gatling:test -Dgrpc.scenario=unary -Dgatling.simulationClass=io.gatling.grpc.training.GreetingSimulation
```

### Calculator simulation

The system property `grpc.scenario` can take the following values:

- unary
- serverStreaming
- clientStreaming
- bidirectionalStreaming
- deadlines

To run the Calculator simulation, use the `gatling:test` Maven goal:

```console
mvn gatling:test -Dgrpc.scenario=unary -Dgatling.simulationClass=io.gatling.grpc.training.CalculatorSimulation
```
Loading

0 comments on commit 86c7b20

Please sign in to comment.