Skip to content

Commit 045d0b1

Browse files
Make it possible to skip some tests when running on 3.13
some feature flags and exchange types won't be available there, for instance.
1 parent 3f9d735 commit 045d0b1

11 files changed

+164
-26
lines changed

src/api.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,14 @@
1313
// limitations under the License.
1414
#![allow(clippy::result_large_err)]
1515

16-
use backtrace::Backtrace;
17-
use reqwest::{
18-
header::{HeaderMap, HeaderValue},
19-
Client as HttpClient, StatusCode,
20-
};
21-
use serde::Serialize;
22-
use serde_json::{json, Map, Value};
23-
use std::fmt;
24-
2516
use crate::error::Error;
2617
use crate::error::Error::{ClientErrorResponse, NotFound, ServerErrorResponse};
2718
use crate::requests::{
2819
Amqp091ShovelParams, Amqp10ShovelParams, EmptyPayload, StreamParams, SHOVEL_COMPONENT,
2920
};
3021
use crate::responses::{
3122
DeprecatedFeatureList, FeatureFlag, FeatureFlagList, FeatureFlagStability, FeatureFlagState,
32-
GetMessage, OAuthConfiguration, SchemaDefinitionSyncStatus, VirtualHostDefinitionSet,
23+
GetMessage, OAuthConfiguration, Overview, SchemaDefinitionSyncStatus, VirtualHostDefinitionSet,
3324
WarmStandbyReplicationStatus,
3425
};
3526
use crate::{
@@ -41,6 +32,14 @@ use crate::{
4132
},
4233
responses::{self, BindingInfo, ClusterDefinitionSet},
4334
};
35+
use backtrace::Backtrace;
36+
use reqwest::{
37+
header::{HeaderMap, HeaderValue},
38+
Client as HttpClient, StatusCode,
39+
};
40+
use serde::Serialize;
41+
use serde_json::{json, Map, Value};
42+
use std::fmt;
4443

4544
pub type HttpClientResponse = reqwest::Response;
4645
pub type HttpClientError = crate::error::HttpClientError;
@@ -1456,6 +1455,13 @@ where
14561455
Ok(response)
14571456
}
14581457

1458+
pub async fn server_version(&self) -> Result<String> {
1459+
let response = self.http_get("overview", None, None).await?;
1460+
let response: Overview = response.json().await?;
1461+
1462+
Ok(response.rabbitmq_version)
1463+
}
1464+
14591465
//
14601466
// Feature flags
14611467
//

src/blocking_api.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,12 @@ where
12831283
Ok(response)
12841284
}
12851285

1286+
pub fn server_version(&self) -> Result<String> {
1287+
let response = self.http_get("overview", None, None)?;
1288+
let response: responses::Overview = response.json()?;
1289+
Ok(response.rabbitmq_version)
1290+
}
1291+
12861292
//
12871293
// Feature flags
12881294
//

tests/async_deprecated_feature_tests.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rabbitmq_http_client::responses::DeprecationPhase;
1515
use rabbitmq_http_client::{api::Client, commons::QueueType, requests::QueueParams};
1616

1717
mod test_helpers;
18-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
18+
use crate::test_helpers::{async_testing_against_3_13_x, endpoint, PASSWORD, USERNAME};
1919

