Compare commits
11 Commits
fcf75b7970
...
a15be35063
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a15be35063 | ||
|
|
03688d481d | ||
|
|
a1f1e93c4b | ||
|
|
832b1b76d7 | ||
|
|
eb6c0c2803 | ||
|
|
13686acc96 | ||
|
|
df5db9b98b | ||
|
|
2c4c2b90b9 | ||
|
|
5c73ff73f0 | ||
|
|
3bf6250b17 | ||
|
|
87c51bc366 |
41
.gitea/gitea-ci.yaml
Normal file
41
.gitea/gitea-ci.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Build And Test
|
||||
run-name: ${{ gitea.actor }} is runs ci pipeline
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
# build:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: https://github.com/actions/checkout@v4
|
||||
# - name: Use Node.js
|
||||
# uses: https://github.com/actions/setup-node@v3
|
||||
# with:
|
||||
# node-version: '18.17'
|
||||
# - run: npm ci
|
||||
# - run: npm run lint
|
||||
# - run: npm run test
|
||||
# - run: npm run build:prod
|
||||
# env:
|
||||
# NODE_OPTIONS: --max_old_space_size=4096
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
# - name: Set up Docker Buildx
|
||||
# uses: https://github.com/docker/setup-buildx-action@v3
|
||||
# with:
|
||||
# config-inline: |
|
||||
# [registry."<my-private-unsecure-git-repository-ip-address>:5000"]
|
||||
# http = true
|
||||
# insecure = true
|
||||
- name: Build and push Docker image
|
||||
uses: https://github.com/docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: "private-registry:5000/python-locust-example:${{gitea.sha}},private-registry:5000/python-locust-example:latest"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM docker.apple.com/piedss/locust:1.1.31
|
||||
FROM docker.apple.com/piedss/locust-2:2.7.0.6
|
||||
|
||||
RUN mkdir -p /usr/local/load_tests/
|
||||
ADD .dist/usr/local/load_tests/locust-example /usr/local/load_tests/locust-example/
|
||||
RUN mkdir -p /home/locust/tests/
|
||||
ADD test_example.py /home/locust/tests/
|
||||
|
||||
32
Readme.md
Normal file
32
Readme.md
Normal file
@@ -0,0 +1,32 @@
|
||||
### What is Locust?
|
||||
|
||||
[Locust io](https://locust.io/)
|
||||
|
||||
It is a load testing framework that allows you to write tests in actual code in your own
|
||||
choice of language.
|
||||
|
||||
#### How do I use Locust in python?
|
||||
|
||||
Locust
|
||||
|
||||
Python is the only official client for the load tests. You can find the [docs](https://docs.locust.io/en/stable/writing-a-locustfile.html#)
|
||||
for writing locustfile aka tests. This most basic example of how to write a test and build it for using it with the
|
||||
[Locust Operator](https://github.pie.apple.com/official-star/repo/tree/main/server/locust-operator).
|
||||
|
||||
#### Files
|
||||
|
||||
[Example Test](https://github.pie.apple.com/aci/python-locust-example/blob/develop/test_example.py)
|
||||
This test creates two tasks that are weighted differently so task foo will be called more often.
|
||||
The tasks will sleep for 1 second and then fire a success or failure.
|
||||
|
||||
[Rio Config](https://github.pie.apple.com/aci/python-locust-example/blob/develop/rio.yaml)
|
||||
This freestyle build will compile the tests and add them to the path the docker build will
|
||||
use to add it to the container.
|
||||
|
||||
[Docker build](https://github.pie.apple.com/aci/python-locust-example/blob/develop/Dockerfile)
|
||||
This will build a container used for load testing in. The key part of this is the dir path that the
|
||||
tests are put into. This will be used in the locust operator config
|
||||
|
||||
[Example Operator config](https://github.pie.apple.com/official-star/repo/blob/main/lib/go/locust-operator/config/samples/test-python.yaml)
|
||||
This example config will run this test for 2 minutes.
|
||||
The testContainer is the container built by the rio container build here.
|
||||
18
rio.yaml
18
rio.yaml
@@ -1,18 +0,0 @@
|
||||
schemaVersion: 2.0
|
||||
|
||||
pipelines:
|
||||
- branchName: develop
|
||||
name: build_container
|
||||
machine:
|
||||
baseImage: docker.apple.com/piedss/locust:1.1.31
|
||||
build:
|
||||
template: freestyle:v4:publish
|
||||
steps:
|
||||
- cp test_example.py .dist/usr/local/load_tests/locust-example/
|
||||
package:
|
||||
version: "0.1.${RIO_BUILD_NUMBER}"
|
||||
dockerfile:
|
||||
- publish:
|
||||
- repo: docker.apple.com/piedss/locust-example-python
|
||||
dockerfilePath: Dockerfile
|
||||
perApplication: false
|
||||
@@ -4,7 +4,7 @@ from locust import events
|
||||
|
||||
|
||||
class MyTaskSet(TaskSet):
|
||||
@task(2)
|
||||
@task(1)
|
||||
def foo(self):
|
||||
start_time = time.time()
|
||||
time.sleep(1)
|
||||
@@ -28,6 +28,6 @@ class MyTaskSet(TaskSet):
|
||||
)
|
||||
|
||||
|
||||
class WebsiteUser(User):
|
||||
class Dummy(User):
|
||||
wait_time = between(2, 5)
|
||||
tasks = [MyTaskSet]
|
||||
|
||||
Reference in New Issue
Block a user