Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
69 changes: 48 additions & 21 deletions .github/workflows/k6-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,55 @@ on:
workflow_dispatch:

jobs:
k6-test:
load-test:
runs-on: ubuntu-latest
# Only run if the VM Deploy workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Setup k6
uses: grafana/k6-action@v0.3.1
with:
filename: my-test.js

- name: Run k6 performance test
run: |
echo "Running k6 tests after successful VM deployment..."
k6 run my-test.js --out json=k6-results.json

- name: Upload k6 results
uses: actions/upload-artifact@v4
if: always()
with:
name: k6-performance-results
path: k6-results.json
- name: Copy test file to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_ADMIN }}
password: ${{ secrets.ADMIN_PASSWORD }}
source: "my-test.js"
target: "/tmp/"

- name: Run K6 test on server
uses: appleboy/ssh-action@v1.2.1
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_ADMIN }}
password: ${{ secrets.ADMIN_PASSWORD }}
script: |
# Install k6 if not already installed
if ! command -v k6 &> /dev/null; then
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install -y k6
fi

# Run test (use localhost since we're on the server)
cd /tmp
k6 run my-test.js --out json=results.json

- name: Download results
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_ADMIN }}
password: ${{ secrets.ADMIN_PASSWORD }}
source: "/tmp/results.json"
target: "."
download: true

- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: k6-results
path: results.json
5 changes: 3 additions & 2 deletions my-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const options = {
};

export default function() {
let res = http.get('https://crs-17313-nodegpt.qatar.cmu.edu/');
// Use localhost since we're running ON the server
let res = http.get('https://localhost/');
expect.soft(res.status).toBe(200);
sleep(1);
}
}