2018-09-25 16:28:26 +00:00
|
|
|
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';
|
2019-04-10 14:36:32 +00:00
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
import flashMessage from 'vault/tests/pages/components/flash-message';
|
|
|
|
const flash = create(flashMessage);
|
2018-09-25 16:28:26 +00:00
|
|
|
|
|
|
|
const disableReplication = async (type, assert) => {
|
2018-04-03 14:16:57 +00:00
|
|
|
// disable performance replication
|
2018-09-25 16:28:26 +00:00
|
|
|
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');
|
2019-04-10 14:36:32 +00:00
|
|
|
await click('[data-test-confirm-button]');
|
|
|
|
if (assert) {
|
2019-05-13 19:05:25 +00:00
|
|
|
assert.equal(currentURL(), `/vault/replication`, 'redirects to the replication page');
|
2019-04-10 14:36:32 +00:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
}
|
2018-09-25 16:28:26 +00:00
|
|
|
await settled();
|
|
|
|
}
|
2018-04-03 14:16:57 +00:00
|
|
|
};
|
2018-09-25 16:28:26 +00:00
|
|
|
|
|
|
|
module('Acceptance | Enterprise | replication', function(hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
|
|
|
|
|
|
|
hooks.beforeEach(async function() {
|
|
|
|
await authPage.login();
|
|
|
|
await disableReplication('dr');
|
2019-05-13 19:05:25 +00:00
|
|
|
await disableReplication('performance');
|
2018-09-25 16:28:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
hooks.afterEach(async function() {
|
|
|
|
await disableReplication('dr');
|
2019-05-13 19:05:25 +00:00
|
|
|
await disableReplication('performance');
|
2018-09-25 16:28:26 +00:00
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +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
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await visit('/vault/replication');
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(currentURL(), '/vault/replication');
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
// 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
|
|
|
|
2019-04-10 14:36:32 +00:00
|
|
|
await click('[data-test-replication-enable]');
|
2018-09-25 16:28:26 +00:00
|
|
|
await pollCluster(this.owner);
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +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
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await pollCluster(this.owner);
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +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
|
|
|
|
2018-09-25 16:28:26 +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(
|
2018-09-25 16:28:26 +00:00
|
|
|
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'
|
|
|
|
);
|
2018-05-24 03:10:21 +00:00
|
|
|
assert
|
|
|
|
.dom('[data-test-mount-config-paths]')
|
|
|
|
.hasText(mountPath, 'show page renders the correct mount path');
|
2018-09-25 16:28:26 +00:00
|
|
|
// click edit
|
|
|
|
|
|
|
|
// delete config
|
|
|
|
await click('[data-test-replication-link="edit-mount-config"]');
|
|
|
|
await click('[data-test-delete-mount-config] button');
|
2019-04-10 14:36:32 +00:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
// 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(
|
2018-09-25 16:28:26 +00:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
// 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');
|
2019-04-10 14:36:32 +00:00
|
|
|
await click('button[type="submit"]');
|
2018-09-25 16:28:26 +00:00
|
|
|
|
|
|
|
await pollCluster(this.owner);
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.ok(
|
2018-09-25 16:28:26 +00:00
|
|
|
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(
|
2018-09-25 16:28:26 +00:00
|
|
|
find('[data-test-replication-mode-display]').textContent.includes('primary'),
|
2018-04-03 14:16:57 +00:00
|
|
|
'it displays the cluster mode correctly'
|
|
|
|
);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
// 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"]');
|
2018-05-24 03:10:21 +00:00
|
|
|
assert
|
|
|
|
.dom('[data-test-secondary-name]')
|
2019-05-13 19:05:25 +00:00
|
|
|
.includesText(secondaryName, 'it displays the secondary in the list of known secondaries');
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +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');
|
|
|
|
|
2019-04-10 14:36:32 +00:00
|
|
|
await click('[data-test-replication-enable]');
|
2018-09-25 16:28:26 +00:00
|
|
|
await pollCluster(this.owner);
|
|
|
|
|
|
|
|
// enable dr replication
|
|
|
|
await visit('/vault/replication/dr');
|
|
|
|
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
|
2019-04-10 14:36:32 +00:00
|
|
|
await click('[data-test-replication-enable]');
|
2018-09-25 16:28:26 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|