Skip to content

Commit

Permalink
test: Update test output and e2e scripts
Browse files Browse the repository at this point in the history
* Fix install script to correctly install config files

Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Jun 20, 2024
1 parent 2b58d1c commit 5059c38
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 12 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ ifeq ($(CGO_BUILD), 1)
PROMU_CONF ?= .promu-cgo.yml
pkgs := ./pkg/api/cli \
./pkg/api/db ./pkg/api/helper \
./pkg/api/resource ./pkg/api/updater \
./pkg/api/resource ./pkg/api/resource/slurm \
./pkg/api/updater \
./pkg/api/http ./cmd/ceems_api_server \
./pkg/lb/backend ./pkg/lb/cli \
./pkg/lb/frontend ./pkg/lb/serverpool \
Expand Down Expand Up @@ -145,6 +146,10 @@ else
test-e2e: $(PROMTOOL) build pkg/collector/testdata/sys/.unpacked pkg/collector/testdata/proc/.unpacked
@echo ">> running end-to-end tests"
./scripts/e2e-test.sh -s api-project-query
./scripts/e2e-test.sh -s api-project-empty-query
./scripts/e2e-test.sh -s api-project-admin-query
./scripts/e2e-test.sh -s api-user-query
./scripts/e2e-test.sh -s api-user-admin-query
./scripts/e2e-test.sh -s api-cluster-admin-query
./scripts/e2e-test.sh -s api-uuid-query
./scripts/e2e-test.sh -s api-running-query
Expand Down Expand Up @@ -185,6 +190,10 @@ else
test-e2e-update: $(PROMTOOL) build pkg/collector/testdata/sys/.unpacked pkg/collector/testdata/proc/.unpacked
@echo ">> updating end-to-end tests outputs"
./scripts/e2e-test.sh -s api-project-query -u || true
./scripts/e2e-test.sh -s api-project-empty-query -u || true
./scripts/e2e-test.sh -s api-project-admin-query -u || true
./scripts/e2e-test.sh -s api-user-query -u || true
./scripts/e2e-test.sh -s api-user-admin-query -u || true
./scripts/e2e-test.sh -s api-cluster-admin-query -u || true
./scripts/e2e-test.sh -s api-uuid-query -u || true
./scripts/e2e-test.sh -s api-running-query -u || true
Expand Down
Binary file modified pkg/api/testdata/ceems.db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"success","data":[{"cluster_id":"slurm-0","resource_manager":"slurm","name":"acc1","users":["usr1","usr15","usr8"]},{"cluster_id":"slurm-1","resource_manager":"slurm","name":"acc1","users":["usr1","usr15","usr8"]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"success","data":[]}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"status":"success","data":[{"name":"acc1"},{"name":"acc2"}]}
{"status":"success","data":[{"cluster_id":"slurm-0","resource_manager":"slurm","name":"acc1","users":["usr1","usr15","usr8"]},{"cluster_id":"slurm-1","resource_manager":"slurm","name":"acc1","users":["usr1","usr15","usr8"]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"success","data":[{"cluster_id":"slurm-0","resource_manager":"slurm","name":"usr1","projects":["acc1","acc2"]},{"cluster_id":"slurm-1","resource_manager":"slurm","name":"usr1","projects":["acc1","acc2"]}]}
1 change: 1 addition & 0 deletions pkg/api/testdata/output/e2e-test-api-server-user-query.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"success","data":[{"cluster_id":"slurm-0","resource_manager":"slurm","name":"usr1","projects":["acc1","acc2"]},{"cluster_id":"slurm-1","resource_manager":"slurm","name":"usr1","projects":["acc1","acc2"]}]}
2 changes: 1 addition & 1 deletion pkg/api/testdata/output/e2e-test-api-verify-pass-query.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"status":"success","data":[{"user":"usr1","uuids":["1479763","1479765"],"owner":true}]}
{"status":"success","data":null}
3 changes: 1 addition & 2 deletions pkg/api/testdata/sacct
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

