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

[Backport 2.x] Add cypress test of index management dashboards plugin on 2.8 #695

Merged
merged 1 commit into from
May 30, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ describe('Aliases', () => {
});
});

describe('can clear cache for an alias', () => {
it('successfully', () => {
cy.get('[placeholder="Search..."]').type(
`${SAMPLE_ALIAS_PREFIX}-0{enter}`
);
cy.contains(`${SAMPLE_ALIAS_PREFIX}-0`);
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="ClearCacheAction"]')
.should('be.disabled')
.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-0-checkbox`)
.click()
.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="ClearCacheAction"]')
.click();

// Check for clear cache index modal
cy.contains('Clear cache');
cy.get('[data-test-subj="ClearCacheConfirmButton"]').should(
'not.be.disabled'
);
// click to clear caches
cy.get('[data-test-subj="ClearCacheConfirmButton"]').click();
// Check for success toast
cy.contains(
`Cache for ${SAMPLE_ALIAS_PREFIX}-0 has been successfully cleared.`
);
});
});

describe('can edit / delete a alias', () => {
it('successfully', () => {
cy.get('[placeholder="Search..."]').type(
Expand Down Expand Up @@ -109,6 +140,112 @@ describe('Aliases', () => {
});
});

describe('can flush an alias', () => {
it('successfully flush an index', () => {
let sample_alias = `${SAMPLE_ALIAS_PREFIX}-${1}`;
// Sort all aliases in asc order to make it at first page
cy.contains('Alias name').click();
// Confirm we have our initial alias
cy.contains(sample_alias);
// index a test doc
cy.request({
method: 'POST',
url: `${Cypress.env('openSearchUrl')}/${sample_alias}/_doc`,
headers: {
'content-type': 'application/json;charset=UTF-8',
},
body: { test: 'test' },
});

// confirm uncommitted_operations is 1 after indexing doc
cy.request({
method: 'GET',
url: `${Cypress.env('openSearchUrl')}/${sample_alias}/_stats/translog`,
}).then((response) => {
let response_obj = JSON.parse(
response['allRequestResponses'][0]['Response Body']
);
let num =
response_obj['_all']['total']['translog']['uncommitted_operations'];
expect(num).to.equal(1);
});

cy.get('[data-test-subj="moreAction"]').click();
// Flush btn should be disabled if no items selected
cy.get('[data-test-subj="Flush Action"]').should(
'have.class',
'euiContextMenuItem-isDisabled'
);

// Select an alias
cy.get(`[data-test-subj="checkboxSelectRow-${sample_alias}"]`).check({
force: true,
});

cy.get('[data-test-subj="moreAction"]').click();
// Flush btn should be enabled
cy.get('[data-test-subj="Flush Action"]')
.should('exist')
.should('not.have.class', 'euiContextMenuItem-isDisabled')
.click();

// Check for flush index modal
cy.contains('Flush alias');

cy.get('[data-test-subj="flushConfirmButton"]').click();

// Check for success toast
cy.contains(`The alias ${sample_alias} has been successfully flushed.`);

// confirm uncommitted_operations is 0 after flush
cy.request({
method: 'GET',
url: `${Cypress.env('openSearchUrl')}/${sample_alias}/_stats/translog`,
}).then((response) => {
let response_obj = JSON.parse(
response['allRequestResponses'][0]['Response Body']
);
let num =
response_obj['_all']['total']['translog']['uncommitted_operations'];
expect(num).to.equal(0);
});
});
});

describe('can refresh aliases', () => {
it('successfully', () => {
cy.get('[placeholder="Search..."]').type(
`${SAMPLE_ALIAS_PREFIX}-1{enter}`
);
cy.contains(`${SAMPLE_ALIAS_PREFIX}-10`);
cy.contains(`${SAMPLE_ALIAS_PREFIX}-11`);

// If no alias is selected, refresh button is disabled
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="refreshAction"]')
.should('be.disabled')
.end();

// Refresh multiple aliases
cy.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-10-checkbox`)
.click()
.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-11-checkbox`)
.click()
.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="refreshAction"]')
.click()
.get('[data-test-subj="refreshConfirmButton"]')
.click()
.end();

cy.contains(
`2 aliases [${SAMPLE_ALIAS_PREFIX}-10, ${SAMPLE_ALIAS_PREFIX}-11] have been successfully refreshed.`
).end();
});
});

after(() => {
cy.deleteAllIndices();
for (let i = 0; i < 30; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,122 @@ describe('Data stream', () => {
});
});

describe('can clear cache for a data stream', () => {
it('successfully', () => {
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="ClearCacheAction"]')
.should('be.disabled')
.get(`#_selection_column_ds--checkbox`)
.click()
.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="ClearCacheAction"]')
.click();

// Check for clear cache index modal
cy.contains('Clear cache');
cy.get('[data-test-subj="ClearCacheConfirmButton"]').should(
'not.be.disabled'
);
// click to clear caches
cy.get('[data-test-subj="ClearCacheConfirmButton"]').click();
// Check for success toast
cy.contains('Cache for ds- has been successfully cleared.');
});
});

