Skip to content

Commit

Permalink
test: deploy mode test failure (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
telpirion authored and pattishin committed Nov 22, 2022
1 parent 8955823 commit 187374e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
3 changes: 1 addition & 2 deletions ai-platform/snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.0.0",
"uuid": "^8.3.1",
"gts": "^3.0.2"
"uuid": "^8.3.1"
}
}
41 changes: 15 additions & 26 deletions ai-platform/snippets/test/deploy-model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

'use strict';

const path = require('path');
const {assert} = require('chai');
const {after, describe, it} = require('mocha');

const uuid = require('uuid').v4;
const cp = require('child_process');
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
const cwd = path.join(__dirname, '..');

const endpointDisplayName = `temp_create_endpoint_test_${uuid()}`;

Expand All @@ -36,39 +34,30 @@ let endpointId;

describe('AI platform deploy model', () => {
it('should deploy the model in the specified endpoint', async () => {
const endOut = execSync(
`node ./create-endpoint.js ${endpointDisplayName} ${project} \
${location}`,
{
cwd,
}
);
const endOut =
execSync(`node ./create-endpoint.js ${endpointDisplayName} ${project} \
${location}`);
endpointId = endOut
.split('/locations/us-central1/endpoints/')[1]
.split('\n')[0]
.split('/')[0];
const stdout = execSync(
`node ./deploy-model.js ${modelId} ${deployedModelDisplayName} \
const stdout =
execSync(`node ./deploy-model.js ${modelId} ${deployedModelDisplayName} \
${endpointId} \
${project} ${location}`,
{
cwd,
}
);
${project} ${location}`);
assert.match(stdout, /Deploy model response/);
deployedModelId = stdout.split('Id : ')[1].split('\n')[0];
});

after('should undeploy the deployed model', async () => {
execSync(
`node ./undeploy-model.js ${deployedModelId} ${endpointId} ${project} \
${location}`,
{
cwd,
}
);
execSync(`node ./delete-endpoint.js ${endpointId} ${project} ${location}`, {
cwd,
});
// If test failed, the attempt to undeploy will fail too.
// Check to see whether we have a deployedModelId
if (deployedModelId === undefined) {
return;
}

execSync(`node ./undeploy-model.js ${deployedModelId} ${endpointId} ${project} \
${location}`);
execSync(`node ./delete-endpoint.js ${endpointId} ${project} ${location}`);
});
});

0 comments on commit 187374e

Please sign in to comment.