Skip to content

Commit 94576a0

Browse files
Merge pull request #13249 from rabbitmq/mergify/bp/v4.0.x/pr-13246
Fix flake on rabbitmq_mqtt auth_SUITE (backport #13180) (backport #13246)
2 parents f605799 + 033f945 commit 94576a0

File tree

3 files changed

+70
-35
lines changed

3 files changed

+70
-35
lines changed

deps/rabbitmq_mqtt/test/auth_SUITE.erl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ sub_groups() ->
6868
ssl_user_vhost_parameter_mapping_vhost_does_not_exist,
6969
ssl_user_cert_vhost_mapping_takes_precedence_over_port_vhost_mapping
7070
]},
71-
{ssl_user_with_client_id_in_cert_san_dns, [],
72-
[client_id_from_cert_san_dns,
73-
invalid_client_id_from_cert_san_dns
71+
{ssl_user_with_invalid_client_id_in_cert_san_dns, [],
72+
[invalid_client_id_from_cert_san_dns
73+
]},
74+
{ssl_user_with_client_id_in_cert_san_dns, [],
75+
[client_id_from_cert_san_dns
7476
]},
7577
{ssl_user_with_client_id_in_cert_san_dns_1, [],
7678
[client_id_from_cert_san_dns_1
@@ -207,7 +209,8 @@ mqtt_config(no_ssl_user) ->
207209
mqtt_config(client_id_propagation) ->
208210
{rabbitmq_mqtt, [{ssl_cert_login, true},
209211
{allow_anonymous, true}]};
210-
mqtt_config(ssl_user_with_client_id_in_cert_san_dns) ->
212+
mqtt_config(T) when T == ssl_user_with_client_id_in_cert_san_dns;
213+
T == ssl_user_with_invalid_client_id_in_cert_san_dns ->
211214
{rabbitmq_mqtt, [{ssl_cert_login, true},
212215
{allow_anonymous, false},
213216
{ssl_cert_client_id_from, subject_alternative_name},
@@ -588,8 +591,8 @@ client_id_from_cert_dn(Config) ->
588591
invalid_client_id_from_cert_san_dns(Config) ->
589592
MqttClientId = <<"other_client_id">>,
590593
{ok, C} = connect_ssl(MqttClientId, Config),
591-
?assertMatch({error, _}, emqtt:connect(C)),
592-
unlink(C).
594+
unlink(C),
595+
{error, {client_identifier_not_valid, _}} = emqtt:connect(C).
593596

594597
ssl_user_vhost_parameter_mapping_success(Config) ->
595598
expect_successful_connection(fun connect_ssl/1, Config).

selenium/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"chromedriver": "^128.0.0",
15+
"chromedriver": "^132.0",
1616
"ejs": "^3.1.8",
1717
"express": "^4.18.2",
1818
"geckodriver": "^3.0.2",

selenium/test/pageobjects/BasePage.js

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = class BasePage {
4545
return this.selectOption(SELECT_REFRESH, option)
4646
}
4747
async waitForOverviewTab() {
48+
await this.driver.sleep(250)
4849
return this.waitForDisplayed(OVERVIEW_TAB)
4950
}
5051

@@ -56,27 +57,31 @@ module.exports = class BasePage {
5657
return this.click(CONNECTIONS_TAB)
5758
}
5859
async waitForConnectionsTab() {
60+
await this.driver.sleep(250)
5961
return this.waitForDisplayed(CONNECTIONS_TAB)
6062
}
6163

6264
async clickOnAdminTab () {
6365
return this.click(ADMIN_TAB)
6466
}
6567
async waitForAdminTab() {
68+
await this.driver.sleep(250)
6669
return this.waitForDisplayed(ADMIN_TAB)
6770
}
6871

6972
async clickOnChannelsTab () {
7073
return this.click(CHANNELS_TAB)
7174
}
7275
async waitForChannelsTab() {
76+
await this.driver.sleep(250)
7377
return this.waitForDisplayed(CHANNELS_TAB)
7478
}
7579

7680
async clickOnExchangesTab () {
7781
return this.click(EXCHANGES_TAB)
7882
}
7983
async waitForExchangesTab() {
84+
await this.driver.sleep(250)
8085
return this.waitForDisplayed(EXCHANGES_TAB)
8186
}
8287

@@ -179,42 +184,69 @@ module.exports = class BasePage {
179184
}
180185

181186
async waitForLocated (locator) {
182-
try {
183-
return this.driver.wait(until.elementLocated(locator), this.timeout,
184-
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator,
185-
this.polling)
186-
}catch(error) {
187-
if (!error.name.includes("NoSuchSessionError")) {
188-
console.error("Failed waitForLocated " + locator + " due to " + error)
189-
}
190-
throw error
191-
}
187+
let attempts = 3
188+
let retry = false
189+
let rethrowError = null
190+
do {
191+
try {
192+
return this.driver.wait(until.elementLocated(locator), this.timeout,
193+
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator,
194+
this.polling)
195+
}catch(error) {
196+
if (error.name.includes("StaleElementReferenceError")) {
197+
retry = true
198+
}else if (!error.name.includes("NoSuchSessionError")) {
199+
console.error("Failed waitForLocated " + locator + " due to " + error)
200+
retry = false
201+
}
202+
rethrowError = error
203+
}
204+
} while (retry && --attempts > 0)
205+
throw rethrowError
192206
}
193207

194208
async waitForVisible (element) {
195-
try {
196-
return this.driver.wait(until.elementIsVisible(element), this.timeout,
197-
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
198-
this.polling)
199-
}catch(error) {
200-
if (!error.name.includes("NoSuchSessionError")) {
201-
console.error("Failed to find visible element " + element + " due to " + error)
209+
let attempts = 3
210+
let retry = false
211+
let rethrowError = null
212+
do {
213+
try {
214+
return this.driver.wait(until.elementIsVisible(element), this.timeout,
215+
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
216+
this.polling)
217+
}catch(error) {
218+
if (error.name.includes("StaleElementReferenceError")) {
219+
retry = true
220+
}else if (!error.name.includes("NoSuchSessionError")) {
221+
console.error("Failed to find visible element " + element + " due to " + error)
222+
retry = false
223+
}
224+
rethrowError = error
202225
}
203-
throw error
204-
}
226+
} while (retry && --attempts > 0)
227+
throw rethrowError
205228
}
206229

207230

208231
async waitForDisplayed (locator) {
209-
if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay)
210-
try {
211-
return this.waitForVisible(await this.waitForLocated(locator))
212-
}catch(error) {
213-
if (!error.name.includes("NoSuchSessionError")) {
214-
console.error("Failed to waitForDisplayed " + locator + " due to " + error)
215-
}
216-
throw error
217-
}
232+
let attempts = 3
233+
let retry = false
234+
let rethrowError = null
235+
do {
236+
if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay)
237+
try {
238+
return this.waitForVisible(await this.waitForLocated(locator))
239+
}catch(error) {
240+
if (error.name.includes("StaleElementReferenceError")) {
241+
retry = true
242+
}else if (!error.name.includes("NoSuchSessionError")) {
243+
retry = false
244+
console.error("Failed to waitForDisplayed " + locator + " due to " + error)
245+
}
246+
rethrowError = error
247+
}
248+
} while (retry && --attempts > 0 )
249+
throw rethrowError
218250
}
219251

220252
async getText (locator) {

0 commit comments

Comments
 (0)