@@ -18,13 +18,6 @@ context('Create remote detector workflow', () => {
18
18
const TEST_INDEX_NAME = 'sample-ad-index' ;
19
19
const TEST_SECOND_INDEX_NAME = 'sample-ad-index-two' ;
20
20
const TEST_REMOTE_INDEX = 'followCluster:sample-ad-index' ;
21
- const remoteClusterSettings = {
22
- persistent : {
23
- 'cluster.remote.followCluster' : {
24
- seeds : [ '127.0.0.1:9301' ] ,
25
- } ,
26
- } ,
27
- } ;
28
21
29
22
// Clean up created resources
30
23
afterEach ( ( ) => {
@@ -35,7 +28,7 @@ context('Create remote detector workflow', () => {
35
28
describe ( 'Remote cluster tests' , ( ) => {
36
29
before ( function ( ) {
37
30
cy . visit ( AD_URL . OVERVIEW , { timeout : 10000 } ) ;
38
- // Use `cy.exec()` to check cluster health before running tests
31
+
39
32
cy . exec (
40
33
`
41
34
node -e "
@@ -49,34 +42,59 @@ context('Create remote detector workflow', () => {
49
42
) . then ( ( result ) => {
50
43
if ( result . code !== 0 ) {
51
44
Cypress . log ( {
52
- name : 'Cluster Health' ,
53
- message :
54
- 'Remote cluster is unavailable - skipping all remote detector tests' ,
45
+ message : 'Remote cluster is unavailable - skipping tests' ,
55
46
} ) ;
56
- this . skip ( ) ; // Skip the entire test suite
47
+ this . skip ( ) ; // Skip all tests if the cluster isn't available
57
48
}
49
+
50
+ cy . request (
51
+ `${ Cypress . env ( 'remoteDataSourceNoAuthUrl' ) } /_cluster/health`
52
+ ) . then ( ( response ) => {
53
+ Cypress . log ( {
54
+ message : `Cluster health response: ${ JSON . stringify (
55
+ response . body
56
+ ) } `,
57
+ } ) ;
58
+
59
+ if ( ! response . body || ! response . body . cluster_name ) {
60
+ Cypress . log ( { message : 'Cluster name not found - skipping tests' } ) ;
61
+ this . skip ( ) ;
62
+ }
63
+ Cypress . env ( 'remoteClusterName' , response . body . cluster_name ) ;
64
+ } ) ;
58
65
} ) ;
59
66
} ) ;
60
67
61
- // apply remote cluster settings after cluster health check passes
62
68
before ( function ( ) {
69
+ const remoteClusterName = Cypress . env ( 'remoteClusterName' ) ;
70
+
71
+ const remoteClusterSettings = {
72
+ persistent : {
73
+ [ `cluster.remote.${ remoteClusterName } ` ] : {
74
+ seeds : [ '127.0.0.1:9301' ] ,
75
+ } ,
76
+ } ,
77
+ } ;
78
+
63
79
cy . visit ( AD_URL . OVERVIEW , { timeout : 10000 } ) ;
80
+
64
81
cy . request ( {
65
82
method : 'PUT' ,
66
83
url : `${ BACKEND_BASE_PATH } /_cluster/settings` ,
67
84
headers : {
68
85
'content-type' : 'application/json' ,
69
- 'osd-xsrf' : true , // If your backend requires this header
86
+ 'osd-xsrf' : true ,
70
87
} ,
71
88
body : remoteClusterSettings ,
72
89
} ) . then ( ( response ) => {
73
- cy . log ( 'Cluster settings update response:' , response ) ;
90
+ Cypress . log ( { message : 'Cluster settings updated successfully' } ) ;
74
91
expect ( response . status ) . to . eq ( 200 ) ;
75
92
} ) ;
93
+
76
94
cy . wait ( 5000 ) ;
77
95
} ) ;
78
96
79
- // Index some sample data in follower cluster (remote)
97
+ // Index some sample data in local and follower cluster (remote)
80
98
beforeEach ( ( ) => {
81
99
cy . visit ( AD_URL . OVERVIEW , { timeout : 10000 } ) ;
82
100
const remoteEndpointTestData = `${ Cypress . env (
@@ -138,6 +156,8 @@ context('Create remote detector workflow', () => {
138
156
139
157
it ( 'Full creation - based on remote index' , ( ) => {
140
158
// Define detector step
159
+ const remoteClusterName = Cypress . env ( 'remoteClusterName' ) ;
160
+
141
161
cy . visit ( AD_URL . CREATE_AD ) ;
142
162
cy . getElementByTestId ( 'defineOrEditDetectorTitle' ) . should ( 'exist' ) ;
143
163
cy . getElementByTestId ( 'detectorNameTextInput' ) . type (
@@ -151,7 +171,7 @@ context('Create remote detector workflow', () => {
151
171
cy . getElementByTestId ( 'clustersFilter' ) . click ( ) ;
152
172
cy . contains (
153
173
'.euiComboBoxOption__content' ,
154
- 'followCluster (Remote)'
174
+ ` ${ remoteClusterName } (Remote)`
155
175
) . click ( ) ;
156
176
157
177
cy . wait ( 3000 ) ;
@@ -160,7 +180,7 @@ context('Create remote detector workflow', () => {
160
180
cy . wait ( 1000 ) ;
161
181
cy . contains (
162
182
'.euiComboBoxOption__content' ,
163
- 'followCluster :sample-ad-index'
183
+ ` ${ remoteClusterName } :sample-ad-index`
164
184
) . click ( ) ;
165
185
166
186
selectTopItemFromFilter ( 'timestampFilter' , false ) ;
@@ -208,6 +228,8 @@ context('Create remote detector workflow', () => {
208
228
} ) ;
209
229
210
230
it ( 'Full creation - based on multiple indexes' , ( ) => {
231
+ const remoteClusterName = Cypress . env ( 'remoteClusterName' ) ;
232
+
211
233
// Define detector step
212
234
cy . visit ( AD_URL . CREATE_AD ) ;
213
235
cy . getElementByTestId ( 'defineOrEditDetectorTitle' ) . should ( 'exist' ) ;
@@ -220,23 +242,26 @@ context('Create remote detector workflow', () => {
220
242
221
243
cy . getElementByTestId ( 'clustersFilter' ) . click ( ) ;
222
244
cy . getElementByTestId ( 'clustersFilter' ) . click ( ) ;
245
+
223
246
cy . contains (
224
247
'.euiComboBoxOption__content' ,
225
- 'followCluster (Remote)'
248
+ ` ${ remoteClusterName } (Remote)`
226
249
) . click ( ) ;
227
250
228
251
cy . wait ( 3000 ) ;
229
252
230
253
cy . getElementByTestId ( 'indicesFilter' ) . click ( ) ;
231
254
cy . wait ( 1000 ) ;
255
+
232
256
cy . contains (
233
257
'.euiComboBoxOption__content' ,
234
- 'followCluster :sample-ad-index'
258
+ ` ${ remoteClusterName } :sample-ad-index`
235
259
) . click ( ) ;
236
260
cy . contains ( '.euiComboBoxOption__content' , 'sample-ad-index' ) . click ( ) ;
261
+
237
262
cy . contains (
238
263
'.euiComboBoxOption__content' ,
239
- 'followCluster :sample-ad-index-two'
264
+ ` ${ remoteClusterName } :sample-ad-index-two`
240
265
) . click ( ) ;
241
266
242
267
selectTopItemFromFilter ( 'timestampFilter' , false ) ;
@@ -297,8 +322,10 @@ context('Create remote detector workflow', () => {
297
322
cy . contains ( 'span.euiTableCellContent__text' , 'Data connection' ) . should (
298
323
'be.visible'
299
324
) ;
325
+ cy . contains ( `${ remoteClusterName } (Remote)` ) . should ( 'be.visible' ) ;
326
+
300
327
cy . contains ( 'followCluster (Remote)' ) . should ( 'be.visible' ) ;
301
- cy . contains ( 'leaderCluster (Local)' ) . should ( 'be.visible' ) ;
328
+ cy . contains ( '(Local)' ) . should ( 'be.visible' ) ;
302
329
cy . contains ( 'sample-ad-index' ) . should ( 'be.visible' ) ;
303
330
304
331
cy . getElementByTestId ( 'euiFlyoutCloseButton' ) . click ( ) ;
@@ -326,8 +353,8 @@ context('Create remote detector workflow', () => {
326
353
cy . contains ( 'span.euiTableCellContent__text' , 'Data connection' ) . should (
327
354
'be.visible'
328
355
) ;
329
- cy . contains ( 'followCluster (Remote)' ) . should ( 'be.visible' ) ;
330
- cy . contains ( 'leaderCluster (Local)' ) . should ( 'be.visible' ) ;
356
+ cy . contains ( ` ${ remoteClusterName } (Remote)` ) . should ( 'be.visible' ) ;
357
+ cy . contains ( '(Local)' ) . should ( 'be.visible' ) ;
331
358
cy . contains ( 'sample-ad-index' ) . should ( 'be.visible' ) ;
332
359
} ) ;
333
360
} ) ;
0 commit comments