From d689a16e6d5b4aa25d2cfcfe2e835a7fe00049ee Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Thu, 30 Jan 2025 15:44:58 +0100 Subject: [PATCH 1/4] Separate invalid client test from the valid one --- deps/rabbitmq_mqtt/test/auth_SUITE.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/deps/rabbitmq_mqtt/test/auth_SUITE.erl b/deps/rabbitmq_mqtt/test/auth_SUITE.erl index 51bfe7b291a4..372de7b1edcb 100644 --- a/deps/rabbitmq_mqtt/test/auth_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/auth_SUITE.erl @@ -68,9 +68,11 @@ sub_groups() -> ssl_user_vhost_parameter_mapping_vhost_does_not_exist, 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, [], - [client_id_from_cert_san_dns, - invalid_client_id_from_cert_san_dns + [client_id_from_cert_san_dns ]}, {ssl_user_with_client_id_in_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) -> {rabbitmq_mqtt, [{ssl_cert_login, 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}, {allow_anonymous, false}, {ssl_cert_client_id_from, subject_alternative_name}, @@ -588,7 +591,7 @@ client_id_from_cert_dn(Config) -> invalid_client_id_from_cert_san_dns(Config) -> MqttClientId = <<"other_client_id">>, {ok, C} = connect_ssl(MqttClientId, Config), - ?assertMatch({error, _}, emqtt:connect(C)), + {error, {client_identifier_not_valid, _}} = emqtt:connect(C), unlink(C). ssl_user_vhost_parameter_mapping_success(Config) -> From de8f59d83a841c2037aebe936bf63ff41a436873 Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 5 Feb 2025 15:08:10 +0100 Subject: [PATCH 2/4] Apply same changes from pr #13197 --- selenium/package.json | 2 +- selenium/test/pageobjects/BasePage.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/selenium/package.json b/selenium/package.json index 251a751f09ca..a0dca54d43f7 100644 --- a/selenium/package.json +++ b/selenium/package.json @@ -12,7 +12,7 @@ "author": "", "license": "ISC", "dependencies": { - "chromedriver": "^130.0.4", + "chromedriver": "^132.0", "ejs": "^3.1.8", "express": "^4.18.2", "geckodriver": "^3.0.2", diff --git a/selenium/test/pageobjects/BasePage.js b/selenium/test/pageobjects/BasePage.js index b54311520833..1ef3e061b02a 100644 --- a/selenium/test/pageobjects/BasePage.js +++ b/selenium/test/pageobjects/BasePage.js @@ -45,6 +45,7 @@ module.exports = class BasePage { return this.selectOption(SELECT_REFRESH, option) } async waitForOverviewTab() { + await this.driver.sleep(250) return this.waitForDisplayed(OVERVIEW_TAB) } @@ -56,6 +57,7 @@ module.exports = class BasePage { return this.click(CONNECTIONS_TAB) } async waitForConnectionsTab() { + await this.driver.sleep(250) return this.waitForDisplayed(CONNECTIONS_TAB) } @@ -63,6 +65,7 @@ module.exports = class BasePage { return this.click(ADMIN_TAB) } async waitForAdminTab() { + await this.driver.sleep(250) return this.waitForDisplayed(ADMIN_TAB) } @@ -70,6 +73,7 @@ module.exports = class BasePage { return this.click(CHANNELS_TAB) } async waitForChannelsTab() { + await this.driver.sleep(250) return this.waitForDisplayed(CHANNELS_TAB) } @@ -77,6 +81,7 @@ module.exports = class BasePage { return this.click(EXCHANGES_TAB) } async waitForExchangesTab() { + await this.driver.sleep(250) return this.waitForDisplayed(EXCHANGES_TAB) } From 3a61274f0311bd4ff26fbc98e4e5cc9b855c9837 Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 5 Feb 2025 16:18:03 +0100 Subject: [PATCH 3/4] Deal with stalereferences caused by timing issues looking up objects in the DOM --- selenium/test/pageobjects/BasePage.js | 83 ++++++++++++++++++--------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/selenium/test/pageobjects/BasePage.js b/selenium/test/pageobjects/BasePage.js index 1ef3e061b02a..dd6ff2230203 100644 --- a/selenium/test/pageobjects/BasePage.js +++ b/selenium/test/pageobjects/BasePage.js @@ -185,42 +185,69 @@ module.exports = class BasePage { } async waitForLocated (locator) { - try { - return this.driver.wait(until.elementLocated(locator), this.timeout, - 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator, - this.polling) - }catch(error) { - if (!error.name.includes("NoSuchSessionError")) { - console.error("Failed waitForLocated " + locator + " due to " + error) - } - throw error - } + let attempts = 3 + let retry = false + let rethrowError = null + do { + try { + return this.driver.wait(until.elementLocated(locator), this.timeout, + 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] seconds locating ' + locator, + this.polling) + }catch(error) { + if (error.name.includes("StaleElementReferenceError")) { + retry = true + }else if (!error.name.includes("NoSuchSessionError")) { + console.error("Failed waitForLocated " + locator + " due to " + error) + retry = false + } + rethrowError = error + } + } while (retry && --attempts > 0) + throw rethrowError } async waitForVisible (element) { - try { - return this.driver.wait(until.elementIsVisible(element), this.timeout, - 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element, - this.polling) - }catch(error) { - if (!error.name.includes("NoSuchSessionError")) { - console.error("Failed to find visible element " + element + " due to " + error) + let attempts = 3 + let retry = false + let rethrowError = null + do { + try { + return this.driver.wait(until.elementIsVisible(element), this.timeout, + 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element, + this.polling) + }catch(error) { + if (error.name.includes("StaleElementReferenceError")) { + retry = true + }else if (!error.name.includes("NoSuchSessionError")) { + console.error("Failed to find visible element " + element + " due to " + error) + retry = false + } + rethrowError = error } - throw error - } + } while (retry && --attempts > 0) + throw rethrowError } async waitForDisplayed (locator) { - if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay) - try { - return this.waitForVisible(await this.waitForLocated(locator)) - }catch(error) { - if (!error.name.includes("NoSuchSessionError")) { - console.error("Failed to waitForDisplayed " + locator + " due to " + error) - } - throw error - } + let attempts = 3 + let retry = false + let rethrowError = null + do { + if (this.interactionDelay && this.interactionDelay > 0) await this.driver.sleep(this.interactionDelay) + try { + return this.waitForVisible(await this.waitForLocated(locator)) + }catch(error) { + if (error.name.includes("StaleElementReferenceError")) { + retry = true + }else if (!error.name.includes("NoSuchSessionError")) { + retry = false + console.error("Failed to waitForDisplayed " + locator + " due to " + error) + } + rethrowError = error + } + } while (retry && --attempts > 0 ) + throw rethrowError } async getText (locator) { From 3ca11fc0d012d020f5183902f3ce10595b1a19a7 Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 12 Feb 2025 14:42:08 +0100 Subject: [PATCH 4/4] Unlink before assertion --- deps/rabbitmq_mqtt/test/auth_SUITE.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/rabbitmq_mqtt/test/auth_SUITE.erl b/deps/rabbitmq_mqtt/test/auth_SUITE.erl index 372de7b1edcb..a7a4ea78f1d8 100644 --- a/deps/rabbitmq_mqtt/test/auth_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/auth_SUITE.erl @@ -591,8 +591,8 @@ client_id_from_cert_dn(Config) -> invalid_client_id_from_cert_san_dns(Config) -> MqttClientId = <<"other_client_id">>, {ok, C} = connect_ssl(MqttClientId, Config), - {error, {client_identifier_not_valid, _}} = emqtt:connect(C), - unlink(C). + unlink(C), + {error, {client_identifier_not_valid, _}} = emqtt:connect(C). ssl_user_vhost_parameter_mapping_success(Config) -> expect_successful_connection(fun connect_ssl/1, Config).