Fix flake on rabbitmq_mqtt auth_SUITE (#13180)

* Separate invalid client test from the valid one

* Apply same changes from pr #13197

* Deal with stalereferences caused by timing issues

looking up objects in the DOM

* Unlink before assertion
This commit is contained in:
Marcial Rosales 2025-02-12 17:15:51 +01:00 committed by GitHub
parent e8a302a249
commit 2ab890f344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 69 additions and 34 deletions

View File

@ -68,9 +68,11 @@ sub_groups() ->
ssl_user_vhost_parameter_mapping_vhost_does_not_exist, ssl_user_vhost_parameter_mapping_vhost_does_not_exist,
ssl_user_cert_vhost_mapping_takes_precedence_over_port_vhost_mapping ssl_user_cert_vhost_mapping_takes_precedence_over_port_vhost_mapping
]}, ]},
{ssl_user_with_invalid_client_id_in_cert_san_dns, [],
[invalid_client_id_from_cert_san_dns
]},
{ssl_user_with_client_id_in_cert_san_dns, [], {ssl_user_with_client_id_in_cert_san_dns, [],
[client_id_from_cert_san_dns, [client_id_from_cert_san_dns
invalid_client_id_from_cert_san_dns
]}, ]},
{ssl_user_with_client_id_in_cert_san_dns_1, [], {ssl_user_with_client_id_in_cert_san_dns_1, [],
[client_id_from_cert_san_dns_1 [client_id_from_cert_san_dns_1
@ -207,7 +209,8 @@ mqtt_config(no_ssl_user) ->
mqtt_config(client_id_propagation) -> mqtt_config(client_id_propagation) ->
{rabbitmq_mqtt, [{ssl_cert_login, true}, {rabbitmq_mqtt, [{ssl_cert_login, true},
{allow_anonymous, true}]}; {allow_anonymous, true}]};
mqtt_config(ssl_user_with_client_id_in_cert_san_dns) -> mqtt_config(T) when T == ssl_user_with_client_id_in_cert_san_dns;
T == ssl_user_with_invalid_client_id_in_cert_san_dns ->
{rabbitmq_mqtt, [{ssl_cert_login, true}, {rabbitmq_mqtt, [{ssl_cert_login, true},
{allow_anonymous, false}, {allow_anonymous, false},
{ssl_cert_client_id_from, subject_alternative_name}, {ssl_cert_client_id_from, subject_alternative_name},
@ -588,8 +591,8 @@ client_id_from_cert_dn(Config) ->
invalid_client_id_from_cert_san_dns(Config) -> invalid_client_id_from_cert_san_dns(Config) ->
MqttClientId = <<"other_client_id">>, MqttClientId = <<"other_client_id">>,
{ok, C} = connect_ssl(MqttClientId, Config), {ok, C} = connect_ssl(MqttClientId, Config),
?assertMatch({error, _}, emqtt:connect(C)), unlink(C),
unlink(C). {error, {client_identifier_not_valid, _}} = emqtt:connect(C).
ssl_user_vhost_parameter_mapping_success(Config) -> ssl_user_vhost_parameter_mapping_success(Config) ->
expect_successful_connection(fun connect_ssl/1, Config). expect_successful_connection(fun connect_ssl/1, Config).

View File

@ -12,7 +12,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"chromedriver": "^130.0.4", "chromedriver": "^132.0",
"ejs": "^3.1.8", "ejs": "^3.1.8",
"express": "^4.18.2", "express": "^4.18.2",
"geckodriver": "^3.0.2", "geckodriver": "^3.0.2",

View File

@ -45,6 +45,7 @@ module.exports = class BasePage {
return this.selectOption(SELECT_REFRESH, option) return this.selectOption(SELECT_REFRESH, option)
} }
async waitForOverviewTab() { async waitForOverviewTab() {
await this.driver.sleep(250)
return this.waitForDisplayed(OVERVIEW_TAB) return this.waitForDisplayed(OVERVIEW_TAB)
} }
@ -56,6 +57,7 @@ module.exports = class BasePage {
return this.click(CONNECTIONS_TAB) return this.click(CONNECTIONS_TAB)
} }
async waitForConnectionsTab() { async waitForConnectionsTab() {
await this.driver.sleep(250)
return this.waitForDisplayed(CONNECTIONS_TAB) return this.waitForDisplayed(CONNECTIONS_TAB)
} }
@ -63,6 +65,7 @@ module.exports = class BasePage {
return this.click(ADMIN_TAB) return this.click(ADMIN_TAB)
} }
async waitForAdminTab() { async waitForAdminTab() {
await this.driver.sleep(250)
return this.waitForDisplayed(ADMIN_TAB) return this.waitForDisplayed(ADMIN_TAB)
} }
@ -70,6 +73,7 @@ module.exports = class BasePage {
return this.click(CHANNELS_TAB) return this.click(CHANNELS_TAB)
} }
async waitForChannelsTab() { async waitForChannelsTab() {
await this.driver.sleep(250)
return this.waitForDisplayed(CHANNELS_TAB) return this.waitForDisplayed(CHANNELS_TAB)
} }
@ -77,6 +81,7 @@ module.exports = class BasePage {
return this.click(EXCHANGES_TAB) return this.click(EXCHANGES_TAB)
} }
async waitForExchangesTab() { async waitForExchangesTab() {
await this.driver.sleep(250)
return this.waitForDisplayed(EXCHANGES_TAB) return this.waitForDisplayed(EXCHANGES_TAB)
} }
@ -180,42 +185,69 @@ module.exports = class BasePage {
} }
async waitForLocated (locator) { async waitForLocated (locator) {
let attempts = 3
let retry = false
let rethrowError = null
do {
try { try {
return this.driver.wait(until.elementLocated(locator), this.timeout, return this.driver.wait(until.elementLocated(locator), this.timeout,
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator, 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator,
this.polling) this.polling)
}catch(error) { }catch(error) {
if (!error.name.includes("NoSuchSessionError")) { if (error.name.includes("StaleElementReferenceError")) {
retry = true
}else if (!error.name.includes("NoSuchSessionError")) {
console.error("Failed waitForLocated " + locator + " due to " + error) console.error("Failed waitForLocated " + locator + " due to " + error)
retry = false
} }
throw error rethrowError = error
} }
} while (retry && --attempts > 0)
throw rethrowError
} }
async waitForVisible (element) { async waitForVisible (element) {
let attempts = 3
let retry = false
let rethrowError = null
do {
try { try {
return this.driver.wait(until.elementIsVisible(element), this.timeout, return this.driver.wait(until.elementIsVisible(element), this.timeout,
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element, 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
this.polling) this.polling)
}catch(error) { }catch(error) {
if (!error.name.includes("NoSuchSessionError")) { if (error.name.includes("StaleElementReferenceError")) {
retry = true
}else if (!error.name.includes("NoSuchSessionError")) {
console.error("Failed to find visible element " + element + " due to " + error) console.error("Failed to find visible element " + element + " due to " + error)
retry = false
} }
throw error rethrowError = error
} }
} while (retry && --attempts > 0)
throw rethrowError
} }
async waitForDisplayed (locator) { async waitForDisplayed (locator) {
let attempts = 3
let retry = false
let rethrowError = null
do {
if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay) if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay)
try { try {
return this.waitForVisible(await this.waitForLocated(locator)) return this.waitForVisible(await this.waitForLocated(locator))
}catch(error) { }catch(error) {
if (!error.name.includes("NoSuchSessionError")) { if (error.name.includes("StaleElementReferenceError")) {
retry = true
}else if (!error.name.includes("NoSuchSessionError")) {
retry = false
console.error("Failed to waitForDisplayed " + locator + " due to " + error) console.error("Failed to waitForDisplayed " + locator + " due to " + error)
} }
throw error rethrowError = error
} }
} while (retry && --attempts > 0 )
throw rethrowError
} }
async getText (locator) { async getText (locator) {