Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Add JS SDK tests to CI #4631

Merged
merged 32 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 30 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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// timeout in minutes
http_timeout = 10
http_timeout = 20
pause_timeout = 1
jenkins_timeout = 120

Expand Down
7 changes: 6 additions & 1 deletion src/rest-server/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,6 @@ components:
- retries
- createdTime
- completedTime
- appId
- appLaunchedTime
- appCompletedTime
- appExitCode
Expand Down Expand Up @@ -1819,9 +1818,11 @@ components:
- UNKNOWN
containerId:
type: string
nullable: true
description: uid of the task container
containerIp:
type: string
nullable: true
description: ip of the task container
containerPorts:
type: object
Expand Down Expand Up @@ -2047,14 +2048,17 @@ components:
type: string
originState:
type: string
nullable: true
maxAttemptCount:
type: integer
attemptIndex:
type: integer
nullable: true
jobStartedTime:
type: integer
attemptStartedTime:
type: integer
nullable: true
attemptCompletedTime:
type: integer
nullable: true
Expand Down Expand Up @@ -2205,6 +2209,7 @@ components:
- UNKNOWN
containerId:
type: string
nullable: true
containerIp:
type: string
containerGpus:
Expand Down
24 changes: 20 additions & 4 deletions src/rest-server/src/utils/frameworkConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ const generateExitSpec = (code) => {
};

const convertToJobAttempt = async (framework) => {
if (framework.status === undefined) {
framework.status = {
attemptStatus: {
completionStatus: null,
id: null,
startTime: null,
completionTime: null,
taskRoleStatuses: [],
},
state: null,
retryPolicyStatus: {
retryDelaySec: null,
},
};
}

const completionStatus = framework.status.attemptStatus.completionStatus;
const jobName = decodeName(
framework.metadata.name,
Expand All @@ -205,12 +221,12 @@ const convertToJobAttempt = async (framework) => {
const jobStartedTime = new Date(
framework.metadata.creationTimestamp,
).getTime();
const attemptStartedTime = new Date(
const attemptStartedTime = framework.status.attemptStatus.startTime ? new Date(
framework.status.attemptStatus.startTime,
).getTime();
const attemptCompletedTime = new Date(
).getTime(): null;
const attemptCompletedTime = framework.status.attemptStatus.completionTime ? new Date(
framework.status.attemptStatus.completionTime,
).getTime();
).getTime(): null;
const totalGpuNumber = framework.metadata.annotations
? parseInt(framework.metadata.annotations.totalGpuNumber)
: 0;
Expand Down
1 change: 1 addition & 0 deletions tests/jenkins/stage_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bash -Eeuxo pipefail ${WORKSPACE}/tests/jenkins/test_rest_server.sh $1 $2
bash -Eeuxo pipefail ${WORKSPACE}/tests/jenkins/test_rest_server_js_sdk.sh $1 $2
60 changes: 60 additions & 0 deletions tests/jenkins/test_rest_server_js_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

cluster_type="$1"
rest_server_uri="$2"

case ${cluster_type} in
"yarn")
echo "Skip the API tests for yarn version"
;;
"k8s")
# install nodejs 12.x
sudo apt update
sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs -y
node --version

# install openpai-js-sdk
rm -rf openpaisdk
git clone https://github.com/microsoft/openpaisdk
cd openpaisdk
npm install
npm run build
cd lib

# get token
token=""
until [ ! -z ${token} ]; do
token=$(curl -sS -X POST -d "username=admin" -d "password=admin-password" -d "expiration=36000" ${rest_server_uri}/api/v2/authn/basic/login | jq -r ".token")
sleep 10s
done

cat <<EOT >.tests/clusters.json
[
{
"alias": "test",
"rest_server_uri": "${rest_server_uri}",
"username": "admin",
"password": "admin-password",
"token": "${token}",
"https": false
}
]
EOT

cp ${WORKSPACE}/src/rest-server/docs/swagger.yaml .
node tests/common/apiTestCaseGenerator.js -- "swagger.yaml" ".tests/apiTestCase.json"
sudo npm install -g mocha
mocha tests/api_tests/**/*.spec.js -t 20000

cd ../..
;;
*)
echo "Unknown cluster type ${cluster_type}"
exit 1
;;
esac