echo """JobIDRaw|Partition|QoS|Account|Group|GID|User|UID|Submit|Start|End|Elapsed|ElapsedRaw|ExitCode|State|Alloctres|NodeList|JobName|WorkDir
1479763|part1|qos1|acc1|grp1|1001|usr1|1001|2022-02-21T14:37:02+0100|2022-02-21T14:37:07+0100|2022-02-21T15:26:29+0100|00:49:22|3000|0:0|CANCELLED by 1001|billing=80,cpu=8,energy=1439089,gres/gpu=8,mem=320G,node=1|compute-0|test_script1|/home/usr1
echo """1479763|part1|qos1|acc1|grp1|1001|usr1|1001|2022-02-21T14:37:02+0100|2022-02-21T14:37:07+0100|2022-02-21T15:26:29+0100|00:49:22|3000|0:0|CANCELLED by 1001|billing=80,cpu=8,energy=1439089,gres/gpu=8,mem=320G,node=1|compute-0|test_script1|/home/usr1
1481508|part1|qos1|acc2|grp2|1002|usr2|1002|2023-02-21T15:48:20+0100|2023-02-21T15:49:06+0100|2023-02-21T15:57:23+0100|00:08:17|4500|0:0|CANCELLED by 1002|billing=160,cpu=16,energy=1439089,gres/gpu=8,mem=320G,node=2|compute-[0-2]|test_script2|/home/usr2
1481510|part1|qos1|acc3|grp3|1003|usr3|1003|2023-02-21T15:48:20+0100|2023-02-21T15:49:06+0100|2023-02-21T15:57:23+0100|00:00:17|789|0:0|CANCELLED by 1003|billing=160,cpu=16,energy=1439089,gres/gpu=8,mem=320G,node=2|compute-[0-2]|test_script2|/home/usr3
147975|part1|qos1|acc3|grp3|1003|usr3|1003|2023-02-21T14:37:02+0100|2023-02-21T14:37:07+0100|2023-02-21T15:26:29+0100|00:49:22|3000|0:0|CANCELLED by 1003|billing=80,cpu=8,energy=1439089,gres/gpu=8,mem=320G,node=1|compute-0|test_script1|/home/usr3
Expand Down
17 changes: 17 additions & 0 deletions pkg/api/testdata/sacctmgr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo """root|
root|root
acc1|
acc1|usr1
acc1|usr8
acc1|usr15
acc2|
acc2|usr2
acc2|usr1
acc3|
acc3|usr3
acc4|
acc4|usr4
testacc|
testacc|testusr"""
Binary file removed pkg/lb/testdata/ceems_api_server.db
Binary file not shown.
38 changes: 33 additions & 5 deletions scripts/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ then
then
desc="/projects end point test"
fixture='pkg/api/testdata/output/e2e-test-api-server-project-query.txt'
elif [ "${scenario}" = "api-project-empty-query" ]
then
desc="/projects end point test with user query a project that they are not part of"
fixture='pkg/api/testdata/output/e2e-test-api-server-project-empty-query.txt'
elif [ "${scenario}" = "api-project-admin-query" ]
then
desc="/projects/admin end point test"
fixture='pkg/api/testdata/output/e2e-test-api-server-project-admin-query.txt'
elif [ "${scenario}" = "api-user-query" ]
then
desc="/users end point test"
fixture='pkg/api/testdata/output/e2e-test-api-server-user-query.txt'
elif [ "${scenario}" = "api-user-admin-query" ]
then
desc="/users/admin end point test"
fixture='pkg/api/testdata/output/e2e-test-api-server-user-admin-query.txt'
elif [ "${scenario}" = "api-cluster-admin-query" ]
then
desc="/clusters/admin end point test"
Expand Down Expand Up @@ -146,11 +162,11 @@ then
fixture='pkg/api/testdata/output/e2e-test-api-verify-fail-query.txt'
elif [ "${scenario}" = "api-demo-units-query" ]
then
desc="/units/demo end point test"
desc="/demo/units end point test"
fixture='pkg/api/testdata/output/e2e-test-api-demo-units-query.txt'
elif [ "${scenario}" = "api-demo-usage-query" ]
then
desc="/usage/demo end point test"
desc="/demo/usage end point test"
fixture='pkg/api/testdata/output/e2e-test-api-demo-usage-query.txt'
fi

