Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset upload response #3791

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"ms": "^2.1.3"
},
"devDependencies": {
"@terascope/types": "^1.1.0",
"@terascope/types": "^1.2.0",
"bunyan": "^1.8.15",
"elasticsearch-store": "^1.2.0",
"elasticsearch-store": "^1.3.0",
"fs-extra": "^11.2.0",
"ms": "^2.1.3",
"nanoid": "^5.0.7",
Expand Down
16 changes: 12 additions & 4 deletions e2e/test/cases/assets/simple-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ describe('assets', () => {
);

// save the asset ID that was submitted to terslice
const assetId = result._id;
const assetId = result.asset_id;
// TODO: remove this in teraslice V3
const oldAssetId = result._id;

const response = await terasliceHarness.teraslice.assets.remove(assetId);

// ensure the deleted asset's ID matches that of
// the saved asset
expect(assetId).toEqual(response._id);
expect(assetId).toEqual(response.asset_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably continue to expect both, and file an issue to remove ._id in v3.0.0. And add a comment here to remove the test for ._id in 3.0.0 (linking to the issue above or vice versa)

expect(oldAssetId).toEqual(response.asset_id);
});

// Test a bad asset
Expand Down Expand Up @@ -81,7 +85,9 @@ describe('assets', () => {
const assetResponse = await terasliceHarness.teraslice.assets.upload(fileStream, {
blocking: true
});
const assetId = assetResponse._id;
const assetId = assetResponse.asset_id;
// TODO: remove this in teraslice V3
const oldAssetId = assetResponse._id;

const ex = await terasliceHarness.submitAndStart(jobSpec);

Expand All @@ -93,7 +99,9 @@ describe('assets', () => {
expect(waitResponse).toEqual(workers);

const execution = await ex.config();

expect(execution.assets[0]).toEqual(assetId);
expect(execution.assets[0]).toEqual(oldAssetId);

await ex.stop({ blocking: true });
});
Expand Down Expand Up @@ -171,7 +179,7 @@ describe('s3 asset storage', () => {
const assetResponse = await terasliceHarness.teraslice.assets.upload(fileStream, {
blocking: true
});
assetId = assetResponse._id;
assetId = assetResponse.asset_id;

const response = await getS3Object(s3client, { Bucket: bucketName, Key: `${assetId}.zip` });
const base64 = await response.Body?.transformToString('base64');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-workspace",
"displayName": "Teraslice",
"version": "2.5.0",
"version": "2.6.0",
"private": true,
"homepage": "https://github.com/terascope/teraslice",
"bugs": {
Expand Down
10 changes: 5 additions & 5 deletions packages/data-mate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-mate",
"displayName": "Data-Mate",
"version": "1.2.0",
"version": "1.3.0",
"description": "Library of data validations/transformations",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-mate#readme",
"repository": {
Expand Down Expand Up @@ -30,9 +30,9 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-types": "^1.2.0",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/data-types": "^1.3.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"@types/validator": "^13.12.2",
"awesome-phonenumber": "^7.2.0",
"date-fns": "^4.1.0",
Expand All @@ -47,7 +47,7 @@
"uuid": "^10.0.0",
"valid-url": "^1.0.9",
"validator": "^13.12.0",
"xlucene-parser": "^1.2.0"
"xlucene-parser": "^1.3.0"
},
"devDependencies": {
"@types/ip6addr": "^0.2.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/data-types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-types",
"displayName": "Data Types",
"version": "1.2.0",
"version": "1.3.0",
"description": "A library for defining the data structures and mapping",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-types#readme",
"bugs": {
Expand All @@ -27,8 +27,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"graphql": "^16.9.0",
"lodash": "^4.17.21",
"yargs": "^17.7.2"
Expand Down
8 changes: 4 additions & 4 deletions packages/elasticsearch-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/elasticsearch-api",
"displayName": "Elasticsearch API",
"version": "4.2.0",
"version": "4.3.0",
"description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
"bugs": {
Expand All @@ -24,16 +24,16 @@
"test:watch": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"bluebird": "^3.7.2",
"setimmediate": "^1.0.5"
},
"devDependencies": {
"@opensearch-project/opensearch": "^1.2.0",
"@types/elasticsearch": "^5.0.43",
"elasticsearch": "^15.4.1",
"elasticsearch-store": "^1.2.0",
"elasticsearch-store": "^1.3.0",
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
Expand Down
12 changes: 6 additions & 6 deletions packages/elasticsearch-store/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticsearch-store",
"displayName": "Elasticsearch Store",
"version": "1.2.0",
"version": "1.3.0",
"description": "An API for managing an elasticsearch index, with versioning and migration support.",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-store#readme",
"bugs": {
Expand Down Expand Up @@ -30,10 +30,10 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-mate": "^1.2.0",
"@terascope/data-types": "^1.2.0",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/data-mate": "^1.3.0",
"@terascope/data-types": "^1.3.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
Expand All @@ -43,7 +43,7 @@
"opensearch2": "npm:@opensearch-project/opensearch@^2.2.1",
"setimmediate": "^1.0.5",
"uuid": "^10.0.0",
"xlucene-translator": "^1.2.0"
"xlucene-translator": "^1.3.0"
},
"devDependencies": {
"@types/uuid": "^10.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/job-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/job-components",
"displayName": "Job Components",
"version": "1.4.0",
"version": "1.5.0",
"description": "A teraslice library for validating jobs schemas, registering apis, and defining and running new Job APIs",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/job-components#readme",
"bugs": {
Expand Down Expand Up @@ -32,8 +32,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"convict": "^6.2.4",
"convict-format-with-moment": "^6.2.0",
"convict-format-with-validator": "^6.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/scripts",
"displayName": "Scripts",
"version": "1.3.3",
"version": "1.4.0",
"description": "A collection of terascope monorepo scripts",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/scripts#readme",
"bugs": {
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@kubernetes/client-node": "^0.22.0",
"@terascope/utils": "^1.2.0",
"@terascope/utils": "^1.3.0",
"codecov": "^3.8.3",
"execa": "9.4.0",
"fs-extra": "^11.2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/terafoundation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "terafoundation",
"displayName": "Terafoundation",
"version": "1.4.0",
"version": "1.5.0",
"description": "A Clustering and Foundation tool for Terascope Tools",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/terafoundation#readme",
"bugs": {
Expand Down Expand Up @@ -29,15 +29,15 @@
},
"dependencies": {
"@terascope/file-asset-apis": "^1.0.2",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"bluebird": "^3.7.2",
"bunyan": "^1.8.15",
"convict": "^6.2.4",
"convict-format-with-moment": "^6.2.0",
"convict-format-with-validator": "^6.2.0",
"elasticsearch": "^15.4.1",
"elasticsearch-store": "^1.2.0",
"elasticsearch-store": "^1.3.0",
"express": "^4.21.0",
"js-yaml": "^4.1.0",
"nanoid": "^5.0.7",
Expand Down
8 changes: 4 additions & 4 deletions packages/teraslice-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-cli",
"displayName": "Teraslice CLI",
"version": "2.6.0",
"version": "2.7.0",
"description": "Command line manager for teraslice jobs, assets, and cluster references.",
"keywords": [
"teraslice"
Expand Down Expand Up @@ -38,8 +38,8 @@
},
"dependencies": {
"@terascope/fetch-github-release": "^1.0.0",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"chalk": "^5.3.0",
"cli-table3": "^0.6.4",
"diff": "^7.0.0",
Expand All @@ -54,7 +54,7 @@
"pretty-bytes": "^6.1.1",
"prompts": "^2.4.2",
"signale": "^1.4.0",
"teraslice-client-js": "^1.2.0",
"teraslice-client-js": "^1.3.0",
"tmp": "^0.2.0",
"tty-table": "^4.2.3",
"yargs": "^17.7.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/teraslice-cli/src/cmds/assets/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ export default {
const resp = await terasliceClient.assets.upload(assetZip, {
blocking: cliConfig.args.blocking
});
reply.green(`Asset posted to ${cliConfig.args.clusterAlias}: ${resp._id}`);
const assetID = resp.asset_id ?? resp._id;
reply.green(`Asset posted to ${cliConfig.args.clusterAlias}: ${assetID}`);
} catch (err) {
reply.fatal(`Error posting asset: ${err.message}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/teraslice-cli/test/servers/teraslice-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const rootResponse: Teraslice.ApiRootResponse = {
};

const postAssetResponse: Teraslice.AssetIDResponse = {
_id: 'assset_test_id'
asset_id: 'assset_test_id'
};

export default class TerasliceServer {
Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-client-js",
"displayName": "Teraslice Client (JavaScript)",
"version": "1.2.0",
"version": "1.3.0",
"description": "A Node.js client for teraslice jobs, assets, and cluster references.",
"keywords": [
"elasticsearch",
Expand Down Expand Up @@ -32,8 +32,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"auto-bind": "^5.0.1",
"got": "^13.0.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/teraslice-client-js/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default class Assets extends Client {
});
}

const results = await this.delete(`/assets/${id}`, searchOptions);
const results = await this.delete<Teraslice.AssetIDResponse>(`/assets/${id}`, searchOptions);

return this.parse(results);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice-client-js/test/assets-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Teraslice Assets', () => {

describe('when called with a string', () => {
const contents = 'example-input';
const idResponse: AssetIDResponse = { _id: 'some-asset-id' };
const idResponse: AssetIDResponse = { asset_id: 'some-asset-id' };

beforeEach(async () => {
scope.post('/assets', contents)
Expand All @@ -76,7 +76,7 @@ describe('Teraslice Assets', () => {
describe.skip('when called with a stream', () => {
const testFilePath = path.join(dirname, 'fixtures', 'test.txt');
const contents = fs.readFileSync(testFilePath, 'utf-8');
const idResponse: AssetIDResponse = { _id: 'some-asset-id' };
const idResponse: AssetIDResponse = { asset_id: 'some-asset-id' };

beforeEach(() => {
scope.post('/assets', (body) => contents === body)
Expand Down Expand Up @@ -336,7 +336,7 @@ describe('Teraslice Assets', () => {
});

describe('->remove', () => {
const idResponse: AssetIDResponse = { _id: 'someId' };
const idResponse: AssetIDResponse = { asset_id: 'someId' };

beforeEach(() => {
scope.delete('/assets/some-asset-id')
Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice-messaging/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/teraslice-messaging",
"displayName": "Teraslice Messaging",
"version": "1.5.0",
"version": "1.6.0",
"description": "An internal teraslice messaging library using socket.io",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/teraslice-messaging#readme",
"bugs": {
Expand Down Expand Up @@ -35,8 +35,8 @@
"ms": "^2.1.3"
},
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.2.0",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.0",
"ms": "^2.1.3",
"nanoid": "^5.0.7",
"p-event": "^6.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice-state-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/teraslice-state-storage",
"displayName": "Teraslice State Storage",
"version": "1.2.0",
"version": "1.3.0",
"description": "State storage operation api for teraslice",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/teraslice-state-storage#readme",
"bugs": {
Expand All @@ -24,8 +24,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/elasticsearch-api": "^4.2.0",
"@terascope/utils": "^1.2.0"
"@terascope/elasticsearch-api": "^4.3.0",
"@terascope/utils": "^1.3.0"
},
"engines": {
"node": ">=18.18.0",
Expand Down
Loading
Loading