* add test_rest_server_js_sdk.sh

* update test_rest_server_js_sdk.sh

* add to stage_test.sh

* fix

* fix

* update

* update

* update

* update

* test

* test

* test

* test

* test

* update

* test

* test

* test

* update

* update

* update

* update swagger

* update

* update

* update

* update

* update

* update

* update

* fix timeout

* update swagger version
This commit is contained in:
yiyione 2020-06-23 16:51:40 +08:00 коммит произвёл GitHub
Родитель bf913540bb
Коммит e4a12008a4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 90 добавлений и 7 удалений

2
Jenkinsfile поставляемый
Просмотреть файл

@ -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

Просмотреть файл

@ -4,10 +4,11 @@ info:
description: >
Open Platform for AI RESTful API docs.
Version 2.0.1: add more examples and fix typos
Version 2.0.2: update job detail and job attempt schema
license:
name: MIT License
url: 'https://github.com/microsoft/pai/blob/master/LICENSE'
version: 2.0.1
version: 2.0.2
externalDocs:
description: Find out more about OpenPAI
url: 'https://github.com/microsoft/pai'
@ -2015,7 +2016,6 @@ components:
- retries
- createdTime
- completedTime
- appId
- appLaunchedTime
- appCompletedTime
- appExitCode
@ -2055,9 +2055,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
@ -2283,14 +2285,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
@ -2441,6 +2446,7 @@ components:
- UNKNOWN
containerId:
type: string
nullable: true
containerIp:
type: string
containerGpus:

Просмотреть файл

@ -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,
@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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