Skip to content

Commit

Permalink
Refractor/e2e test to FTRepo (#663) (#664)
Browse files Browse the repository at this point in the history
* feat: add test case from FTRepo

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

* feat: update

Signed-off-by: suzhou <suzhou@amazon.com>

---------

Signed-off-by: suzhou <suzhou@amazon.com>
(cherry picked from commit 87ab1f4)

Co-authored-by: suzhou <suzhou@amazon.com>
  • Loading branch information
opensearch-trigger-bot[bot] and SuZhou-Joe authored Mar 13, 2023
1 parent 1c6af19 commit 950e157
Show file tree
Hide file tree
Showing 29 changed files with 1,038 additions and 508 deletions.
17 changes: 9 additions & 8 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"viewportHeight": 900,
"viewportWidth": 1440,
"defaultCommandTimeout": 10000,
"nodeVersion": "system",
"defaultCommandTimeout": 60000,
"requestTimeout": 60000,
"responseTimeout": 60000,
"baseUrl": "http://localhost:5601",
"viewportWidth": 2000,
"viewportHeight": 1320,
"env": {
"opensearch_url": "localhost:9200",
"opensearch_dashboards": "http://localhost:5601",
"security_enabled": false,
"openSearchUrl": "http://localhost:9200",
"SECURITY_ENABLED": false,
"username": "admin",
"password": "admin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"policy": {
"description": "A simple description",
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [
{
"replica_count": {
"number_of_replicas": 5
}
}
],
"transitions": [
{
"state_name": "cold",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "cold",
"actions": [
{
"replica_count": {
"number_of_replicas": 2
}
}
],
"transitions": []
}
],
"ism_template": {
"index_patterns": ["logs-*"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"policy": {
"description": "A simple description",
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [
{
"replica_count": {
"number_of_replicas": 5
}
}
],
"transitions": [
{
"state_name": "cold",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "cold",
"actions": [
{
"replica_count": {
"number_of_replicas": 2
}
}
],
"transitions": []
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"policy": {
"description": "A simple description",
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {},
"retry": {
"count": 0
}
}
],
"transitions": [
{
"state_name": "cold",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "cold",
"actions": [
{
"replica_count": {
"number_of_replicas": 2
}
}
],
"transitions": []
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"rollup": {
"enabled": true,
"schedule": {
"interval": {
"period": 1,
"unit": "Minutes",
"start_time": 1602100553
}
},
"last_updated_time": 1602100553,
"description": "An example rollup job that rolls up the sample ecommerce data",
"source_index": "opensearch_dashboards_sample_data_ecommerce",
"target_index": "test_rollup_target",
"page_size": 1000,
"delay": 0,
"continuous": false,
"dimensions": [
{
"date_histogram": {
"source_field": "order_date",
"fixed_interval": "90m",
"timezone": "America/Los_Angeles"
}
},
{
"terms": {
"source_field": "customer_gender"
}
},
{
"terms": {
"source_field": "geoip.city_name"
}
},
{
"terms": {
"source_field": "geoip.region_name"
}
},
{
"terms": {
"source_field": "day_of_week"
}
}
],
"metrics": [
{
"source_field": "taxless_total_price",
"metrics": [{ "avg": {} }, { "sum": {} }, { "max": {} }, { "min": {} }, { "value_count": {} }]
},
{
"source_field": "total_quantity",
"metrics": [{ "avg": {} }, { "max": {} }]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"transform": {
"enabled": true,
"schedule": {
"interval": {
"period": 1,
"unit": "Minutes",
"start_time": 1602100553
}
},
"description": "Test transform",
"source_index": "opensearch_dashboards_sample_data_ecommerce",
"target_index": "test_transform",
"data_selection_query": {
"match_all": {}
},
"page_size": 1000,
"groups": [
{
"terms": {
"source_field": "customer_gender",
"target_field": "gender"
}
},
{
"terms": {
"source_field": "day_of_week",
"target_field": "day"
}
}
],
"aggregations": {
"quantity": {
"sum": {
"field": "total_quantity"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";
import { IM_PLUGIN_NAME, BASE_PATH } from "../../../utils/constants";

const SAMPLE_INDEX_PREFIX = "index-for-alias-test";
const SAMPLE_ALIAS_PREFIX = "alias-for-test";
Expand All @@ -19,15 +19,15 @@ describe("Aliases", () => {
}
cy.createIndex(EDIT_INDEX, null);
for (let i = 0; i < 30; i++) {
cy.addAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`, `${SAMPLE_INDEX_PREFIX}-${i % 11}`);
cy.addIndexAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`, `${SAMPLE_INDEX_PREFIX}-${i % 11}`);
}
cy.removeAlias(`${SAMPLE_ALIAS_PREFIX}-0`);
cy.addAlias(`${SAMPLE_ALIAS_PREFIX}-0`, `${SAMPLE_INDEX_PREFIX}-*`);
cy.removeIndexAlias(`${SAMPLE_ALIAS_PREFIX}-0`);
cy.addIndexAlias(`${SAMPLE_ALIAS_PREFIX}-0`, `${SAMPLE_INDEX_PREFIX}-*`);
});

beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/aliases`);
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/aliases`);

// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains("Rows per page", { timeout: 60000 });
Expand Down Expand Up @@ -94,26 +94,14 @@ describe("Aliases", () => {
.end();

cy.get('[data-test-subj="7 more"]').should("exist");

cy.get('[data-test-subj="moreAction"] button').click().get('[data-test-subj="deleteAction"]').click();
// The confirm button should be disabled
cy.get('[data-test-subj="deleteConfirmButton"]').should("be.disabled");
// type delete
cy.wait(500).get('[data-test-subj="deleteInput"]').type("delete");
cy.get('[data-test-subj="deleteConfirmButton"]').should("not.be.disabled");
// click to delete
cy.get('[data-test-subj="deleteConfirmButton"]').click();
// the alias should not exist
cy.wait(500);
cy.get(`#_selection_column_${SAMPLE_ALIAS_PREFIX}-0-checkbox`).should("not.exist");
});
});

after(() => {
cy.deleteAllIndices();
for (let i = 0; i < 30; i++) {
cy.removeAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`);
cy.removeIndexAlias(`${SAMPLE_ALIAS_PREFIX}-${i}`);
}
cy.removeAlias(CREATE_ALIAS);
cy.removeIndexAlias(CREATE_ALIAS);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { PLUGIN_NAME } from "../support/constants";
import { IM_PLUGIN_NAME, BASE_PATH } from "../../../utils/constants";

const SAMPLE_INDEX = "index-specific-index";

Expand Down Expand Up @@ -51,7 +51,7 @@ describe("Create Index", () => {
describe("can be created and updated", () => {
beforeEach(() => {
// Visit ISM OSD
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/indices`);
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/indices`);
cy.contains("Rows per page", { timeout: 60000 });
});

Expand Down Expand Up @@ -106,13 +106,15 @@ describe("Create Index", () => {
cy.get('[data-test-subj="mapping-visual-editor-1-field-name"]').type("text_mappings");

// click create
cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });
cy.get('[data-test-subj="createIndexCreateButton"]').click({
force: true,
});

// The index should exist
cy.get(`#_selection_column_${SAMPLE_INDEX}-checkbox`).should("have.exist");

// check the index detail
cy.visit(`${Cypress.env("opensearch_dashboards")}/app/${PLUGIN_NAME}#/create-index/${SAMPLE_INDEX}`);
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/create-index/${SAMPLE_INDEX}`);

// index name and alias should exist
cy.get(`[title="${SAMPLE_INDEX}"]`)
Expand Down Expand Up @@ -171,22 +173,29 @@ describe("Create Index", () => {
})
.blur();

cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });
cy.get('[data-test-subj="createIndexCreateButton"]').click({
force: true,
});

cy.contains(`Can't update non dynamic settings`).should("exist");

cy.get(".ace_text-input")
.focus()
.clear({ force: true })
.type('{ "index.blocks.write": true, "index.number_of_shards": "3" }', { parseSpecialCharSequences: false, force: true })
.type('{ "index.blocks.write": true, "index.number_of_shards": "3" }', {
parseSpecialCharSequences: false,
force: true,
})
.end()
.wait(1000)
.get('[placeholder="Specify number of replicas."]')
.clear()
.type(2)
.end();

cy.get('[data-test-subj="createIndexCreateButton"]').click({ force: true });
cy.get('[data-test-subj="createIndexCreateButton"]').click({
force: true,
});

cy.wait(1000).get('[data-test-subj="form-name-index.number_of_replicas"] input').should("have.value", "2");
});
Expand All @@ -211,7 +220,10 @@ describe("Create Index", () => {
.get(".ace_text-input")
.focus()
.clear({ force: true })
.type('{ "dynamic": true }', { parseSpecialCharSequences: false, force: true })
.type('{ "dynamic": true }', {
parseSpecialCharSequences: false,
force: true,
})
.blur()
.end()
.wait(1000)
Expand Down
Loading

0 comments on commit 950e157

Please sign in to comment.