2020
#[tokio::test]
2121
async fn test_async_list_all_deprecated_features() {
@@ -35,6 +35,11 @@ async fn test_async_list_all_deprecated_features() {
3535
async fn test_async_list_deprecated_features_in_use() {
3636
let endpoint = endpoint();
3737
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
38+
39+
if async_testing_against_3_13_x().await {
40+
return;
41+
}
42+
3843
let vh = "/";
3944
let q = "test_list_deprecated_features_in_use";
4045

tests/async_dynamic_shovel_tests.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ use rabbitmq_http_client::{api::Client, requests::VirtualHostParams};
2020

2121
mod test_helpers;
2222
use crate::test_helpers::{
23-
amqp_endpoint_with_vhost, await_metric_emission, endpoint, PASSWORD, USERNAME,
23+
amqp_endpoint_with_vhost, async_testing_against_3_13_x, await_metric_emission, endpoint,
24+
PASSWORD, USERNAME,
2425
};
2526

2627
#[tokio::test]
2728
async fn test_async_declare_a_dynamic_amqp091_shovel() {
2829
let endpoint = endpoint();
2930
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
3031

32+
if async_testing_against_3_13_x().await {
33+
return;
34+
}
35+
3136
let vh = "rust.http.api.async.test_declare_a_dynamic_amqp091_shovel";
3237
let sh = "test_declare_a_dynamic_amqp091_shovel";
3338

@@ -62,6 +67,10 @@ async fn test_async_declare_a_dynamic_amqp10_shovel() {
6267
let endpoint = endpoint();
6368
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
6469

70+
if async_testing_against_3_13_x().await {
71+
return;
72+
}
73+
6574
let vh = "rust.http.api.async.test_async_declare_a_dynamic_amqp10_shovel";
6675
let sh = "test_async_declare_a_dynamic_amqp10_shovel";
6776

@@ -104,6 +113,10 @@ async fn test_async_declare_a_dynamic_amqp091_shovel_with_predeclared_source_top
104113
let endpoint = endpoint();
105114
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
106115

116+
if async_testing_against_3_13_x().await {
117+
return;
118+
}
119+
107120
let vh = "rust.http.api.blocking.test_declare_a_dynamic_amqp091_shovel_with_predeclared_source_topology";
108121
let sh = "test_declare_a_dynamic_amqp091_shovel_with_predeclared_source_topology";
109122

@@ -142,6 +155,10 @@ async fn test_async_declare_a_dynamic_amqp091_shovel_with_predeclared_destinatio
142155
let endpoint = endpoint();
143156
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
144157

158+
if async_testing_against_3_13_x().await {
159+
return;
160+
}
161+
145162
let vh = "rust.http.api.blocking.test_declare_a_dynamic_amqp091_shovel_with_predeclared_destination_topology";
146163
let sh = "test_declare_a_dynamic_amqp091_shovel_with_predeclared_destination_topology";
147164

@@ -183,6 +200,10 @@ async fn test_async_delete_a_dynamic_amqp091_shovel() {
183200
let endpoint = endpoint();
184201
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
185202

203+
if async_testing_against_3_13_x().await {
204+
return;
205+
}
206+
186207
let vh = "rust.http.api.async.test_delete_a_dynamic_amqp091_shovel";
187208
let sh = "test_delete_a_dynamic_amqp091_shovel";
188209

tests/async_exchange_tests.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rabbitmq_http_client::{api::Client, error::Error as APIClientError, requests
1515
use serde_json::{json, Map, Value};
1616

1717
mod test_helpers;
18-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
18+
use crate::test_helpers::{async_testing_against_3_13_x, endpoint, PASSWORD, USERNAME};
1919

2020
use rabbitmq_http_client::commons::ExchangeType;
2121

@@ -44,6 +44,10 @@ async fn test_async_declare_a_durable_headers_exchange() {
4444

4545
#[tokio::test]
4646
async fn test_async_declare_a_durable_local_random_exchange() {
47+
if async_testing_against_3_13_x().await {
48+
return;
49+
}
50+
4751
test_async_declare_a_durable_exchange_of_type(
4852
"rust.tests.local-rnd.1",
4953
ExchangeType::LocalRandom,
@@ -53,6 +57,10 @@ async fn test_async_declare_a_durable_local_random_exchange() {
5357

5458
#[tokio::test]
5559
async fn test_async_declare_a_durable_custom_exchange_type() {
60+
if async_testing_against_3_13_x().await {
61+
return;
62+
}
63+
5664
// This is a core type that's not in the AMQP 0-9-1 spec,
5765
// using it requiring additional plugins on the node
5866
test_async_declare_a_durable_exchange_of_type(

tests/async_feature_flag_tests.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ use rabbitmq_http_client::{
1717
};
1818

1919
mod test_helpers;
20-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
20+
use crate::test_helpers::{async_testing_against_3_13_x, endpoint, PASSWORD, USERNAME};
2121

2222
#[tokio::test]
2323
async fn test_async_list_feature_flags() {
2424
let endpoint = endpoint();
2525
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
26-
let result = rc.list_feature_flags().await;
2726

27+
if async_testing_against_3_13_x().await {
28+
return;
29+
}
30+
31+
let result = rc.list_feature_flags().await;
2832
assert!(result.is_ok());
2933
let vec = result.unwrap();
3034
assert!(vec
@@ -37,8 +41,12 @@ async fn test_async_list_feature_flags() {
3741
async fn test_async_enable_a_feature_flag() {
3842
let endpoint = endpoint();
3943
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
40-
let ff_name = "detailed_queues_endpoint";
4144

45+
if async_testing_against_3_13_x().await {
46+
return;
47+
}
48+
49+
let ff_name = "detailed_queues_endpoint";
4250
let result1 = rc.enable_feature_flag(ff_name).await;
4351
assert!(result1.is_ok());
4452

@@ -56,8 +64,12 @@ async fn test_async_enable_a_feature_flag() {
5664
async fn test_async_enable_all_stable_feature_flags() {
5765
let endpoint = endpoint();
5866
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
59-
let ff_name = "rabbitmq_4.0.0";
6067

68+
if async_testing_against_3_13_x().await {
69+
return;
70+
}
71+
72+
let ff_name = "rabbitmq_4.0.0";
6173
let result1 = rc.enable_all_stable_feature_flags().await;
6274
assert!(result1.is_ok());
6375

tests/blocking_deprecated_feature_tests.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rabbitmq_http_client::responses::DeprecationPhase;
1515
use rabbitmq_http_client::{blocking_api::Client, commons::QueueType, requests::QueueParams};
1616

1717
mod test_helpers;
18-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
18+
use crate::test_helpers::{endpoint, testing_against_3_13_x, PASSWORD, USERNAME};
1919

2020
#[test]
2121
fn test_blocking_list_all_deprecated_features() {
@@ -35,6 +35,11 @@ fn test_blocking_list_all_deprecated_features() {
3535
fn test_blocking_list_deprecated_features_in_use() {
3636
let endpoint = endpoint();
3737
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
38+
39+
if testing_against_3_13_x() {
40+
return;
41+
}
42+
3843
let vh = "/";
3944
let q = "test_list_deprecated_features_in_use";
4045

tests/blocking_dynamic_shovel_tests.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ use rabbitmq_http_client::{blocking_api::Client, requests::VirtualHostParams};
2020

2121
mod test_helpers;
2222
use crate::test_helpers::{
23-
amqp_endpoint_with_vhost, await_metric_emission, endpoint, PASSWORD, USERNAME,
23+
amqp_endpoint_with_vhost, await_metric_emission, endpoint, testing_against_3_13_x, PASSWORD,
24+
USERNAME,
2425
};
2526

2627
#[test]
2728
fn test_blocking_declare_a_dynamic_amqp091_shovel() {
2829
let endpoint = endpoint();
2930
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
3031

32+
if testing_against_3_13_x() {
33+
return;
34+
}
35+
3136
let vh = "rust.http.api.blocking.test_declare_a_dynamic_amqp091_shovel";
3237
let sh = "test_declare_a_dynamic_amqp091_shovel";
3338

@@ -62,6 +67,10 @@ fn test_blocking_declare_a_dynamic_amqp10_shovel() {
6267
let endpoint = endpoint();
6368
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
6469

70+
if testing_against_3_13_x() {
71+
return;
72+
}
73+
6574
let vh = "rust.http.api.blocking.test_blocking_declare_a_dynamic_amqp10_shovel";
6675
let sh = "test_async_declare_a_dynamic_amqp10_shovel";
6776

@@ -104,6 +113,10 @@ fn test_blocking_declare_a_dynamic_amqp091_shovel_with_predeclared_source_topolo
104113
let endpoint = endpoint();
105114
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
106115

116+
if testing_against_3_13_x() {
117+
return;
118+
}
119+
107120
let vh = "rust.http.api.blocking.test_declare_a_dynamic_amqp091_shovel_with_predeclared_source_topology";
108121
let sh = "test_declare_a_dynamic_amqp091_shovel_with_predeclared_source_topology";
109122

@@ -142,6 +155,10 @@ fn test_blocking_declare_a_dynamic_amqp091_shovel_with_predeclared_destination_t
142155
let endpoint = endpoint();
143156
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
144157

158+
if testing_against_3_13_x() {
159+
return;
160+
}
161+
145162
let vh = "rust.http.api.blocking.test_declare_a_dynamic_amqp091_shovel_with_predeclared_destination_topology";
146163
let sh = "test_declare_a_dynamic_amqp091_shovel_with_predeclared_destination_topology";
147164

@@ -183,6 +200,10 @@ fn test_blocking_delete_a_dynamic_amqp091_shovel() {
183200
let endpoint = endpoint();
184201
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
185202

203+
if testing_against_3_13_x() {
204+
return;
205+
}
206+
186207
let vh = "rust.http.api.blocking.test_delete_a_dynamic_amqp091_shovel";
187208
let sh = "test_delete_a_dynamic_amqp091_shovel";
188209

tests/blocking_exchange_tests.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rabbitmq_http_client::{
1717
use serde_json::{json, Map, Value};
1818

1919
mod test_helpers;
20-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
20+
use crate::test_helpers::{endpoint, testing_against_3_13_x, PASSWORD, USERNAME};
2121

2222
use rabbitmq_http_client::commons::ExchangeType;
2323

@@ -43,11 +43,19 @@ fn test_blocking_declare_a_durable_headers_exchange() {
4343

4444
#[test]
4545
fn test_blocking_declare_a_durable_local_random_exchange() {
46+
if testing_against_3_13_x() {
47+
return;
48+
}
49+
4650
test_declare_a_durable_exchange_of_type("rust.tests.local-rnd.1", ExchangeType::LocalRandom);
4751
}
4852

4953
#[test]
5054
fn test_blocking_declare_a_durable_custom_exchange_type() {
55+
if testing_against_3_13_x() {
56+
return;
57+
}
58+
5159
// This is a core type that's not in the AMQP 0-9-1 spec,
5260
// using it requiring additional plugins on the node
5361
test_declare_a_durable_exchange_of_type(

tests/blocking_feature_flag_tests.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ use rabbitmq_http_client::{
1717
};
1818

1919
mod test_helpers;
20-
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
20+
use crate::test_helpers::{endpoint, testing_against_3_13_x, PASSWORD, USERNAME};
2121

2222
#[test]
2323
fn test_blocking_list_feature_flags() {
2424
let endpoint = endpoint();
2525
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
26-
let result = rc.list_feature_flags();
2726

27+
if testing_against_3_13_x() {
28+
return;
29+
}
30+
31+
let result = rc.list_feature_flags();
2832
assert!(result.is_ok());
2933
let vec = result.unwrap();
3034
assert!(vec
@@ -37,8 +41,12 @@ fn test_blocking_list_feature_flags() {
3741
fn test_blocking_enable_a_feature_flag() {
3842
let endpoint = endpoint();
3943
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
40-
let ff_name = "detailed_queues_endpoint";
4144

45+
if testing_against_3_13_x() {
46+
return;
47+
}
48+
49+
let ff_name = "detailed_queues_endpoint";
4250
let result1 = rc.enable_feature_flag(ff_name);
4351
assert!(result1.is_ok());
4452

@@ -56,8 +64,12 @@ fn test_blocking_enable_a_feature_flag() {
5664
fn test_blocking_enable_all_stable_feature_flags() {
5765
let endpoint = endpoint();
5866
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
59-
let ff_name = "rabbitmq_4.0.0";
6067

68+
if testing_against_3_13_x() {
69+
return;
70+
}
71+
72+
let ff_name = "rabbitmq_4.0.0";
6173
let result1 = rc.enable_all_stable_feature_flags();
6274
assert!(result1.is_ok());
6375

0 commit comments

Comments
 (0)