Skip to content

Commit

Permalink
Adding functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jan 31, 2022
1 parent e126374 commit 821bc7d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
62 changes: 62 additions & 0 deletions x-pack/test/functional/es_archives/task_manager_tasks/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,66 @@
"updated_at": "2020-11-30T15:43:08.277Z"
}
}
}

{
"type": "doc",
"value": {
"id": "task:ce7e1250-3322-11eb-94c1-db6995e84f6d",
"index": ".kibana_task_manager_1",
"source": {
"migrationVersion": {
"task": "7.16.0"
},
"references": [
],
"task": {
"attempts": 0,
"params": "{\"spaceId\":\"user1\",\"alertId\":\"0359d7fcc04da9878ee9aadbda38ba55\"}",
"retryAt": "2020-11-30T15:43:39.626Z",
"runAt": "2020-11-30T15:43:08.277Z",
"scheduledAt": "2020-11-30T15:43:08.277Z",
"scope": [
"testing"
],
"startedAt": null,
"state": "{}",
"status": "unrecognized",
"taskType": "alerting:0359d7fcc04da9878ee9aadbda38ba55"
},
"type": "task",
"updated_at": "2020-11-30T15:43:08.277Z"
}
}
}

{
"type": "doc",
"value": {
"id": "task:fe7e1250-3322-11eb-94c1-db6395e84f6e",
"index": ".kibana_task_manager_1",
"source": {
"migrationVersion": {
"task": "7.16.0"
},
"references": [
],
"task": {
"attempts": 0,
"params": "{\"spaceId\":\"user1\",\"alertId\":\"0359d7fcc04da9878ee9aadbda38ba55\"}",
"retryAt": "2020-11-30T15:43:39.626Z",
"runAt": "2020-11-30T15:43:08.277Z",
"scheduledAt": "2020-11-30T15:43:08.277Z",
"scope": [
"testing"
],
"startedAt": null,
"state": "{}",
"status": "unrecognized",
"taskType": "sampleTaskRemovedType"
},
"type": "task",
"updated_at": "2020-11-30T15:43:08.277Z"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import expect from '@kbn/expect';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { TransportResult } from '@elastic/elasticsearch';
import { TaskInstanceWithDeprecatedFields } from '../../../../plugins/task_manager/server/task';
import {
ConcreteTaskInstance,
TaskInstanceWithDeprecatedFields,
} from '../../../../plugins/task_manager/server/task';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { SavedObjectsUtils } from '../../../../../src/core/server/saved_objects';

Expand Down Expand Up @@ -76,5 +79,37 @@ export default function createGetTests({ getService }: FtrProviderContext) {
)}"}`
);
});

it('8.2.0 migrates tasks with unrecognized status to idle if task type is removed', async () => {
const response = await es.get<{ task: ConcreteTaskInstance }>(
{
index: '.kibana_task_manager',
id: 'task:ce7e1250-3322-11eb-94c1-db6995e84f6d',
},
{
meta: true,
}
);
expect(response.statusCode).to.eql(200);
expect(response.body._source?.task.taskType).to.eql(
`alerting:0359d7fcc04da9878ee9aadbda38ba55`
);
expect(response.body._source?.task.status).to.eql(`idle`);
});

it('8.2.0 does not migrate tasks with unrecognized status if task type is valid', async () => {
const response = await es.get<{ task: ConcreteTaskInstance }>(
{
index: '.kibana_task_manager',
id: 'task:fe7e1250-3322-11eb-94c1-db6395e84f6e',
},
{
meta: true,
}
);
expect(response.statusCode).to.eql(200);
expect(response.body._source?.task.taskType).to.eql(`sampleTaskRemovedType`);
expect(response.body._source?.task.status).to.eql(`unrecognized`);
});
});
}

0 comments on commit 821bc7d

Please sign in to comment.