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

Sidebranch: Performance Secondary Dashboard #8956

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions ui/app/styles/components/replication-dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@
.selectable-card-container {
margin-top: $spacing-xl;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
grid-template-rows: 1fr;
grid-gap: $spacing-xl;

&.primary {
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
margin: 2rem 0 2rem 0;
grid-template-columns: 1fr 2fr;

@include until($mobile) {
grid-template-columns: 1fr;
}
}

&.secondary {
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
grid-gap: $spacing-xl; //ARG TODO double check ok
}

.card-container {
display: grid;
Expand Down
8 changes: 0 additions & 8 deletions ui/app/styles/components/replication-summary.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
.replication {
.selectable-card-container {
grid-template-columns: 1fr 2fr;

@include until($mobile) {
grid-template-columns: 1fr;
}
}

.toolbar {
border-top: 0px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</nav>
</EmptyState>
{{else}}
<Page.toggle />
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
<Page.dashboard
{{!-- passing in component to render so that the yielded components are flexible based on the dashboard --}}
@componentToRender='replication-secondary-card' as |Dashboard|>
Expand Down
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 @@ -4,5 +4,6 @@ import layout from '../templates/components/replication-header';
export default Component.extend({
layout,
isSecondary: null,
secondaryId: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we check for secondaryId instead of using isSecondary ? basically consolidating those attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought, but they're pretty different, both of these properties are passed down from different places. So secondaryIdcomes from replicationAttrs model, and the isSecondary is a computed property set on the top parent of the contextual components that this component is nested under. And in some cases you can have isSecondary = true, but null for secondaryId (that happens if you demote a DR Primary to Secondary.

'data-test-replication-header': true,
});
1 change: 0 additions & 1 deletion ui/lib/core/addon/components/replication-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default Component.extend({
}
this.set('reindexingDetails', resp);
}),

replicationMode: computed('model.{replicationMode}', function() {
// dr or performance 🤯
let mode = this.model.replicationMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
data-test-isReindexing />
</div>
{{/if}}

<div class="selectable-card-container">
<div
class="selectable-card-container {{if isSecondary 'secondary' 'primary'}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so here i think it would be {{unless (eq secondaryId null) 'secondary' 'primary'}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you can be a Secondary, but not have a secondaryId, we can't really do this one. ☹️

data-test-selectable-card-container={{if isSecondary 'secondary' 'primary'}}>
{{yield (hash
card=(component componentToRender replicationDetails=replicationDetails)
)}}
{{#if (not isSecondary)}}
{{yield (hash secondaryCard=(component 'known-secondaries-card'))}}
{{/if}}

</div>
{{#if isSyncing}}
<div class="syncing-alert">
Expand Down
8 changes: 4 additions & 4 deletions ui/lib/core/addon/templates/components/replication-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
<p.levelLeft>
<h1 class="title is-3">
{{title}}
<span class="tag" data-test-mode>
{{if isSecondary 'Secondary' 'Primary'}}
<span class="tag is-light has-text-grey-dark" data-test-mode>
{{if isSecondary 'secondary' 'primary'}}
</span>
<span class="tag" data-test-clusterId>
{{data.dr.clusterIdDisplay}}
<span class="tag is-light has-text-grey-dark" data-test-secondaryId>
{{secondaryId}}
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
</span>
</h1>
</p.levelLeft>
Expand Down
7 changes: 6 additions & 1 deletion ui/lib/core/addon/templates/components/replication-page.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<div class="replication-page" data-test-replication-page>
{{yield
(hash
header=(component 'replication-header' data=model title=replicationMode isSecondary=isSecondary)
header=(component 'replication-header'
data=model
title=replicationMode
isSecondary=isSecondary
secondaryId=replicationDetails.secondaryId
)
dashboard=(component
'replication-dashboard'
data=model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
href={{primaryClusterAddr}}
class="link"
target="_blank"
rel="noreferrer noopener"
rel="noreferrer noopener"
data-test-primaryClusterAddr
>
{{primaryClusterAddr}}
</a>
Expand All @@ -67,7 +68,7 @@
<p class="has-text-grey is-size-8">unknown</p>
{{/if}}
</div>
<h2 class="title is-3 grid-item-left-bottom">{{format-number lastRemoteWAL}}</h2>
<h2 class="title is-3 grid-item-left-bottom" data-test-lastRemoteWAL>{{format-number lastRemoteWAL}}</h2>
<div class="grid-item-right-bottom">
{{!-- Empty --}}
</div>
Expand Down
1 change: 1 addition & 0 deletions ui/lib/core/app/helpers/format-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, formatNumber } from 'core/helpers/format-number';
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,31 @@
<p>{{cluster.replicationModeStatus.cluster_id}}</p>
<div class="replication">
<ReplicationPage @model={{cluster}} as |Page|>
<Page.dashboard @data={{cluster}} @componentToRender='replication-primary-card' as |Dashboard|>
<Dashboard.card
@title='State'
@description='Updated every ten seconds.'
@glyph={{get (cluster-states replicationAttrs.state) "glyph"}}
@metric={{replicationAttrs.state}} />
<Dashboard.card
@title='Last WAL entry'
@description='Index of last Write Ahead Logs entry written on local storage.'
@metric={{replicationAttrs.lastWAL}} />
<Dashboard.secondaryCard
@cluster={{cluster}}
@replicationAttrs={{replicationAttrs}} />
<Page.dashboard
@data={{cluster}}
@componentToRender={{if (eq replicationAttrs.mode 'secondary') 'replication-secondary-card' 'replication-primary-card' }}
as |Dashboard|>
{{#if (eq replicationAttrs.mode 'secondary')}}
<Dashboard.card
@title="States"
/>
<Dashboard.card
@title="Primary cluster"
/>
{{else}}
<Dashboard.card
@title='State'
@description='Updated every ten seconds.'
@glyph={{get (cluster-states replicationAttrs.state) "glyph"}}
@metric={{replicationAttrs.state}} />
<Dashboard.card
@title='Last WAL entry'
@description='Index of last Write Ahead Logs entry written on local storage.'
@metric={{replicationAttrs.lastWAL}} />
<Dashboard.secondaryCard
@cluster={{cluster}}
@replicationAttrs={{replicationAttrs}} />
{{/if}}
</Page.dashboard>
</ReplicationPage>
</div>
Expand Down
13 changes: 7 additions & 6 deletions ui/lib/replication/addon/templates/mode.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
<span class="tag is-light has-text-grey-dark" data-test-replication-mode-display=true>
{{model.replicationAttrs.modeForUrl}}
</span>
{{#if secondaryId}}
{{#if model.replicationAttrs.secondaryId}}
<span class="tag is-light has-text-grey-dark">
<code>
{{model.replicationAttrs.secondaryId}}
</code>
</span>
{{else}}
<span class="tag is-light has-text-grey-dark">
<code>
{{model.replicationAttrs.clusterIdDisplay}}
</code>
</span>
{{/if}}
<span class="tag is-light">
<code class="has-text-grey-dark">
{{model.replicationAttrs.clusterIdDisplay}}
</code>
</span>
</h1>
</p.levelLeft>
</PageHeader>
Expand Down
32 changes: 28 additions & 4 deletions ui/tests/acceptance/enterprise-replication-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ module('Acceptance | Enterprise | replication', function(hooks) {
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);

Expand All @@ -192,22 +191,47 @@ module('Acceptance | Enterprise | replication', function(hooks) {
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');
});

test('navigating to dr secondary details page', async function(assert) {
test('navigating to dr secondary details page when dr secondary is not enabled', async function(assert) {
// 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-promote/details');

assert.dom('[data-test-component="empty-state"]').exists();
assert.equal(
find('[data-test-empty-state-message]').textContent.trim(),
'This Disaster Recovery secondary has not been enabled. You can do so from the Disaster Recovery Primary.',
'renders default message specific to when no replication is enabled'
'renders message when replication is enabled'
);
});

test('render performance secondary and navigate to the details page', async function(assert) {
// enable perf replication
await visit('/vault/replication');
await click('[data-test-replication-type-select="performance"]');
await fillIn('[data-test-replication-cluster-mode-select]', 'primary');
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];
await click(demote);
await click('[data-test-confirm-button="true"]');
await click('[data-test-replication-link="details"]');

assert.dom('[data-test-replication-dashboard]').exists();
assert.dom('[data-test-selectable-card-container="secondary"]').exists();
assert.ok(
find('[data-test-replication-mode-display]').textContent.includes('secondary'),
'it displays the cluster mode correctly'
);
});
});
18 changes: 0 additions & 18 deletions ui/tests/acceptance/replication/dr/secondary-test.js

This file was deleted.

16 changes: 16 additions & 0 deletions ui/tests/integration/components/replication-dashboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import hbs from 'htmlbars-inline-precompile';
const REPLICATION_DETAILS = {
state: 'stream-wals',
primaryClusterAddr: 'https://127.0.0.1:8201',
merkleRoot: '352f6e58ba2e8ec3935e05da1d142653dc76fe17',
clusterId: '68999e13-a09d-b5e4-d66c-b35da566a177',
};

const IS_SYNCING = {
Expand Down Expand Up @@ -40,10 +42,24 @@ module('Integration | Enterprise | Component | replication-dashboard', function(

assert.dom('[data-test-replication-dashboard]').exists();
assert.dom('[data-test-table-rows').exists();
assert.dom('[data-test-selectable-card-container="secondary"]').exists();
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
assert.dom('[data-test-replication-doc-link]').exists();
assert.dom('[data-test-flash-message]').doesNotExist('no flash message is displayed on render');
});

test('it renders the primary selectable-card-container when the cluster is a primary', async function(assert) {
this.set('replicationDetails', REPLICATION_DETAILS);
this.set('isSecondary', false);

await render(hbs`<ReplicationDashboard
@replicationDetails={{replicationDetails}}
@clusterMode={{clusterMode}}
@isSecondary={{isSecondary}}
/>`);

assert.dom('[data-test-selectable-card-container="primary"]').exists();
});

test('it renders an alert banner if the dashboard is syncing', async function(assert) {
this.set('replicationDetails', IS_SYNCING);

Expand Down
16 changes: 8 additions & 8 deletions ui/tests/integration/components/replication-header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const DATA = {
rm: {
mode: 'dr',
},
clusterIdDisplay: 12345,
},
unsealed: 'good',
};

const TITLE = 'Disaster Recovery';
const SECONDARY_ID = '123abc';

module('Integration | Enterprise | Component | replication-header', function(hooks) {
setupRenderingTest(hooks);
Expand All @@ -23,6 +23,7 @@ module('Integration | Enterprise | Component | replication-header', function(hoo
this.set('data', DATA);
this.set('title', TITLE);
this.set('isSecondary', true);
this.set('secondaryId', SECONDARY_ID);
});

test('it renders', async function(assert) {
Expand All @@ -31,14 +32,13 @@ module('Integration | Enterprise | Component | replication-header', function(hoo
assert.dom('[data-test-replication-header]').exists();
});

test('it renders with clusterId and mode when set', async function(assert) {
await render(hbs`<ReplicationHeader @data={{data}} @isSecondary={{isSecondary}} @title={{title}}/>`);

assert
.dom('[data-test-clusterId]')
.includesText(DATA.dr.clusterIdDisplay, `shows the correct clusterId value`);
test('it renders with mode and secondaryId when set', async function(assert) {
await render(
hbs`<ReplicationHeader @data={{data}} @isSecondary={{isSecondary}} @title={{title}} @secondaryId={{secondaryId}}/>`
);

assert.dom('[data-test-mode]').includesText('Secondary', `shows the correct mode value`);
assert.dom('[data-test-secondaryId]').includesText(SECONDARY_ID, `shows the correct secondaryId value`);
assert.dom('[data-test-mode]').includesText('secondary', `shows the correct mode value`);
});

test('it does not show tabs when showTabs is not set', async function(assert) {
Expand Down