Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Fix replication management tests #9136

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/lib/core/addon/components/replication-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import layout from '../templates/components/replication-header';

export default Component.extend({
layout,
data: null,
chelshaw marked this conversation as resolved.
Show resolved Hide resolved
classNames: ['replication-header'],
isSecondary: null,
secondaryId: null,
Expand Down
7 changes: 5 additions & 2 deletions ui/lib/core/addon/components/replication-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ export default Component.extend({
return false;
}),
message: computed('model.{anyReplicationEnabled}', 'formattedReplicationMode', function() {
let msg;
if (this.model.anyReplicationEnabled) {
return `This ${this.formattedReplicationMode} secondary has not been enabled. You can do so from the ${this.formattedReplicationMode} Primary.`;
msg = `This ${this.formattedReplicationMode} secondary has not been enabled. You can do so from the ${this.formattedReplicationMode} Primary.`;
} else {
msg = `This cluster has not been enabled as a ${this.formattedReplicationMode} Secondary. You can do so by enabling replication and adding a secondary from the ${this.formattedReplicationMode} Primary.`;
}
return `This cluster has not been enabled as a ${this.formattedReplicationMode} Secondary. You can do so by enabling replication and adding a secondary from the ${this.formattedReplicationMode} Primary.`;
return msg;
}),
});
1 change: 1 addition & 0 deletions ui/lib/core/addon/helpers/replication-action-for-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ACTIONS = {
},
dr: {
primary: ['disable', 'recover', 'reindex', 'demote'],
// TODO: add disable, recover, reindex and update-primary when API is ready
secondary: ['promote'],
bootstrapping: ['disable', 'recover', 'reindex'],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="action-block is-rounded">
<div class="action-block is-rounded" data-test-promote-replication>
<div class="action-block-info">
<h4 class="title is-5 is-marginless">
Promote cluster
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="action-block is-rounded">
<div class="action-block is-rounded" data-test-recover-replication>
<div class="action-block-info">
<h4 class="title is-5 is-marginless">
Recover
Expand Down Expand Up @@ -34,7 +34,6 @@
<footer class="modal-card-foot modal-card-foot-outlined">
<button
class="button is-primary"
disabled={{if (and (eq replicationMode "dr") (not dr_operation_token)) true}}
onclick={{action "onSubmit" "recover"}}
data-test-recover-confirm-button
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Reindex the local data storage
</p>
</div>

<div class="action-block-action">
<button
class="button is-secondary"
Expand All @@ -18,7 +17,6 @@
</button>
</div>
</div>

<Modal
@title="Begin reindex?"
@onClose={{action (mut isModalActive) false}}
Expand All @@ -28,25 +26,28 @@
>
<section class="modal-card-body">
<p class="has-bottom-margin-m">
Reindexing can cause a very long delay on the number and size of objects in the data store. {{if model.replicationAttrs.isPrimary 'You should always re-index your secondary first.'}}
Reindexing can cause a very long delay depending on the number and size of objects in the data store.
{{if model.replicationAttrs.isPrimary 'You should always re-index your secondary first.'}}
</p>
<p>
Progress will be shown, and you will {{ if model.replicationAttrs.isPrimary 'not' }} be able to use Vault during this time.
Progress will be shown, and you will
{{if model.replicationAttrs.isPrimary 'not'}}
chelshaw marked this conversation as resolved.
Show resolved Hide resolved
be able to use Vault during this time.
</p>
</section>
<footer class="modal-card-foot modal-card-foot-outlined">
<button
class="button is-primary"
disabled={{if (and (eq replicationMode "dr") (not dr_operation_token)) true}}
onclick={{action "onSubmit" "reindex"}}
onclick={{action 'onSubmit' 'reindex'}}
data-test-reindex-confirm-button
>
Reindex
</button>
<button
class="button is-secondary"
onclick={{action (mut isModalActive) false}}
data-test-reindex-cancel-button>
data-test-reindex-cancel-button
>
Cancel
</button>
</footer>
Expand Down
50 changes: 26 additions & 24 deletions ui/lib/core/addon/templates/components/replication-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
<p.levelLeft>
<h1 class="title is-3">
{{title}}
<span class="tag is-light has-text-grey-dark" data-test-mode>
{{if isSecondary 'secondary' 'primary'}}
</span>
<span class="tag is-light has-text-grey-dark" data-test-secondaryId>
{{secondaryId}}
</span>
{{#if data.anyReplicationEnabled}}
<span class="tag is-light has-text-grey-dark" data-test-mode>
{{if isSecondary 'secondary' 'primary'}}
</span>
<span class="tag is-light has-text-grey-dark" data-test-secondaryId>
{{secondaryId}}
</span>
{{/if}}
</h1>
</p.levelLeft>
</PageHeader>
Expand All @@ -49,25 +51,25 @@
<div class="tabs-container box is-bottomless is-fullwidth is-paddingless" data-test-tabs>
<nav class="tabs">
{{#if (not isSummaryDashboard )}}
<ul>
{{#link-to
"vault.cluster.replication-dr-promote.details"
tagName="li"
activeClass="is-active"
}}
{{#link-to "vault.cluster.replication-dr-promote.details"}}
Details
{{/link-to}}
{{/link-to}}
{{#link-to
"vault.cluster.replication-dr-promote"
tagName="li"
activeClass="is-active"
current-when="vault.cluster.replication-dr-promote.index"
}}
{{#link-to "vault.cluster.replication-dr-promote"}}
Manage
<ul>
{{#link-to
"vault.cluster.replication-dr-promote.details"
tagName="li"
activeClass="is-active"
}}
{{#link-to "vault.cluster.replication-dr-promote.details"}}
Details
{{/link-to}}
{{/link-to}}
{{#link-to
"vault.cluster.replication-dr-promote"
tagName="li"
activeClass="is-active"
current-when="vault.cluster.replication-dr-promote.index"
}}
{{#link-to "vault.cluster.replication-dr-promote"}}
Manage
{{/link-to}}
{{/link-to}}
</ul>
{{else}}
Expand Down
10 changes: 7 additions & 3 deletions ui/tests/acceptance/enterprise-replication-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const disableReplication = async (type, assert) => {
if (findAll('[data-test-replication-link="manage"]').length) {
await click('[data-test-replication-link="manage"]');
await click('[data-test-disable-replication] button');

const typeDisplay = type === 'dr' ? 'Disaster Recovery' : 'Performance';
await fillIn('[data-test-confirmation-modal-input]', typeDisplay);
await click('[data-test-confirm-button]');
if (assert) {
assert.equal(currentURL(), `/vault/replication`, 'redirects to the replication page');
Expand Down Expand Up @@ -121,7 +124,7 @@ module('Acceptance | Enterprise | replication', function(hooks) {
`/vault/replication/performance/secondaries`,
'redirects to the secondaries page'
);
// nav back to details page and confirm secondary is in the know secondaries table
// nav back to details page and confirm secondary is in the known secondaries table
await click('[data-test-replication-link="details"]');
await settled();
assert
Expand Down Expand Up @@ -254,9 +257,10 @@ module('Acceptance | Enterprise | replication', function(hooks) {
await click('[data-test-replication-enable]');
await pollCluster(this.owner);
await settled();
await click('[data-test-replication-link="manage"]');

let demote = document.querySelectorAll('[data-test-confirm-action-trigger="true"]')[1];
// demote perf primary to a secondary
await click('[data-test-replication-link="manage"]');
const demote = document.querySelector('[data-test-replication-demote]').firstElementChild;
await click(demote);
await click('[data-test-confirm-button="true"]');
await click('[data-test-replication-link="details"]');
Expand Down
102 changes: 66 additions & 36 deletions ui/tests/integration/components/replication-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,54 @@ module('Integration | Component | replication actions', function(hooks) {
});

let testCases = [
['dr', 'primary', 'disable', 'Disable Replication', null, ['disable', 'primary'], false],
['performance', 'primary', 'disable', 'Disable Replication', null, ['disable', 'primary'], false],
['dr', 'secondary', 'disable', 'Disable Replication', null, ['disable', 'secondary'], false],
['performance', 'secondary', 'disable', 'Disable Replication', null, ['disable', 'secondary'], false],
['dr', 'primary', 'recover', 'Recover', null, ['recover'], true],
['performance', 'primary', 'recover', 'Recover', null, ['recover'], true],
['performance', 'secondary', 'recover', 'Recover', null, ['recover'], true],
[
'dr',
'primary',
'disable',
'Disable Replication',
async function() {
fillIn('[data-test-confirmation-modal-input]', 'Disaster Recovery');
},
['disable', 'primary'],
false,
],
[
'performance',
'primary',
'disable',
'Disable Replication',
async function() {
fillIn('[data-test-confirmation-modal-input]', 'Performance');
},
['disable', 'primary'],
false,
],
[
'performance',
'secondary',
'disable',
'Disable Replication',
async function() {
fillIn('[data-test-confirmation-modal-input]', 'Disaster Recovery');
andaley marked this conversation as resolved.
Show resolved Hide resolved
},
['disable', 'secondary'],
false,
],
['dr', 'primary', 'recover', 'Recover', null, ['recover'], false],
['performance', 'primary', 'recover', 'Recover', null, ['recover'], false],
['performance', 'secondary', 'recover', 'Recover', null, ['recover'], false],

['dr', 'primary', 'reindex', 'Reindex', null, ['reindex'], false],
['performance', 'primary', 'reindex', 'Reindex', null, ['reindex'], false],
['performance', 'secondary', 'reindex', 'Reindex', null, ['reindex'], false],

['dr', 'primary', 'reindex', 'Reindex', null, ['reindex'], true],
['performance', 'primary', 'reindex', 'Reindex', null, ['reindex'], true],
['dr', 'secondary', 'reindex', 'Reindex', null, ['reindex'], true],
['performance', 'secondary', 'reindex', 'Reindex', null, ['reindex'], true],
// ['dr', 'primary', 'demote', 'Demote cluster', null, ['demote', 'primary'], true],
// ['performance', 'primary', 'demote', 'Demote cluster', null, ['demote', 'primary'], true],

['dr', 'primary', 'demote', 'Demote cluster', null, ['demote', 'primary'], true],
['performance', 'primary', 'demote', 'Demote cluster', null, ['demote', 'primary'], true],
// we don't do dr secondary promote in this component so just test perf
// re-enable this test when the DR secondary disable API endpoint is fixed
// ['dr', 'secondary', 'disable', 'Disable Replication', null, ['disable', 'secondary'], false],
// ['dr', 'secondary', 'reindex', 'Reindex', null, ['reindex'], false],
[
'performance',
'secondary',
Expand All @@ -65,24 +97,24 @@ module('Integration | Component | replication actions', function(hooks) {
await blur('[name="primary_cluster_addr"]');
},
['promote', 'secondary', { primary_cluster_addr: 'cluster addr' }],
true,
false,
],

// don't yet update-primary for dr
[
'performance',
'secondary',
'update-primary',
'Update primary',
async function() {
await fillIn('#secondary-token', 'token');
await blur('#secondary-token');
await fillIn('#primary_api_addr', 'addr');
await blur('#primary_api_addr');
},
['update-primary', 'secondary', { token: 'token', primary_api_addr: 'addr' }],
true,
],
// [
// 'performance',
// 'secondary',
// 'update-primary',
// 'Update primary',
// async function() {
// await fillIn('#secondary-token', 'token');
// await blur('#secondary-token');
// await fillIn('#primary_api_addr', 'addr');
// await blur('#primary_api_addr');
// },
// ['update-primary', 'secondary', { token: 'token', primary_api_addr: 'addr' }],
// true,
// ],
];

for (let [
Expand Down Expand Up @@ -126,24 +158,22 @@ module('Integration | Component | replication actions', function(hooks) {
{{replication-actions model=model replicationMode=replicationMode selectedAction=selectedAction onSubmit=(action onSubmit)}}
`
);

let selector = oldVersion ? 'h4' : `[data-test-${action}-replication] h4`;
assert.equal(
find('h4').textContent.trim(),
find(selector).textContent.trim(),
headerText,
`${testKey}: renders the correct component header (${oldVersion})`
);

if (typeof fillInFn === 'function') {
await fillInFn.call(this);
}
if (oldVersion) {
await click('[data-test-confirm-action-trigger]');
await click('[data-test-confirm-button]');
} else {
await click('[data-test-replication-action-trigger]');
await fillIn(
'[data-test-confirmation-modal-input]',
replicationMode === 'dr' ? 'Disaster Recovery' : 'Performance'
);
if (typeof fillInFn === 'function') {
await fillInFn.call(this);
}
await blur('[data-test-confirmation-modal-input]');
await click('[data-test-confirm-button]');
}
Expand Down
15 changes: 15 additions & 0 deletions ui/tests/integration/components/replication-header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

const DATA = {
anyReplicationEnabled: true,
dr: {
mode: 'secondary',
rm: {
Expand Down Expand Up @@ -41,6 +42,20 @@ module('Integration | Enterprise | Component | replication-header', function(hoo
assert.dom('[data-test-mode]').includesText('secondary', `shows the correct mode value`);
});

test('it does not render mode or secondaryId when replication is not enabled', async function(assert) {
const notEnabled = { anyReplicationEnabled: false };
const noId = null;
this.set('data', notEnabled);
this.set('secondaryId', noId);

await render(
hbs`<ReplicationHeader @data={{data}} @isSecondary={{isSecondary}} @title={{title}} @secondaryId={{secondaryId}}/>`
);

assert.dom('[data-test-secondaryId]').doesNotExist();
assert.dom('[data-test-mode]').doesNotExist();
});

test('it does not show tabs when showTabs is not set', async function(assert) {
await render(hbs`<ReplicationHeader @data={{data}} @isSecondary={{isSecondary}} @title={{title}}/>`);

Expand Down