Expand Down Expand Up @@ -393,7 +409,19 @@ then

if [ "${scenario}" = "api-project-query" ]
then
get -H "X-Grafana-User: usr1" "127.0.0.1:${port}/api/${api_version}/projects" > "${fixture_output}"
get -H "X-Grafana-User: usr1" "127.0.0.1:${port}/api/${api_version}/projects?project=acc1" > "${fixture_output}"
elif [ "${scenario}" = "api-project-empty-query" ]
then
get -H "X-Grafana-User: usr1" "127.0.0.1:${port}/api/${api_version}/projects?project=acc3" > "${fixture_output}"
elif [ "${scenario}" = "api-project-admin-query" ]
then
get -H "X-Grafana-User: grafana" "127.0.0.1:${port}/api/${api_version}/projects/admin?project=acc1" > "${fixture_output}"
elif [ "${scenario}" = "api-user-query" ]
then
get -H "X-Grafana-User: usr1" "127.0.0.1:${port}/api/${api_version}/users" > "${fixture_output}"
elif [ "${scenario}" = "api-user-admin-query" ]
then
get -H "X-Grafana-User: grafana" "127.0.0.1:${port}/api/${api_version}/users/admin?user=usr1" > "${fixture_output}"
elif [ "${scenario}" = "api-cluster-admin-query" ]
then
get -H "X-Ceems-User: usr1" "127.0.0.1:${port}/api/${api_version}/clusters/admin" > "${fixture_output}"
Expand Down Expand Up @@ -438,10 +466,10 @@ then
get -H "X-Grafana-User: usr2" "127.0.0.1:${port}/api/${api_version}/units/verify?cluster_id=slurm-1&uuid=1479763&uuid=11508" > "${fixture_output}"
elif [ "${scenario}" = "api-demo-units-query" ]
then
get -s -o /dev/null -w "%{http_code}" "127.0.0.1:${port}/api/${api_version}/units/demo" > "${fixture_output}"
get -s -o /dev/null -w "%{http_code}" "127.0.0.1:${port}/api/${api_version}/demo/units" > "${fixture_output}"
elif [ "${scenario}" = "api-demo-usage-query" ]
then
get -s -o /dev/null -w "%{http_code}" "127.0.0.1:${port}/api/${api_version}/usage/demo" > "${fixture_output}"
get -s -o /dev/null -w "%{http_code}" "127.0.0.1:${port}/api/${api_version}/demo/usage" > "${fixture_output}"
fi

elif [[ "${scenario}" =~ ^"lb" ]]
Expand Down
4 changes: 2 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ chmod +x -R "$TMP_DIR/$FILE_NAME"
mkdir -p "$CFG_DIR" "$BIN_DIR"
cp -r "$TMP_DIR/$FILE_NAME/$APP" "$BIN_DIR/$APP"
cp -r "$TMP_DIR/$FILE_NAME/web-config.yml" "$CFG_DIR"
test "$APP" = "ceems_api_server" && cp -r "$TMP_DIR/$FILE_NAME/tsdb-config.yml" "$CFG_DIR"
test "$APP" = "ceems_lb" && cp -r "$TMP_DIR/$FILE_NAME/config.yml" "$CFG_DIR"
test "$APP" = "ceems_api_server" && cp -r "$TMP_DIR/$FILE_NAME/ceems_api_server.yml" "$CFG_DIR"
test "$APP" = "ceems_lb" && cp -r "$TMP_DIR/$FILE_NAME/ceems_lb.yml" "$CFG_DIR"
done
)

0 comments on commit 5059c38

Please sign in to comment.