26
26
27
27
import { PLUGIN_NAME } from "../support/constants" ;
28
28
import samplePolicy from "../fixtures/sample_policy" ;
29
+ import sampleRolloverPolicy from "../fixtures/sample_rollover_policy" ;
29
30
import sampleDataStreamPolicy from "../fixtures/sample_data_stream_policy.json" ;
30
31
31
32
const POLICY_ID = "test_policy_id" ;
32
33
const POLICY_ID_2 = "test_policy_id_2" ;
34
+ const POLICY_ID_ROLLOVER = "test_policy_rollover" ;
33
35
const SAMPLE_INDEX = "sample_index" ;
36
+ const SAMPLE_INDEX_ROLLOVER = "sample_index-01" ;
34
37
35
38
describe ( "Managed indices" , ( ) => {
36
39
beforeEach ( ( ) => {
@@ -45,8 +48,9 @@ describe("Managed indices", () => {
45
48
cy . visit ( `${ Cypress . env ( "opensearch_dashboards" ) } /app/${ PLUGIN_NAME } #/managed-indices` ) ;
46
49
47
50
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
48
- // TODO flaky: page may not rendered right with below line
49
- cy . contains ( "Rows per page" , { timeout : 60000 } ) ;
51
+ cy . contains ( "Edit rollover alias" , { timeout : 60000 } ) ;
52
+
53
+ cy . get ( '[data-test-subj="toastCloseButton"]' ) . click ( { force : true } ) ;
50
54
} ) ;
51
55
52
56
describe ( "can have policies removed" , ( ) => {
@@ -80,31 +84,46 @@ describe("Managed indices", () => {
80
84
} ) ;
81
85
} ) ;
82
86
83
- describe . skip ( "can have policies retried" , ( ) => {
87
+ describe ( "can have policies retried" , ( ) => {
84
88
before ( ( ) => {
85
89
cy . deleteAllIndices ( ) ;
86
- // Add a non-existent policy to the index
87
- cy . createIndex ( SAMPLE_INDEX , POLICY_ID ) ;
88
- // Speed up execution time to happen in a few seconds
89
- cy . updateManagedIndexConfigStartTime ( SAMPLE_INDEX ) ;
90
+ // Create a policy that rolls over
91
+ cy . createPolicy ( POLICY_ID_ROLLOVER , sampleRolloverPolicy ) ;
92
+ // Create index with alias to rollover
93
+ cy . createIndex ( SAMPLE_INDEX_ROLLOVER , POLICY_ID_ROLLOVER , { aliases : { "retry-rollover-alias" : { } } } ) ;
90
94
} ) ;
91
95
92
96
it ( "successfully" , ( ) => {
93
97
// Confirm we have initial policy
94
- cy . contains ( POLICY_ID ) ;
98
+ cy . contains ( POLICY_ID_ROLLOVER ) ;
99
+
100
+ // Speed up execution time to happen in a few seconds
101
+ cy . updateManagedIndexConfigStartTime ( SAMPLE_INDEX_ROLLOVER ) ;
95
102
96
103
// Wait up to 5 seconds for the managed index to execute
97
104
// eslint-disable-next-line cypress/no-unnecessary-waiting
98
105
cy . wait ( 5000 ) . reload ( ) ;
106
+ cy . get ( '[data-test-subj="toastCloseButton"]' ) . click ( { force : true } ) ;
107
+
108
+ // Confirm managed index successfully initialized the policy
109
+ cy . contains ( "Successfully initialized" , { timeout : 20000 } ) ;
110
+
111
+ cy . updateManagedIndexConfigStartTime ( SAMPLE_INDEX_ROLLOVER ) ;
112
+
113
+ // Wait up to 5 seconds for managed index to execute
114
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
115
+ cy . wait ( 5000 ) . reload ( ) ;
116
+ cy . get ( '[data-test-subj="toastCloseButton"]' ) . click ( { force : true } ) ;
99
117
100
118
// Confirm we have a Failed execution, wait up to 20 seconds as OSD takes a while to load
101
119
cy . contains ( "Failed" , { timeout : 20000 } ) ;
120
+ cy . contains ( "Missing rollover_alias" ) ;
102
121
103
- // Create the policy we were missing
104
- cy . createPolicy ( POLICY_ID , samplePolicy ) ;
122
+ // Add rollover alias
123
+ cy . updateIndexSettings ( SAMPLE_INDEX_ROLLOVER , { "plugins.index_state_management.rollover_alias" : "retry-rollover-alias" } ) ;
105
124
106
125
// Select checkbox for our managed index
107
- cy . get ( `[data-test-subj="checkboxSelectRow-${ SAMPLE_INDEX } "]` ) . check ( { force : true } ) ;
126
+ cy . get ( `[data-test-subj="checkboxSelectRow-${ SAMPLE_INDEX_ROLLOVER } "]` ) . check ( { force : true } ) ;
108
127
109
128
// Click the retry policy button
110
129
cy . get ( `[data-test-subj="Retry policyButton"]` ) . click ( { force : true } ) ;
@@ -117,19 +136,21 @@ describe("Managed indices", () => {
117
136
118
137
// Reload the page
119
138
cy . reload ( ) ;
139
+ cy . get ( '[data-test-subj="toastCloseButton"]' ) . click ( { force : true } ) ;
120
140
121
141
// Confirm we see managed index attempting to retry, give 20 seconds for OSD load
122
142
cy . contains ( "Pending retry of failed managed index" , { timeout : 20000 } ) ;
123
143
124
144
// Speed up next execution of managed index
125
- cy . updateManagedIndexConfigStartTime ( SAMPLE_INDEX ) ;
145
+ cy . updateManagedIndexConfigStartTime ( SAMPLE_INDEX_ROLLOVER ) ;
126
146
127
147
// Wait up to 5 seconds for managed index to execute
128
148
// eslint-disable-next-line cypress/no-unnecessary-waiting
129
149
cy . wait ( 5000 ) . reload ( ) ;
150
+ cy . get ( '[data-test-subj="toastCloseButton"]' ) . click ( { force : true } ) ;
130
151
131
- // Confirm managed index successfully initialized the policy
132
- cy . contains ( "Successfully initialized " , { timeout : 20000 } ) ;
152
+ // Confirm managed index successfully rolled over
153
+ cy . contains ( "Successfully rolled over " , { timeout : 20000 } ) ;
133
154
} ) ;
134
155
} ) ;
135
156
0 commit comments