@@ -67,6 +67,136 @@ describe("Split Index", () => {
6767 cy . updateIndexSettings ( sampleIndex , {
6868 "index.blocks.write" : "true" ,
6969 } ) . end ( ) ;
70- } ) ;
70+ } ) ; //create the index
71+
72+ it ( "Split successfully" , ( ) => {
73+ const targetIndex = `${ sampleIndex } ` + "-target" ;
74+ cy . get ( `[data-test-subj="checkboxSelectRow-${ sampleIndex } "]` )
75+ . click ( )
76+ . end ( )
77+ . get ( '[data-test-subj="moreAction"]' )
78+ . click ( )
79+ . end ( )
80+ . get ( '[data-test-subj="Split Action"]' )
81+ . click ( )
82+ . end ( )
83+ // Target Index Name is required
84+ . get ( '[data-test-subj="targetIndexNameInput"]' )
85+ . type ( `${ targetIndex } ` )
86+ . end ( )
87+ // Number of shards after split is required
88+ . get ( '[data-test-subj="numberOfShardsInput"]' )
89+ . type ( `${ splitNumber } {downArrow}{enter}` )
90+ . end ( )
91+ . get ( '[data-test-subj="numberOfReplicasInput"]' )
92+ . clear ( )
93+ . type ( `${ replicaNumber } ` )
94+ . end ( )
95+ . get ( '[data-test-subj="splitButton"]' )
96+ . click ( )
97+ . end ( ) ;
98+
99+ cy . get ( `[data-test-subj="viewIndexDetailButton-${ targetIndex } "]` ) . click ( ) . end ( ) ;
100+ cy . get ( "#indexDetailModalSettings" ) . click ( ) . end ( ) ;
101+ cy . get ( '[data-test-subj="form-name-index.number_of_shards"] .euiText' ) . should ( "have.text" , `${ splitNumber } ` ) . end ( ) ;
102+ cy . get ( '[data-test-subj="form-name-index.number_of_replicas"] input' ) . should ( "have.value" , `${ replicaNumber } ` ) . end ( ) ;
103+ } ) ; // Split
104+
105+ it ( "Split successfully with advanced setting" , ( ) => {
106+ const targetIndex = `${ sampleIndex } ` + "-setting" ;
107+ cy . get ( `[data-test-subj="checkboxSelectRow-${ sampleIndex } "]` )
108+ . click ( )
109+ . end ( )
110+ . get ( '[data-test-subj="moreAction"]' )
111+ . click ( )
112+ . end ( )
113+ . get ( '[data-test-subj="Split Action"]' )
114+ . click ( )
115+ . end ( )
116+ . get ( "[data-test-subj=targetIndexNameInput]" )
117+ . type ( `${ targetIndex } ` )
118+ . end ( )
119+ // Instead of input shard number at shard field, another option is to populate it in advanced setting
120+ . get ( '[aria-controls="accordionForCreateIndexSettings"]' )
121+ . click ( )
122+ . end ( )
123+ . get ( '[data-test-subj="codeEditorContainer"] textarea' )
124+ . focus ( )
125+ // Need to remove the default {} in advanced setting
126+ . clear ( )
127+ . type ( `{"index.number_of_shards": "${ splitNumber } ", "index.number_of_replicas": "${ replicaNumber } "}` , {
128+ parseSpecialCharSequences : false ,
129+ } )
130+ . end ( )
131+ . get ( '[data-test-subj="splitButton"]' )
132+ . click ( )
133+ . end ( ) ;
134+
135+ cy . get ( `[data-test-subj="viewIndexDetailButton-${ targetIndex } "]` ) . click ( ) . end ( ) ;
136+ cy . get ( "#indexDetailModalSettings" ) . click ( ) . end ( ) ;
137+ cy . get ( '[data-test-subj="form-name-index.number_of_shards"] .euiText' ) . should ( "have.text" , `${ splitNumber } ` ) . end ( ) ;
138+ cy . get ( '[data-test-subj="form-name-index.number_of_replicas"] input' ) . should ( "have.value" , `${ replicaNumber } ` ) . end ( ) ;
139+ } ) ; // advanced setting
140+
141+ it ( "Split successfully with alias" , ( ) => {
142+ const targetIndex = `${ sampleIndex } ` + "-alias" ;
143+ const newAlias = "alias-new" ;
144+ cy . get ( `[data-test-subj="checkboxSelectRow-${ sampleIndex } "]` )
145+ . click ( )
146+ . end ( )
147+ . get ( '[data-test-subj="moreAction"]' )
148+ . click ( )
149+ . end ( )
150+ . get ( '[data-test-subj="Split Action"]' )
151+ . click ( )
152+ . end ( )
153+ . get ( "[data-test-subj=targetIndexNameInput]" )
154+ . type ( `${ targetIndex } ` )
155+ . end ( )
156+ . get ( '[data-test-subj="numberOfShardsInput"]' )
157+ . type ( `${ splitNumber } {downArrow}{enter}` )
158+ . end ( )
159+ // Assign to an existing alias and a new alias
160+ . get ( '[data-test-subj="form-name-aliases"] [data-test-subj="comboBoxSearchInput"]' )
161+ . type ( `${ sampleAlias } {enter}${ newAlias } {enter}` )
162+ . end ( )
163+ . get ( '[data-test-subj="splitButton"]' )
164+ . click ( )
165+ . end ( ) ;
166+
167+ cy . get ( `[data-test-subj="viewIndexDetailButton-${ targetIndex } "]` ) . click ( ) . end ( ) ;
168+ // Verify alias associated with the new index
169+ cy . get ( "#indexDetailModalAlias" ) . click ( ) . end ( ) ;
170+ cy . get ( `[title="${ newAlias } "]` ) . should ( "exist" ) . end ( ) ;
171+ cy . get ( `[title="${ sampleAlias } "]` ) . should ( "exist" ) . end ( ) ;
172+ } ) ; // Create with alias
173+
174+ it ( "Update blocks write to true" , ( ) => {
175+ // Set index to not blocks write
176+ cy . updateIndexSettings ( sampleIndex , {
177+ "index.blocks.write" : "false" ,
178+ } ) . end ( ) ;
179+ cy . get ( `[data-test-subj="checkboxSelectRow-${ sampleIndex } "]` )
180+ . click ( )
181+ . end ( )
182+ . get ( '[data-test-subj="moreAction"]' )
183+ . click ( )
184+ . end ( )
185+ . get ( '[data-test-subj="Split Action"]' )
186+ . click ( )
187+ . end ( )
188+ // Index can't be split if it's blocks write status is not true
189+ . get ( '[data-test-subj="splitButton"]' )
190+ . should ( "have.class" , "euiButton-isDisabled" )
191+ . end ( )
192+ . wait ( 1000 )
193+ // Set index to blocks write
194+ . get ( '[data-test-subj="set-indexsetting-button"]' )
195+ . click ( )
196+ . end ( )
197+ . get ( '[data-test-subj="splitButton"]' )
198+ . click ( )
199+ . end ( ) ;
200+ } ) ; // Blocks write
71201 } ) ;
72202} ) ;
0 commit comments