You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by eo...@apache.org on 2022/06/24 13:45:36 UTC
[pulsar] branch master updated: [fix][tests] TieredStorageConfigurationTests - clear system properties (#15957)
This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new bacc9d69c66 [fix][tests] TieredStorageConfigurationTests - clear system properties (#15957)
bacc9d69c66 is described below
commit bacc9d69c66777879a6418e3d61c546150a5e753
Author: Enrico Olivelli <eo...@apache.org>
AuthorDate: Fri Jun 24 15:45:26 2022 +0200
[fix][tests] TieredStorageConfigurationTests - clear system properties (#15957)
---
.../provider/TieredStorageConfigurationTests.java | 42 ++++++++++++----------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/provider/TieredStorageConfigurationTests.java b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/provider/TieredStorageConfigurationTests.java
index bf5e046bf70..8370fb95804 100644
--- a/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/provider/TieredStorageConfigurationTests.java
+++ b/tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/provider/TieredStorageConfigurationTests.java
@@ -129,19 +129,21 @@ public class TieredStorageConfigurationTests {
// set the aws properties with fake creds so the defaultProviderChain works
System.setProperty("aws.accessKeyId", "fakeid1");
System.setProperty("aws.secretKey", "fakekey1");
- Credentials creds1 = config.getProviderCredentials().get();
- assertEquals(creds1.identity, "fakeid1");
- assertEquals(creds1.credential, "fakekey1");
+ try {
+ Credentials creds1 = config.getProviderCredentials().get();
+ assertEquals(creds1.identity, "fakeid1");
+ assertEquals(creds1.credential, "fakekey1");
- // reset the properties and ensure we get different values by re-evaluating the chain
- System.setProperty("aws.accessKeyId", "fakeid2");
- System.setProperty("aws.secretKey", "fakekey2");
- Credentials creds2 = config.getProviderCredentials().get();
- assertEquals(creds2.identity, "fakeid2");
- assertEquals(creds2.credential, "fakekey2");
-
- System.clearProperty("aws.accessKeyId");
- System.clearProperty("aws.secretKey");
+ // reset the properties and ensure we get different values by re-evaluating the chain
+ System.setProperty("aws.accessKeyId", "fakeid2");
+ System.setProperty("aws.secretKey", "fakekey2");
+ Credentials creds2 = config.getProviderCredentials().get();
+ assertEquals(creds2.identity, "fakeid2");
+ assertEquals(creds2.credential, "fakekey2");
+ } finally {
+ System.clearProperty("aws.accessKeyId");
+ System.clearProperty("aws.secretKey");
+ }
}
/**
@@ -215,11 +217,15 @@ public class TieredStorageConfigurationTests {
map.put("s3ManagedLedgerOffloadRegion", "my-region");
System.setProperty("jclouds.SystemPropertyA", "A");
System.setProperty("jclouds.region", "jclouds-region");
- TieredStorageConfiguration config = new TieredStorageConfiguration(map);
- Properties properties = config.getOverrides();
- System.out.println(properties.toString());
- assertEquals(properties.get("jclouds.region"), "jclouds-region");
- assertEquals(config.getServiceEndpoint(), "http://localhost");
- assertEquals(properties.get("jclouds.SystemPropertyA"), "A");
+ try {
+ TieredStorageConfiguration config = new TieredStorageConfiguration(map);
+ Properties properties = config.getOverrides();
+ assertEquals(properties.get("jclouds.region"), "jclouds-region");
+ assertEquals(config.getServiceEndpoint(), "http://localhost");
+ assertEquals(properties.get("jclouds.SystemPropertyA"), "A");
+ } finally {
+ System.clearProperty("jclouds.SystemPropertyA");
+ System.clearProperty("jclouds.region");
+ }
}
}