Skip to content

Commit 24fba9c

Browse files
Onboard index management cypress test (opensearch-project#94)
* Onboard index management cypress test Signed-off-by: bowenlan-amzn <[email protected]> * Refactor plugin specific commands constants out Signed-off-by: bowenlan-amzn <[email protected]> * Prettier and documentation Signed-off-by: bowenlan-amzn <[email protected]> * Refactor the base constants to single file So other plugins' constant file can directly import. Signed-off-by: bowenlan-amzn <[email protected]> * Refactor IM commands Move general commands from IM commands to main commands. Signed-off-by: bowenlan-amzn <[email protected]> * Use open source terms Signed-off-by: bowenlan-amzn <[email protected]>
1 parent 755b6b6 commit 24fba9c

File tree

23 files changed

+1857
-118
lines changed

23 files changed

+1857
-118
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ cypress/results/
44
cypress/screenshots/
55
.DS_Store
66
**/.DS_Store
7+
.idea
78

CONTRIBUTING.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ $ npm uninstall @opensearch-dashboards-test/opensearch-dashboards-test-library &
4848

4949
### Run Tests
5050

51-
You can run the cypress tests by cli. There are some handy sripts in [package.json](package.json) to run the tests with some pre-set configurations.
51+
You can run the cypress tests by cli. There are some handy scripts in [package.json](package.json) to run the tests with some pre-set configurations.
5252

53-
To run without security:
53+
To run tests against a local cluster
54+
55+
without security:
5456

5557
```
5658
$ yarn cypress run-without-security --spec "cypress/integration/core-opensearch-dashboards/vanilla-opensearch-dashboards/*.js"
5759
```
5860

59-
To run with security:
61+
with security:
6062

6163
```
6264
$ yarn cypress run-with-security --spec "cypress/integration/core-opensearch-dashboards/vanilla-opensearch-dashboards/*.js"
@@ -68,12 +70,16 @@ These tests run in headless mode by default. You can also manually trigger the t
6870
$ yarn cypress open
6971
```
7072

71-
And you can override certain cypress config or environment variable by appling additional cli arguments, for example to override the baseUrl and OpensearchUrl to test a remote endpoint:
73+
And you can override certain [cypress config or environment variable](cypress.json) by applying additional cli arguments, for example to override the baseUrl and openSearchUrl to test a remote OpenSearch endpoint:
7274

7375
```
74-
$ yarn cypress run --spec "cypress/integration/core-opensearch-dashboards/vanilla-opensearch-dashboards/*.js" --env "openSearchUrl=https://foo.com" --config "baseUrl=https://foo.com/_dashboards"
76+
$ yarn cypress run --spec "cypress/integration/core-opensearch-dashboards/vanilla-opensearch-dashboards/*.js" --config "baseUrl=https://<endpoint>/_dashboards" --env "openSearchUrl=https://<endpoint>,SECURITY_ENABLED=true,username=admin,password=xxxxxxxx,ENDPOINT_WITH_PROXY=true"
7577
```
7678

79+
`SECURITY_ENABLED`: if true, the `username` and `password` passing in are used as basic authentication credentials during `cy.visit` and `cy.request`. Also, please notice security enabled endpoint normally uses https protocol, so you may want to pass in different urls.
80+
81+
`ENDPOINT_WITH_PROXY`: for an OpenSearch endpoint wrapped with a proxy that redirects the visiting url to the login url, even with auth option provided in `cy.visit`, the redirection to the login url still happens. So a login request before tests and cache the security cookie are needed and can be switched on by this argument.
82+
7783
### Formatting
7884

7985
`prettier` is used to standardize formatting of files. You can format all files (new and existing) by running
@@ -96,9 +102,9 @@ The dir name shall be descriptive to identify your plugin. You can use the same
96102

97103
2. Place fixtures under `cypress/fixtures/plugins/<plugin-name>`
98104

99-
3. Place custom commands under `cypress/fixtures/plugins/<plugin-name>`
105+
3. Place custom commands under `cypress/utils/plugins/<plugin-name>`, if it's a general command that could be reused by other plugins, place it under `cypress/utils/commands.js`
100106

101-
4. Place constants to `cypress/utils/constants.js`
107+
4. Place custom constants under `cypress/utils/plugins/<plugin-name>`, reuse the constants in `cypress/utils/base_constants.js`
102108

103109
5. Run tests
104110

@@ -118,7 +124,7 @@ npx cypress run --env SECURITY_ENABLED=true --spec "cypress/integration/plugins/
118124

119125
For the complete ways to run Cypress, you can refer to the Cypress official site https://docs.cypress.io/guides/getting-started/.installing-cypress#Opening-Cypress.
120126

121-
The env paramaters are defined in https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/cypress.json where you can look for or add the desired parameters. You can refer to the Cypress official site https://docs.cypress.io/guides/guides/environment-variables#Setting.
127+
The env parameters are defined in https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/cypress.json where you can look for or add the desired parameters. You can refer to the Cypress official site https://docs.cypress.io/guides/guides/environment-variables#Setting.
122128

123129
6. [optional] Remove copied tests from your plugin and execute them remotely from your plugin
124130

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
- [Documentation](https://docs-beta.opensearch.org/)
1818
- Need help? Try [Forums](https://discuss.opendistrocommunity.dev/)
1919
- [Project Principles](https://opensearch.org/#principles)
20-
- [Contributing to OpenSearch](CONTRIBUTING.md)
2120
- [Maintainer Responsibilities](MAINTAINERS.md)
2221
- [Release Management](RELEASING.md)
2322
- [Admin Responsibilities](ADMINS.md)
2423
- [Security](SECURITY.md)
2524

25+
## Contributing
26+
27+
See [contributing guide](CONTRIBUTING.md).
28+
2629
## Code of Conduct
2730

2831
This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

cypress.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"viewportHeight": 1320,
1212
"env": {
1313
"openSearchUrl": "http://localhost:9200",
14-
"SECURITY_ENABLED": false
14+
"SECURITY_ENABLED": false,
15+
"username": "admin",
16+
"password": "admin",
17+
"ENDPOINT_WITH_PROXY": false
1518
},
1619
"experimentalNetworkStubbing": true
1720
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"policy": {
3+
"description": "A simple description",
4+
"default_state": "hot",
5+
"states": [
6+
{
7+
"name": "hot",
8+
"actions": [
9+
{
10+
"replica_count": {
11+
"number_of_replicas": 5
12+
}
13+
}
14+
],
15+
"transitions": [
16+
{
17+
"state_name": "cold",
18+
"conditions": {
19+
"min_index_age": "30d"
20+
}
21+
}
22+
]
23+
},
24+
{
25+
"name": "cold",
26+
"actions": [
27+
{
28+
"replica_count": {
29+
"number_of_replicas": 2
30+
}
31+
}
32+
],
33+
"transitions": []
34+
}
35+
],
36+
"ism_template": {
37+
"index_patterns": ["logs-*"]
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"policy": {
3+
"description": "A simple description",
4+
"default_state": "hot",
5+
"states": [
6+
{
7+
"name": "hot",
8+
"actions": [
9+
{
10+
"replica_count": {
11+
"number_of_replicas": 5
12+
}
13+
}
14+
],
15+
"transitions": [
16+
{
17+
"state_name": "cold",
18+
"conditions": {
19+
"min_index_age": "30d"
20+
}
21+
}
22+
]
23+
},
24+
{
25+
"name": "cold",
26+
"actions": [
27+
{
28+
"replica_count": {
29+
"number_of_replicas": 2
30+
}
31+
}
32+
],
33+
"transitions": []
34+
}
35+
]
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"policy": {
3+
"description": "A simple description",
4+
"default_state": "hot",
5+
"states": [
6+
{
7+
"name": "hot",
8+
"actions": [
9+
{
10+
"rollover": {}
11+
}
12+
],
13+
"transitions": [
14+
{
15+
"state_name": "cold",
16+
"conditions": {
17+
"min_index_age": "30d"
18+
}
19+
}
20+
]
21+
},
22+
{
23+
"name": "cold",
24+
"actions": [
25+
{
26+
"replica_count": {
27+
"number_of_replicas": 2
28+
}
29+
}
30+
],
31+
"transitions": []
32+
}
33+
]
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"rollup": {
3+
"enabled": true,
4+
"schedule": {
5+
"interval": {
6+
"period": 1,
7+
"unit": "Minutes",
8+
"start_time": 1602100553
9+
}
10+
},
11+
"last_updated_time": 1602100553,
12+
"description": "An example rollup job that rolls up the sample ecommerce data",
13+
"source_index": "opensearch_dashboards_sample_data_ecommerce",
14+
"target_index": "test_rollup_target",
15+
"page_size": 1000,
16+
"delay": 0,
17+
"continuous": false,
18+
"dimensions": [
19+
{
20+
"date_histogram": {
21+
"source_field": "order_date",
22+
"fixed_interval": "90m",
23+
"timezone": "America/Los_Angeles"
24+
}
25+
},
26+
{
27+
"terms": {
28+
"source_field": "customer_gender"
29+
}
30+
},
31+
{
32+
"terms": {
33+
"source_field": "geoip.city_name"
34+
}
35+
},
36+
{
37+
"terms": {
38+
"source_field": "geoip.region_name"
39+
}
40+
},
41+
{
42+
"terms": {
43+
"source_field": "day_of_week"
44+
}
45+
}
46+
],
47+
"metrics": [
48+
{
49+
"source_field": "taxless_total_price",
50+
"metrics": [
51+
{ "avg": {} },
52+
{ "sum": {} },
53+
{ "max": {} },
54+
{ "min": {} },
55+
{ "value_count": {} }
56+
]
57+
},
58+
{
59+
"source_field": "total_quantity",
60+
"metrics": [{ "avg": {} }, { "max": {} }]
61+
}
62+
]
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"transform": {
3+
"enabled": true,
4+
"schedule": {
5+
"interval": {
6+
"period": 1,
7+
"unit": "Minutes",
8+
"start_time": 1602100553
9+
}
10+
},
11+
"description": "Test transform",
12+
"source_index": "opensearch_dashboards_sample_data_ecommerce",
13+
"target_index": "test_transform",
14+
"data_selection_query": {
15+
"match_all": {}
16+
},
17+
"page_size": 1000,
18+
"groups": [
19+
{
20+
"terms": {
21+
"source_field": "customer_gender",
22+
"target_field": "gender"
23+
}
24+
},
25+
{
26+
"terms": {
27+
"source_field": "day_of_week",
28+
"target_field": "day"
29+
}
30+
}
31+
],
32+
"aggregations": {
33+
"quantity": {
34+
"sum": {
35+
"field": "total_quantity"
36+
}
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)