Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: suzhou <suzhou@amazon.com>
(cherry picked from commit d2e30c1)

Co-authored-by: suzhou <suzhou@amazon.com>
Signed-off-by: leanne.laceybyrne@eliatra.com <leanne.laceybyrne@eliatra.com>
  • Loading branch information
2 people authored and leanneeliatra committed Sep 15, 2023
1 parent 6ede9b2 commit b252632
Show file tree
Hide file tree
Showing 7 changed files with 619 additions and 16 deletions.
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

0 comments on commit b252632

Please sign in to comment.