Skip to content

Commit 1d9e51c

Browse files
committedMar 21, 2025
add transport port dynamically when changing setting
Signed-off-by: Amit Galitzky <amgalitz@amazon.com>
1 parent 51d6e07 commit 1d9e51c

File tree

1 file changed

+30
-38
lines changed

1 file changed

+30
-38
lines changed
 

‎cypress/integration/plugins/anomaly-detection-dashboards-plugin/create_remote_detector_spec.js

+30-38
Original file line numberDiff line numberDiff line change
@@ -68,54 +68,45 @@ context('Create remote detector workflow', () => {
6868
before(function () {
6969
const remoteClusterName = Cypress.env('remoteClusterName');
7070

71-
const remoteClusterSettings = {
72-
persistent: {
73-
[`cluster.remote.${remoteClusterName}`]: {
74-
seeds: ['127.0.0.1:9301'],
75-
},
76-
},
77-
};
78-
79-
cy.visit(AD_URL.OVERVIEW, { timeout: 10000 });
71+
const remoteSettings = `${Cypress.env(
72+
'remoteDataSourceNoAuthUrl'
73+
)}/_cluster/settings?include_defaults=true`;
8074

8175
cy.request({
82-
method: 'PUT',
83-
url: `${BACKEND_BASE_PATH}/_cluster/settings`,
76+
method: 'GET',
77+
form: false,
78+
url: remoteSettings,
8479
headers: {
85-
'content-type': 'application/json',
80+
'content-type': 'application/json;charset=UTF-8',
8681
'osd-xsrf': true,
8782
},
88-
body: remoteClusterSettings,
8983
}).then((response) => {
90-
Cypress.log({ message: 'Cluster settings updated successfully' });
91-
expect(response.status).to.eq(200);
92-
});
84+
const remoteTransportPort = response.body.defaults.transport.port;
9385

94-
cy.wait(5000);
95-
const remoteSettings = `${Cypress.env(
96-
'remoteDataSourceNoAuthUrl'
97-
)}/_cluster/settings?include_defaults=true`;
98-
cy.request(
99-
{
100-
method: 'GET',
101-
form: false,
102-
url: remoteSettings,
86+
Cypress.log({
87+
message: `transport port: ${remoteTransportPort}`,
88+
});
89+
90+
const remoteClusterSettings = {
91+
persistent: {
92+
[`cluster.remote.${remoteClusterName}`]: {
93+
seeds: [`127.0.0.1:${remoteTransportPort}`],
94+
},
95+
},
96+
};
97+
98+
cy.request({
99+
method: 'PUT',
100+
url: `${BACKEND_BASE_PATH}/_cluster/settings`,
103101
headers: {
104-
'content-type': 'application/json;charset=UTF-8',
102+
'content-type': 'application/json',
105103
'osd-xsrf': true,
106104
},
107-
},
108-
1000
109-
).then((response) => {
110-
Cypress.log({
111-
message: `transport port: ${JSON.stringify(
112-
response.body.defaults.transport.port
113-
)}`,
105+
body: remoteClusterSettings,
106+
}).then((putResponse) => {
107+
Cypress.log({ message: 'Cluster settings updated successfully' });
108+
expect(putResponse.status).to.eq(200);
114109
});
115-
116-
if (response.body.defaults.transport.port != 9301) {
117-
this.skip();
118-
}
119110
});
120111
});
121112

@@ -144,9 +135,10 @@ context('Create remote detector workflow', () => {
144135
},
145136
body: data,
146137
},
147-
1000
138+
2000
148139
);
149140
});
141+
cy.wait(1000);
150142
cy.fixture(AD_FIXTURE_BASE_PATH + 'sample_remote_test_data.txt').then(
151143
(data) => {
152144
cy.request(

0 commit comments

Comments
 (0)