Skip to content

Commit

Permalink
Add integration test for direct package upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed Sep 14, 2020
1 parent d8f3203 commit ad58cdf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function loadTests({ loadTestFile }) {
loadTestFile(require.resolve('./file'));
//loadTestFile(require.resolve('./template'));
loadTestFile(require.resolve('./ilm'));
loadTestFile(require.resolve('./install_by_upload'));
loadTestFile(require.resolve('./install_overrides'));
loadTestFile(require.resolve('./install_prerelease'));
loadTestFile(require.resolve('./install_remove_assets'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import fs from 'fs';
import path from 'path';
import expect from '@kbn/expect';

import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { warnAndSkipTest } from '../../helpers';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const dockerServers = getService('dockerServers');
const log = getService('log');

const testPkgArchiveTgz = path.join(
path.dirname(__filename),
'../fixtures/direct_upload_packages/apache_0.1.4.tar.gz'
);
const testPkgKey = 'apache-0.14';
const server = dockerServers.get('registry');

const deletePackage = async (pkgkey: string) => {
await supertest.delete(`/api/ingest_manager/epm/packages/${pkgkey}`).set('kbn-xsrf', 'xxxx');
};

describe('installs packages from direct upload', async () => {
after(async () => {
if (server.enabled) {
// remove the package just in case it being installed will affect other tests
await deletePackage(testPkgKey);
}
});

it('should install a tar archive correctly', async function () {
if (server.enabled) {
const buf = fs.readFileSync(testPkgArchiveTgz);
const res = await supertest
.post(`/api/ingest_manager/epm/packages`)
.set('kbn-xsrf', 'xxxx')
.type('application/gzip')
.send(buf)
.expect(200);
expect(res.body.response).to.equal(
'package upload was received ok, but not installed (not implemented yet)'
);
} else {
warnAndSkipTest(this, log);
}
});
});
}
Binary file not shown.

0 comments on commit ad58cdf

Please sign in to comment.