Skip to content

Commit

Permalink
feat: bump ask-smapi-model to v1.19.1 (#426)
Browse files Browse the repository at this point in the history
* feat: bump ask-smapi-model to v1.19.1

* fix: add integration test cases for new added smapi model apis

* fix: bug fix integrations test cases failures

* fix: experimentMetricConfigurationModel constant name for file referencing and disable JSON parse

Co-authored-by: Shreyas Govinda Raju <[email protected]>
  • Loading branch information
Shreyas-vgr and shreraju-amzn authored Jan 28, 2022
1 parent 7ede2a0 commit 6fd3a15
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"adm-zip": "^0.4.13",
"archiver": "^1.1.0",
"ask-smapi-model": "~1.17.0",
"ask-smapi-model": "~1.19.1",
"ask-smapi-sdk": "^1.2.0",
"async": "^2.1.5",
"aws-profile-handler": "2.0.3",
Expand Down
97 changes: 96 additions & 1 deletion test/integration/commands/smapi-commands-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const accountLinkingRequest = require('@test/integration/fixtures/account-linkin
const interactionModel = require('@test/integration/fixtures/interaction-model.json');
const annotationSet = require('@test/integration/fixtures/annotation-set.json');
const jobDefinition = require('@test/integration/fixtures/job-definition.json');
const experimentMetricConfigurationModel = require('@test/integration/fixtures/experiment-metric-configuration.json')

parallel.limit(8);

Expand Down Expand Up @@ -63,10 +64,20 @@ parallel('smapi command test', () => {
const slotTypeId = 'someSlotTypeId';
const sourceAnnotationId = 'someSourceAnnotationId';
const evaluationId = 'someEvaluationId';
const annotationId = 'soemAnnotationId';
const annotationId = 'some AnnotationId';
const accept = 'application/json';
const contentType = 'application/json';
const annotationSetId = 'someAnnotationSetId';
const experimentId = '1';
const treatmentId = '2';
const metricSnapShotId = '3';
const experimentName = 'experimentName';
const experimentDescription = 'experimentDescription';
const experimentType = 'ENDPOINT_BASED';
const experimentPlannedDuration = 'P3W';
const experimentExposurePercentage = '10';
const targetState = 'ENABLED';
const experimentMetricConfigurations = JSON.stringify(experimentMetricConfigurationModel);
const updateNluAnnotationSetAnnotationsRequest = JSON.stringify(annotationSet);
const interactionModelJobDefinition = JSON.stringify(jobDefinition);
const annotations = JSON.stringify(
Expand Down Expand Up @@ -1249,6 +1260,90 @@ parallel('smapi command test', () => {
expect(result).be.an('object');
});

it('| should list all experiments associated with this skill id', async () => {
const args = [subCmd, 'list-experiments', '-s', skillId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

it('| should create a new experiment for a skill', async () => {
const args = [subCmd, 'create-experiment', '-s', skillId, '--experiment-name', experimentName, '--experiment-description', experimentDescription, '--experiment-type', experimentType, '--experiment-planned-duration', experimentPlannedDuration, '--experiment-exposure-percentage', experimentExposurePercentage, '--experiment-metric-configurations', experimentMetricConfigurations];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should update an existing experiment for a skill', async () => {
const args = [subCmd, 'update-experiment', '-s', skillId, '--experiment-id', experimentId, '--experiment-description', experimentDescription, '--experiment-planned-duration', experimentPlannedDuration, '--experiment-exposure-percentage', experimentExposurePercentage, '--experiment-metric-configurations', experimentMetricConfigurations];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should retrieve an existing experiment for a skill', async () => {
const args = [subCmd, 'get-experiment', '-s', skillId, '--experiment-id', experimentId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

it('| should delete an existing experiment for a skill', async () => {
const args = [subCmd, 'delete-experiment', '-s', skillId, '--experiment-id', experimentId];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should update the exposure of an experiment that is in CREATED or RUNNING state.', async () => {
const args = [subCmd, 'update-exposure', '-s', skillId, '--experiment-id', experimentId, '--exposure-percentage', experimentExposurePercentage];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should retrieve the current user\'s customer treatment override for an existing A/B Test experiment', async () => {
const args = [subCmd, 'get-customer-treatment-override', '-s', skillId, '--experiment-id', experimentId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

it('| should add the requesting user\'s customer treatment override to an existing experiment.', async () => {
const args = [subCmd, 'set-customer-treatment-override', '-s', skillId, '--experiment-id', experimentId, '--treatment-id', treatmentId];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should retrieve the current state of the experiment.', async () => {
const args = [subCmd, 'get-experiment-state', '-s', skillId, '--experiment-id', experimentId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

it('| should request an action on the experiment to move it to the targetState.', async () => {
const args = [subCmd, 'manage-experiment-state', '-s', skillId, '--experiment-id', experimentId, '--target-state', targetState];
addCoveredCommand(args);
const result = await run(cmd, args, { ...options, parse: false });
expect(result).include('Command executed successfully!');
});

it('| should get a list of all metric snapshots associated with this experiment id.', async () => {
const args = [subCmd, 'list-experiment-metric-snapshots', '-s', skillId, '--experiment-id', experimentId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

it('| should gets a list of all metric data associated with this experiment\'s metric snapshot.', async () => {
const args = [subCmd, 'get-experiment-metric-snapshot', '-s', skillId, '--experiment-id', experimentId, '--metric-snapshot-id', metricSnapShotId];
addCoveredCommand(args);
const result = await run(cmd, args, options);
expect(result).be.an('object');
});

after(() => {
mockSmapiServer.kill();
mockLwaServer.kill();
Expand Down
12 changes: 12 additions & 0 deletions test/integration/fixtures/experiment-metric-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "CPDR",
"metricTypes": ["KEY"],
"expectedChange": "DECREASE"
},
{
"name": "ISP_SALES_QUANTITY",
"metricTypes": ["KEY"],
"expectedChange": "INCREASE"
}
]

0 comments on commit 6fd3a15

Please sign in to comment.