Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
feat: pass jobOwnerId param to bulk export job (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
carvantes committed Oct 13, 2021
1 parent 37e3473 commit 85a5912
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bulkExport/bulkExport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('startJobExecution', () => {
});

const jobId = 'job-1';
const jobOwnerId = 'owner-1';
const exportType = 'system';
const transactionTime = '2020-10-10T00:00:00.000Z';
const since = '2020-10-09T00:00:00.000Z';
Expand All @@ -107,7 +108,7 @@ describe('startJobExecution', () => {
const job: BulkExportJob = {
jobId,
jobStatus: 'in-progress',
jobOwnerId: 'owner-1',
jobOwnerId,
exportType,
transactionTime,
outputFormat,
Expand All @@ -116,6 +117,7 @@ describe('startJobExecution', () => {

const expectedInput = {
jobId,
jobOwnerId,
exportType,
transactionTime,
since,
Expand Down Expand Up @@ -143,7 +145,7 @@ describe('startJobExecution', () => {
const job: BulkExportJob = {
jobId,
jobStatus: 'in-progress',
jobOwnerId: 'owner-1',
jobOwnerId,
exportType,
transactionTime,
outputFormat,
Expand All @@ -153,6 +155,7 @@ describe('startJobExecution', () => {

const expectedInput = {
jobId,
jobOwnerId,
exportType,
transactionTime,
since,
Expand Down
2 changes: 2 additions & 0 deletions src/bulkExport/bulkExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const getBulkExportResults = async (
export const startJobExecution = async (bulkExportJob: BulkExportJob): Promise<void> => {
const {
jobId,
jobOwnerId,
exportType,
groupId,
type,
Expand All @@ -62,6 +63,7 @@ export const startJobExecution = async (bulkExportJob: BulkExportJob): Promise<v
} = bulkExportJob;
const params: any = {
jobId,
jobOwnerId,
exportType,
transactionTime,
since,
Expand Down
12 changes: 12 additions & 0 deletions src/bulkExport/getJobStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import DynamoDbParamBuilder from '../dataServices/dynamoDbParamBuilder';

AWSMock.setSDKInstance(AWS);

const jobOwnerId = 'owner-1';

describe('getJobStatus', () => {
beforeEach(() => {
process.env.GLUE_JOB_NAME = 'jobName';
Expand All @@ -23,6 +25,7 @@ describe('getJobStatus', () => {
test('completed job', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -47,6 +50,7 @@ describe('getJobStatus', () => {
});
await expect(getJobStatusHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -60,6 +64,7 @@ describe('getJobStatus', () => {
test('completed job in multi-tenancy mode', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
tenantId: 'tenant1',
exportType: 'system',
transactionTime: '',
Expand Down Expand Up @@ -87,6 +92,7 @@ describe('getJobStatus', () => {
});
await expect(getJobStatusHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
tenantId: 'tenant1',
exportType: 'system',
transactionTime: '',
Expand All @@ -102,6 +108,7 @@ describe('getJobStatus', () => {
test('failed job', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -125,6 +132,7 @@ describe('getJobStatus', () => {
});
await expect(getJobStatusHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -138,6 +146,7 @@ describe('getJobStatus', () => {
test('canceled job', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -161,6 +170,7 @@ describe('getJobStatus', () => {
});
await expect(getJobStatusHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -175,6 +185,7 @@ describe('getJobStatus', () => {
delete process.env.GLUE_JOB_NAME;
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -189,6 +200,7 @@ describe('getJobStatus', () => {
test('missing glueJobRunId ', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
};
Expand Down
8 changes: 8 additions & 0 deletions src/bulkExport/startExportJob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { startExportJobHandler } from './startExportJob';

AWSMock.setSDKInstance(AWS);

const jobOwnerId = 'owner-1';

describe('getJobStatus', () => {
beforeEach(() => {
process.env.GLUE_JOB_NAME = 'jobName';
Expand All @@ -18,6 +20,7 @@ describe('getJobStatus', () => {
test('start job', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
};
Expand All @@ -29,6 +32,7 @@ describe('getJobStatus', () => {
});
await expect(startExportJobHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -40,6 +44,7 @@ describe('getJobStatus', () => {
test('start job in multi-tenancy mode', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
tenantId: 'tenant1',
exportType: 'system',
transactionTime: '',
Expand All @@ -52,6 +57,7 @@ describe('getJobStatus', () => {
});
await expect(startExportJobHandler(event, null as any, null as any)).resolves.toEqual({
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
tenantId: 'tenant1',
Expand All @@ -64,6 +70,7 @@ describe('getJobStatus', () => {
test('glue exception', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
};
Expand All @@ -78,6 +85,7 @@ describe('getJobStatus', () => {
delete process.env.GLUE_JOB_NAME;
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
};
Expand Down
1 change: 1 addition & 0 deletions src/bulkExport/startExportJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const startExportJobHandler: Handler<
JobName: GLUE_JOB_NAME,
Arguments: {
'--jobId': event.jobId,
'--jobOwnerId': event.jobOwnerId,
'--exportType': event.exportType,
'--transactionTime': event.transactionTime,
'--groupId': event.groupId!,
Expand Down
6 changes: 6 additions & 0 deletions src/bulkExport/stopExportJob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { stopExportJobHandler } from './stopExportJob';

AWSMock.setSDKInstance(AWS);

const jobOwnerId = 'owner-1';

describe('getJobStatus', () => {
const glueJobName = 'jobName';
const glueJobRunId = 'jr_1';
Expand All @@ -20,6 +22,7 @@ describe('getJobStatus', () => {
test('stop job successfully', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -44,6 +47,7 @@ describe('getJobStatus', () => {
test('stop job failed', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand Down Expand Up @@ -75,6 +79,7 @@ describe('getJobStatus', () => {
delete process.env.GLUE_JOB_NAME;
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand All @@ -89,6 +94,7 @@ describe('getJobStatus', () => {
test('missing glueJobRunId ', async () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {},
Expand Down
1 change: 1 addition & 0 deletions src/bulkExport/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface BulkExportStateMachineExecutionParameters {
*/
export interface BulkExportStateMachineGlobalParameters {
jobId: string;
jobOwnerId: string;
exportType: ExportType;
transactionTime: string;
groupId?: string;
Expand Down
3 changes: 3 additions & 0 deletions src/bulkExport/updateStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ import DynamoDbParamBuilder from '../dataServices/dynamoDbParamBuilder';

AWSMock.setSDKInstance(AWS);

const jobOwnerId = 'owner-1';

describe('updateStatus', () => {
const event: BulkExportStateMachineGlobalParameters = {
jobId: '1',
jobOwnerId,
exportType: 'system',
transactionTime: '',
executionParameters: {
Expand Down

0 comments on commit 85a5912

Please sign in to comment.