Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 50562a1

Browse files
committed
Add dummy data to run a test job
1 parent 967edf1 commit 50562a1

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

test/create-lab.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
TOKEN=$1
3+
SERVER="127.0.0.1"
4+
LAB_NAME="lab-baylibre-$(date "+%Y%m%dT%H%M%S")"
5+
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: $TOKEN" -d '{"version": "1.0", "name": "'${LAB_NAME}'", "contact": {"name": "Hilman", "surname": "Kevin", "email": "[email protected]"}}' $SERVER:8081/lab

test/dump.tar.gz

290 KB
Binary file not shown.

test/raw_json.pkl

291 KB
Binary file not shown.

test/send_job.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pickle
2+
import yaml
3+
import requests
4+
import sys
5+
6+
if len(sys.argv) < 3:
7+
print("TOKEN, LAB_NAME, BACKEND_URL and FILEPATH must be provided")
8+
sys.exit(0)
9+
10+
TOKEN = sys.argv[1]
11+
LAB_NAME = sys.argv[2]
12+
BACKEND_URL = sys.argv[3]
13+
FILEPATH = sys.argv[4]
14+
15+
headers = {
16+
"Authorization": TOKEN
17+
}
18+
19+
def fake_callback():
20+
file = open(FILEPATH, 'rb')
21+
payload = pickle.load(file)
22+
url = BACKEND_URL + "/callback/lava/test?lab_name=" + LAB_NAME + "&status=2&status_string=complete"
23+
response = requests.post(url, headers=headers, json=payload)
24+
print(response)
25+
26+
if __name__ == "__main__":
27+
fake_callback()
28+
sys.exit(0)

test/test.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Get admin token
2+
ADMIN_TOKEN=${1:-$(cat .kernelci_token)}
3+
echo $ADMIN_TOKEN
4+
5+
# Tet pickel file
6+
FILEPATH=$PWD/test/raw_json.pkl
7+
8+
# Define additional variables
9+
SERVER="http://127.0.0.1:8081"
10+
LAB_NAME="lab-baylibre-$(date "+%Y%m%dT%H%M%S")"
11+
12+
# Create lab
13+
result=$(curl -s -X POST -H "Content-Type: application/json" -H "Authorization: $ADMIN_TOKEN" -d '{"version": "1.0", "name": "'${LAB_NAME}'", "contact": {"name": "Hilman", "surname": "Kevin", "email": "[email protected]"}}' $SERVER/lab)
14+
15+
# Get token
16+
TOKEN=$(echo $result | docker run -i --rm lucj/jq:1.0 -r '.result[0].token')
17+
18+
# Send a dummy job
19+
python $PWD/test/send_job.py $TOKEN $LAB_NAME $SERVER $FILEPATH

0 commit comments

Comments
 (0)