Skip to content

Commit

Permalink
[Ingest Manager] add skipIfNoDockerRegistry to package_install_comple…
Browse files Browse the repository at this point in the history
…te test (#80779) (#80817)

* fix missing skipIfNoDockerRegistry

* skip afterEach if server doesn't exist
  • Loading branch information
neptunian authored Oct 16, 2020
1 parent 0288a85 commit 7120827
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const es = getService('es');
const dockerServers = getService('dockerServers');
const server = dockerServers.get('registry');
const pkgName = 'datastreams';
const pkgVersion = '0.1.0';
const pkgUpdateVersion = '0.2.0';
Expand Down Expand Up @@ -63,6 +65,7 @@ export default function (providerContext: FtrProviderContext) {
});
});
afterEach(async () => {
if (!server) return;
await es.transport.request({
method: 'DELETE',
path: `/_data_stream/${logsTemplateName}-default`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
PACKAGES_SAVED_OBJECT_TYPE,
MAX_TIME_COMPLETE_INSTALL,
} from '../../../../plugins/ingest_manager/common';
import { skipIfNoDockerRegistry } from '../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';

export default function (providerContext: FtrProviderContext) {
Expand All @@ -19,20 +20,22 @@ export default function (providerContext: FtrProviderContext) {
const pkgVersion = '0.1.0';
const pkgUpdateVersion = '0.2.0';
describe('setup checks packages completed install', async () => {
skipIfNoDockerRegistry(providerContext);
describe('package install', async () => {
before(async () => {
await supertest
.post(`/api/fleet/epm/packages/${pkgName}-0.1.0`)
.set('kbn-xsrf', 'xxxx')
.send({ force: true });
.send({ force: true })
.expect(200);
});
it('should have not reinstalled if package install completed', async function () {
const packageBeforeSetup = await kibanaServer.savedObjects.get({
type: 'epm-packages',
id: pkgName,
});
const installStartedAtBeforeSetup = packageBeforeSetup.attributes.install_started_at;
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -51,7 +54,7 @@ export default function (providerContext: FtrProviderContext) {
install_started_at: previousInstallDate,
},
});
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -71,7 +74,7 @@ export default function (providerContext: FtrProviderContext) {
install_started_at: previousInstallDate,
},
});
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -83,27 +86,30 @@ export default function (providerContext: FtrProviderContext) {
after(async () => {
await supertest
.delete(`/api/fleet/epm/packages/multiple_versions-0.1.0`)
.set('kbn-xsrf', 'xxxx');
.set('kbn-xsrf', 'xxxx')
.expect(200);
});
});
describe('package update', async () => {
before(async () => {
await supertest
.post(`/api/fleet/epm/packages/${pkgName}-0.1.0`)
.set('kbn-xsrf', 'xxxx')
.send({ force: true });
.send({ force: true })
.expect(200);
await supertest
.post(`/api/fleet/epm/packages/${pkgName}-0.2.0`)
.set('kbn-xsrf', 'xxxx')
.send({ force: true });
.send({ force: true })
.expect(200);
});
it('should have not reinstalled if package update completed', async function () {
const packageBeforeSetup = await kibanaServer.savedObjects.get({
type: 'epm-packages',
id: pkgName,
});
const installStartedAtBeforeSetup = packageBeforeSetup.attributes.install_started_at;
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -124,7 +130,7 @@ export default function (providerContext: FtrProviderContext) {
install_version: pkgUpdateVersion, // set version back
},
});
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -147,7 +153,7 @@ export default function (providerContext: FtrProviderContext) {
version: pkgVersion, // set version back
},
});
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').expect(200);
const packageAfterSetup = await kibanaServer.savedObjects.get({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: pkgName,
Expand All @@ -160,7 +166,8 @@ export default function (providerContext: FtrProviderContext) {
after(async () => {
await supertest
.delete(`/api/fleet/epm/packages/multiple_versions-0.1.0`)
.set('kbn-xsrf', 'xxxx');
.set('kbn-xsrf', 'xxxx')
.expect(200);
});
});
});
Expand Down

0 comments on commit 7120827

Please sign in to comment.