open-vault/ui/tests/acceptance/enterprise-replication-test.js

162 lines
6 KiB
JavaScript
Raw Normal View History

import { click, fillIn, findAll, currentURL, find, visit, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import authPage from 'vault/tests/pages/auth';
import { pollCluster } from 'vault/tests/helpers/poll-cluster';
import { create } from 'ember-cli-page-object';
import flashMessage from 'vault/tests/pages/components/flash-message';
const flash = create(flashMessage);
const disableReplication = async (type, assert) => {
2018-04-03 14:16:57 +00:00
// disable performance replication
await visit(`/vault/replication/${type}`);
if (findAll('[data-test-replication-link="manage"]').length) {
await click('[data-test-replication-link="manage"]');
await click('[data-test-disable-replication] button');
await click('[data-test-confirm-button]');
if (assert) {
assert.equal(currentURL(), `/vault/replication`, 'redirects to the replication page');
assert.equal(
flash.latestMessage,
'This cluster is having replication disabled. Vault will be unavailable for a brief period and will resume service shortly.',
'renders info flash when disabled'
);
}
await settled();
}
2018-04-03 14:16:57 +00:00
};
module('Acceptance | Enterprise | replication', function(hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(async function() {
await authPage.login();
await disableReplication('dr');
await disableReplication('performance');
});
hooks.afterEach(async function() {
await disableReplication('dr');
await disableReplication('performance');
});
2018-04-03 14:16:57 +00:00
test('replication', async function(assert) {
const secondaryName = 'firstSecondary';
const mode = 'blacklist';
const mountType = 'kv';
let mountPath;
2018-04-03 14:16:57 +00:00
await visit('/vault/replication');
2018-04-03 14:16:57 +00:00
assert.equal(currentURL(), '/vault/replication');
// enable perf replication
await click('[data-test-replication-type-select="performance"]');
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
2018-04-03 14:16:57 +00:00
await click('[data-test-replication-enable]');
await pollCluster(this.owner);
2018-04-03 14:16:57 +00:00
// add a secondary with a mount filter config
await click('[data-test-replication-link="secondaries"]');
await click('[data-test-secondary-add]');
await fillIn('[data-test-replication-secondary-id]', secondaryName);
//expand the config
await click('[data-test-replication-secondary-token-options]');
await fillIn('[data-test-replication-filter-mount-mode]', mode);
await click(findAll(`[data-test-mount-filter="${mountType}"]`)[0]);
mountPath = findAll(`[data-test-mount-filter-path-for-type="${mountType}"]`)[0].textContent.trim();
await click('[data-test-secondary-add]');
2018-04-03 14:16:57 +00:00
await pollCluster(this.owner);
2018-04-03 14:16:57 +00:00
// click into the added secondary's mount filter config
await click('[data-test-replication-link="secondaries"]');
await click('[data-test-popup-menu-trigger]');
2018-04-03 14:16:57 +00:00
await click('[data-test-replication-mount-filter-link]');
2018-04-03 14:16:57 +00:00
assert.equal(currentURL(), `/vault/replication/performance/secondaries/config/show/${secondaryName}`);
assert.ok(
find('[data-test-mount-config-mode]')
.textContent.trim()
.toLowerCase()
.includes(mode),
2018-04-03 14:16:57 +00:00
'show page renders the correct mode'
);
assert
.dom('[data-test-mount-config-paths]')
.hasText(mountPath, 'show page renders the correct mount path');
// click edit
// delete config
await click('[data-test-replication-link="edit-mount-config"]');
await click('[data-test-delete-mount-config] button');
await click('[data-test-confirm-button]');
assert.equal(
flash.latestMessage,
`The performance mount filter config for the secondary ${secondaryName} was successfully deleted.`,
'renders success flash upon deletion'
);
2018-04-03 14:16:57 +00:00
assert.equal(
currentURL(),
`/vault/replication/performance/secondaries`,
'redirects to the secondaries page'
);
// nav to DR
await visit('/vault/replication/dr');
await fillIn('[data-test-replication-cluster-mode-select]', 'secondary');
2018-04-03 14:16:57 +00:00
assert.ok(
find('[data-test-replication-enable]:disabled'),
2018-04-03 14:16:57 +00:00
'dr secondary enable is disabled when other replication modes are on'
);
// disable performance replication
await disableReplication('performance', assert);
await pollCluster(this.owner);
// enable dr replication
await visit('vault/replication/dr');
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
await click('button[type="submit"]');
await pollCluster(this.owner);
2018-04-03 14:16:57 +00:00
assert.ok(
find('[data-test-replication-title]').textContent.includes('Disaster Recovery'),
2018-04-03 14:16:57 +00:00
'it displays the replication type correctly'
);
assert.ok(
find('[data-test-replication-mode-display]').textContent.includes('primary'),
2018-04-03 14:16:57 +00:00
'it displays the cluster mode correctly'
);
// add dr secondary
await click('[data-test-replication-link="secondaries"]');
await click('[data-test-secondary-add]');
await fillIn('[data-test-replication-secondary-id]', secondaryName);
await click('[data-test-secondary-add]');
await pollCluster(this.owner);
await pollCluster(this.owner);
await click('[data-test-replication-link="secondaries"]');
assert
.dom('[data-test-secondary-name]')
.includesText(secondaryName, 'it displays the secondary in the list of known secondaries');
2018-04-03 14:16:57 +00:00
});
test('disabling dr primary when perf replication is enabled', async function(assert) {
await visit('vault/replication/performance');
// enable perf replication
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
await click('[data-test-replication-enable]');
await pollCluster(this.owner);
// enable dr replication
await visit('/vault/replication/dr');
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
await click('[data-test-replication-enable]');
await pollCluster(this.owner);
await visit('/vault/replication/dr/manage');
assert.ok(findAll('[data-test-demote-warning]').length, 'displays the demotion warning');
2018-04-03 14:16:57 +00:00
});
});