Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image publishing #6

Merged
merged 40 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5b3d919
Updated docs and config.
alfredeen Jan 10, 2024
8af2e1a
Small change to instructions.
alfredeen Jan 12, 2024
7dc91f1
Refactored into using abstract base user types. These are implemented…
alfredeen Jan 12, 2024
0b74393
Added an app viewer user
alfredeen Jan 12, 2024
8f96c6f
Work on login to Serve as test user.
alfredeen Jan 16, 2024
a180aeb
Completed authentication methods. Work on user type power user..
alfredeen Jan 16, 2024
991cbe1
Created non-locust module for opening user apps which created k8s pod…
alfredeen Jan 18, 2024
16c6066
More settings and configuration to customize the user app behaviour
alfredeen Jan 18, 2024
82e8720
Better handling of switching between test environments.
alfredeen Jan 19, 2024
8286b6a
Added task to register new user account.
alfredeen Jan 19, 2024
0855d6a
Began test plan classroom. Implemented power user create and delete u…
alfredeen Jan 22, 2024
0075962
Finished test plan classroom.
alfredeen Jan 22, 2024
3aad2da
Small change to readme to make configuration URL into a link.
alfredeen Feb 1, 2024
b4b3c42
Added config files for pre-commit and flake8.
alfredeen Feb 1, 2024
db19a75
Added github workflow pre-commit
alfredeen Feb 1, 2024
0ec1f15
Update source/tests-dev/appviewer_requestshtml.py
alfredeen Feb 1, 2024
01cc795
Update source/tests-dev/appviewer_requestshtml.py
alfredeen Feb 1, 2024
0d82d4c
Update source/tests-dev/appviewer_requestshtml.py
alfredeen Feb 1, 2024
b955402
Update source/tests-dev/authenticated.py
alfredeen Feb 1, 2024
12b8fc9
Moved code check config files up to root level.
alfredeen Feb 1, 2024
359a383
Reformatted with code linters and checkers
alfredeen Feb 1, 2024
36c5c7f
Reformatted imports with isort
alfredeen Feb 1, 2024
b67f157
Reformatted and code changes for the mypy type checker.
alfredeen Feb 1, 2024
626027c
Fixed end of line rules
alfredeen Feb 1, 2024
046cdad
Introduced the standard logging library. Converted most prints to log…
alfredeen Feb 1, 2024
c176ef8
Update source/tests/base_user_types.py
alfredeen Feb 2, 2024
b29ce3f
Update source/tests/base_user_types.py
alfredeen Feb 2, 2024
14e0035
Clearer setup instructions
alfredeen Feb 2, 2024
e1c10eb
Formatting
alfredeen Feb 2, 2024
ab83dc1
Formatting
alfredeen Feb 2, 2024
cc88b22
Updated test logic so sync with changes to Serve.
alfredeen Apr 17, 2024
2a1694a
Added Dockerfile and a start script.
alfredeen Apr 18, 2024
1961106
Added a CI github action
alfredeen Apr 18, 2024
af783a2
Pinned version of the Locust base image.
alfredeen Apr 18, 2024
e2ddd2c
Building source directory
alfredeen Apr 18, 2024
336342d
Adding a publish action
alfredeen Apr 19, 2024
c23bf74
Fixed formatting
alfredeen Apr 19, 2024
be975ee
Fixed formatting
alfredeen Apr 19, 2024
10e620d
Fixed formatting
alfredeen Apr 19, 2024
e75b8e1
Merge branch 'main' into develop
alfredeen Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [ "develop" ]
paths-ignore:
- '**.md'

pull_request:
branches: [ "develop" ]
paths-ignore:
- '**.md'

# Adds ability to run this workflow manually
workflow_dispatch:


jobs:

lint:
runs-on: ubuntu-latest
env:
HADOLINT_RECURSIVE: "true"

steps:
- uses: actions/checkout@v3
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: "Dockerfile*"


build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build source --file source/Dockerfile --tag ci:$(date +%s)
64 changes: 64 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Docker publish

on:
push:
branches: [ "main" ]
paths-ignore:
- '**.md'
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]

# Adds ability to run this workflow manually
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'YYYYMMDD-HHmm' tz='Europe/Stockholm'}},prefix=${{ github.ref_name }}-

- name: Output docker image information
run: |
echo "Branch GITHUB_REF##*/: ${GITHUB_REF##*/}"
#echo "github.refname: $github.ref_name"

- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Publish image to GHCR
uses: docker/build-push-action@v3
with:
file: ./source/Dockerfile
context: .
push: true
build-args: version=${{ github.ref_name }}
tags: |
${{ steps.meta.outputs.tags }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,12 @@ $ cd ./source
$ chmod +x run_test_plan.sh
$ ./run_test_plan.sh
```


## Use a custom built docker image

cd ./source

docker build -t serve-load-testing .

docker run -p 8089:8089 serve-load-testing
14 changes: 14 additions & 0 deletions source/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use the Locust image as the base image
FROM locustio/locust:2.25.0

WORKDIR /home/locust

# TODO: pip install requirements without locust

# Copy the Locust files into the container
COPY locust-ui.conf locust.conf
COPY tests/ tests
COPY start-script.sh start-script.sh

# Expose the Locust web UI port
EXPOSE 8089
4 changes: 2 additions & 2 deletions source/locust-ui.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# locust.conf
locustfile = tests
# locust-ui.conf
locustfile = tests/test_verify_host.py
headless = false
#master = true
#expect-workers = 5
Expand Down
3 changes: 3 additions & 0 deletions source/start-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/home/locust/locust
12 changes: 6 additions & 6 deletions source/tests/base_user_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def register_user(self):
last_name="Me",
affiliation="other",
department="Dept ABC",
password1="ac3ya89ni3wk",
password2="ac3ya89ni3wk",
password1="Ac3ya89ni3wk!",
password2="Ac3ya89ni3wk!",
note="",
csrfmiddlewaretoken=self.csrftoken,
)
Expand Down Expand Up @@ -234,12 +234,12 @@ def create_project(self, project_name: str):
logger.debug("create project response.status_code = %s, %s", response.status_code, response.reason)
# If succeeds then url = /<username>/<project-name>
logger.debug("create project response.url = %s", response.url)
if self.username in response.url and project_name in response.url:
if project_name in response.url:
logger.info("Successfully created project %s", project_name)
self.project_url = response.url
else:
logger.warning(response.content)
response.failure("Create project failed. Response URL does not contain username and project name.")
response.failure("Create project failed. Response URL does not contain project name.")

def delete_project(self):
# Update the csrf token
Expand Down Expand Up @@ -327,8 +327,8 @@ def open_user_app(self):
# Staging
# ex: https://loadtest-shinyproxy2.staging.serve-dev.scilifelab.se/app/loadtest-shinyproxy2
# from host: https://staging.serve-dev.scilifelab.se
APP_SHINYPROXY = self.host.replace("https://", "https://loadtest-shinyproxy2.")
APP_SHINYPROXY += "/app/loadtest-shinyproxy2"
APP_SHINYPROXY = self.host.replace("https://", "https://loadtest-shinyproxy3.")
APP_SHINYPROXY += "/app/loadtest-shinyproxy3"

elif "serve.scilifelab.se" in self.host:
# Production
Expand Down
Loading