describe('can flush a data stream', () => {
it('successfully flush a data stream', () => {
// Confirm we have our initial ds
cy.contains('ds-');
// index a test doc
cy.request({
method: 'POST',
url: `${Cypress.env('openSearchUrl')}/ds-/_doc`,
headers: {
'content-type': 'application/json;charset=UTF-8',
},
body: { '@timestamp': 123123123 },
});

// confirm uncommitted_operations is 1 after indexing doc
cy.request({
method: 'GET',
url: `${Cypress.env('openSearchUrl')}/ds-/_stats/translog`,
}).then((response) => {
let response_obj = JSON.parse(
response['allRequestResponses'][0]['Response Body']
);
let num =
response_obj['_all']['total']['translog']['uncommitted_operations'];
expect(num).to.equal(1);
});

cy.get('[data-test-subj="moreAction"]').click();
// Flush btn should be disabled if no items selected
cy.get('[data-test-subj="Flush Action"]').should(
'have.class',
'euiContextMenuItem-isDisabled'
);

// Select a ds
cy.get(`[data-test-subj="checkboxSelectRow-ds-"]`).check({
force: true,
});

cy.get('[data-test-subj="moreAction"]').click();
// Flush btn should be enabled
cy.get('[data-test-subj="Flush Action"]')
.should('exist')
.should('not.have.class', 'euiContextMenuItem-isDisabled')
.click();

// Check for flush modal
cy.contains('Flush data stream');

cy.get('[data-test-subj="flushConfirmButton"]').click();

// Check for success toast
cy.contains('The data stream ds- has been successfully flushed.');

// confirm uncommitted_operations is 0 after flush
cy.request({
method: 'GET',
url: `${Cypress.env('openSearchUrl')}/ds-/_stats/translog`,
}).then((response) => {
let response_obj = JSON.parse(
response['allRequestResponses'][0]['Response Body']
);
let num =
response_obj['_all']['total']['translog']['uncommitted_operations'];
expect(num).to.equal(0);
});
});
});

describe('can refresh data streams', () => {
it('successfully', () => {
cy.get('[data-test-subj="moreAction"] button')
.click()
.get('[data-test-subj="refreshAction"]')
.should('be.disabled')
.get(`#_selection_column_ds--checkbox`)
.click()
.get('[data-test-subj="moreAction"]')
.click()
.get('[data-test-subj="refreshAction"]')
.click()
.get('[data-test-subj="refreshConfirmButton"]')
.click()
.end();

cy.contains(
`The data stream [ds-] has been successfully refreshed.`
).end();
});
});

describe('can delete a data stream', () => {
it('successfully', () => {
cy.get('[data-test-subj="moreAction"] button')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('force_merge', () => {
force: true,
});

cy.contains(/Some shards could not be force merged/);
cy.contains(/Successfully started force merging/);
});
});

Expand Down
Loading