Skip to content

Commit

Permalink
[Test] Correctly patch DevSpaces sample devfiles (eclipse-che#22187)
Browse files Browse the repository at this point in the history
* correctly patch sample devfiles
  • Loading branch information
SkorikSergey authored May 1, 2023
1 parent 5e8a484 commit fb4c7e9
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 10 deletions.
11 changes: 11 additions & 0 deletions tests/performance/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM quay.io/openshift/origin-cli:latest

RUN yum install -y jq python3-pip

RUN pip3 install yq

RUN yum clean all && \
rm -rf /var/cache/yum && \
rm -rf /tmp/*

CMD ["/bin/bash"]
22 changes: 22 additions & 0 deletions tests/performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,25 @@ If tests fail, there is also another folder called report. There are screenshots
## Pod conole log files
For each running pod there are logs gathered in a file `pod-<number_of_pod>-console-logs.txt`. Please note that if you set `-t` larger then 1, this pod console log contains logs only from the last run.



# API performance tests

API performance tests use test scripts from crw-jenkins(https://gitlab.cee.redhat.com/codeready-workspaces/crw-jenkins/-/tree/master/vars) repo.

## Running API load tests
To start API tests use `./api-load-tests.sh` script with next parameters:
- `-n` - number of users
- `-c` - number of workspaces per user
- `-o` - OCP URL
- `-b` - Che URL
- `-u` - username
- `-p` - password
- `-s` - test suite to run

Example:
This script will run API test for 10 users with 10 workspaces and cpp test suite:
`./api-load-tests.sh -u user -p load-user -b https://devspaces.apps.ocp410-sskoryk.crw-qe.com -o https://api.ocp410-sskoryk.crw-qe.com:6443 -n 10 -c 1 -s cpp` .

## Dockerfile
Dockerfile is used to build image with all required dependencies to run API tests. It is used in `api-pod.yaml` script. It based on `openshift/origin-cli:latest` image and adds `jq` and `yq` packages.
2 changes: 1 addition & 1 deletion tests/performance/api-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
value: REPLACE_PASSWORD
- name: KUBECONFIG
value: /tmp/.kube/config
image: quay.io/openshift/origin-cli
image: quay.io/crw_pr/performance
command: ["/bin/bash"]
args: ["-c", "curl -sSL REPLACE_API_TEST | bash"]
restartPolicy: Never
2 changes: 1 addition & 1 deletion tests/performance/api-tests/api-test-cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export commandToTest="cd /projects/$projectName && rm -f bin.out && g++ -g "knut
oc login -u $OCP_USERNAME -p $OCP_PASSWORD --server=$OCP_SERVER_URL --insecure-skip-tls-verify
cd /tmp

startWorkspace ${BASE_URL}/${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}
startWorkspace ${BASE_URL} ${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}

testProjectImported ${WORKSPACE_NAME} ${containerName} ${projectName}

Expand Down
2 changes: 1 addition & 1 deletion tests/performance/api-tests/api-test-lombok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export commandToTest="cd '$projectName'; mvn clean install >> command_log.txt; g
oc login -u $OCP_USERNAME -p $OCP_PASSWORD --server=$OCP_SERVER_URL --insecure-skip-tls-verify
cd /tmp

startWorkspace ${BASE_URL}/${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}
startWorkspace ${BASE_URL} ${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}

testProjectImported ${WORKSPACE_NAME} ${containerName} ${projectName}

Expand Down
2 changes: 1 addition & 1 deletion tests/performance/api-tests/api-test-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export commandToTest="cd /projects/$projectName; php hello-world.php >> command_
oc login -u $OCP_USERNAME -p $OCP_PASSWORD --server=$OCP_SERVER_URL --insecure-skip-tls-verify
cd /tmp

startWorkspace ${BASE_URL}/${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}
startWorkspace ${BASE_URL} ${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}

testProjectImported ${WORKSPACE_NAME} ${containerName} ${projectName}

Expand Down
2 changes: 1 addition & 1 deletion tests/performance/api-tests/api-test-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export commandToTest="cd /projects/$projectName; pwd && ls -la && python -m venv
oc login -u $OCP_USERNAME -p $OCP_PASSWORD --server=$OCP_SERVER_URL --insecure-skip-tls-verify
cd /tmp

startWorkspace ${BASE_URL}/${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}
startWorkspace ${BASE_URL} ${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}

testProjectImported ${WORKSPACE_NAME} ${containerName} ${projectName}

Expand Down
2 changes: 1 addition & 1 deletion tests/performance/api-tests/api-test-quarkus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export commandToTest="cd /projects/$projectName && mvn package >> command_log.tx
oc login -u $OCP_USERNAME -p $OCP_PASSWORD --server=$OCP_SERVER_URL --insecure-skip-tls-verify
cd /tmp

startWorkspace ${BASE_URL}/${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}
startWorkspace ${BASE_URL} ${TEST_DEVFILE_PATH} ${WORKSPACE_NAME}

testProjectImported ${WORKSPACE_NAME} ${containerName} ${projectName}

Expand Down
27 changes: 23 additions & 4 deletions tests/performance/api-tests/api-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ set -e
# $2: path to devfile in devfile-registry
# $3: workspace name
function startWorkspace() {
curl --insecure $1 -o devfile.yaml
echo " routingClass: che" >> devfile.yaml
echo $1
echo $2
curl --insecure "$1/$2" -o devfile.yaml
cat devfile.yaml
oc apply -f devfile.yaml

csplit devfile.yaml /---/
mv xx00 dwt.yaml
mv xx01 dw.yaml

echo "--- Patch devfile ---"
export patch="[{\"name\": \"CHE_DASHBOARD_URL\", \"value\": \"$1\"},{\"name\": \"CHE_PLUGIN_REGISTRY_URL\", \"value\": \"$1/plugin-registry/v3\"},{\"name\": \"CHE_PLUGIN_REGISTRY_INTERNAL_URL\", \"value\": \"http://plugin-registry.openshift-devspaces.svc:8080/v3\"}]";
echo $patch

yq -y ".spec.components[0].container.env += $patch" dwt.yaml -i
cat dwt.yaml

yq -y ".spec.template.components[0].container.env += $patch" dw.yaml -i
yq -y '.spec += {"routingClass": "che"}' dw.yaml -i
cat dw.yaml

echo "--- Create and start workspace by 'oc' command ---"
oc apply -f dwt.yaml
oc apply -f dw.yaml

start=$(date +%s)
oc wait --for=condition=Ready dw $2 --timeout=360s
oc wait --for=condition=Ready dw $3 --timeout=360s
end=$(date +%s)
echo "Workspace started in $(($end - $start)) seconds"
}
Expand Down

0 comments on commit fb4c7e9

Please sign in to comment.