Compare commits

...

11 Commits

Author SHA1 Message Date
Chris Richardson
a15be35063 asD 2025-05-12 18:09:43 -04:00
Chris Richardson
03688d481d Asd 2022-05-20 12:49:43 -04:00
Chris Richardson
a1f1e93c4b Asd 2022-05-20 09:46:24 -04:00
Chris Richardson
832b1b76d7 update python client.
Updated client to work with locust 1.2
2022-04-18 15:34:44 -04:00
Chris Richardson
eb6c0c2803 Merge pull request #4 from aci/add_docs
Add basic docs.
2020-09-09 19:57:41 -04:00
Chris Richardson
13686acc96 Add basic docs.
Add basic docs
2020-09-09 19:55:22 -04:00
Chris Richardson
df5db9b98b Merge pull request #3 from crichardson/add_rio3
Change path for installing tests
2020-08-11 19:23:33 -04:00
Chris Richardson
2c4c2b90b9 Change path for installing tests
Due to user of the container we will drop it in the homedir
2020-08-11 19:22:11 -04:00
Chris Richardson
5c73ff73f0 Merge pull request #2 from crichardson/add_rio2
Fix rio build.
2020-08-11 19:10:59 -04:00
Chris Richardson
3bf6250b17 Fix rio build.
Forgot to mkdir first
2020-08-11 19:09:38 -04:00
Chris Richardson
87c51bc366 Merge pull request #1 from crichardson/add_rio
Add a rio job for building containers
2020-08-11 18:57:36 -04:00
5 changed files with 78 additions and 23 deletions

41
.gitea/gitea-ci.yaml Normal file
View 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"

View File

@@ -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
View 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.

View File

@@ -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

View File

@@ -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]