Skip to content

Commit

Permalink
Also support all S3_PING configuration options as environment variables
Browse files Browse the repository at this point in the history
#374; update stacks to the latest jgroups template tcp.xml stack

Update tests to leverage properties instead of hard-coded values.
  • Loading branch information
rhusar committed Jan 15, 2025
1 parent 746d7b5 commit c78c88c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 43 deletions.
12 changes: 10 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,50 @@ System Property

| `region_name` +
System property: `jgroups.aws.s3.region_name`
Environment variable: `JGROUPS_AWS_S3_REGION_NAME`
| *required*
| The S3 region to use.

| `bucket_name` +
System property: `jgroups.aws.s3.bucket_name`
Environment variable: `JGROUPS_AWS_S3_BUCKET_NAME`
| *required*
| The S3 bucket to use.

| `bucket_prefix` +
System property: `jgroups.aws.s3.bucket_prefix`
Environment variable: `JGROUPS_AWS_S3_BUCKET_PREFIX`
|
| The S3 bucket prefix to use (optional e.g. 'jgroups/').


| `check_if_bucket_exists` +
System property: `jgroups.aws.s3.check_if_bucket_exists`
Environment variable: `JGROUPS_AWS_S3_CHECK_IF_BUCKET_EXISTS`
| `true`
| Checks if the bucket exists in S3 and creates a new one if missing

| `endpoint` +
System property: `jgroups.aws.s3.endpoint`
Environment variable: `JGROUPS_AWS_S3_ENDPOINT`
|
| The S3 endpoint to use (optional).

| `path_style_access_enabled` +
System property: `jgroups.aws.s3.path_style_access_enabled`
Environment variable: `JGROUPS_AWS_S3_PATH_STYLE_ACCESS_ENABLED`
| `false`
| The S3 path-style enable (optional).

| `kms_key_id` +
System property: `jgroups.aws.s3.kms_key_id`
Environment variable: `JGROUPS_AWS_S3_KMS_KEY_ID`
|
| Use kms encryption with s3 with the given kms key (optionally - enables KMS Server side encryption (SSE-KMS) using the given kms key)

| `acl_grant_bucket_owner_full_control` +
System property: `jgroups.aws.s3.acl_grant_bucket_owner_full_control`
Environment variable: `JGROUPS_AWS_S3_ACL_GRANT_BUCKET_OWNER_FULL_CONTROL`
| `false`
| Flag indicating whether or not to grant the bucket owner full control over the bucket on each update. This is useful in multi-region deployments where each region exists in its own AWS account.

Expand Down Expand Up @@ -142,8 +150,8 @@ along with setting the region name and a bucket name.
----
declare -x AWS_ACCESS_KEY_ID="qF7ujVAaYUp3Tx7m"
declare -x AWS_SECRET_ACCESS_KEY="WzbG3R2KGtx5rsHQUx2PKQPS2f6WzMtf"
declare -x S3_PING_REGION_NAME="eu-central-1"
declare -x S3_PING_BUCKET_NAME="jgroups"
declare -x JGROUPS_AWS_S3_REGION_NAME="eu-central-1"
declare -x JGROUPS_AWS_S3_BUCKET_NAME="jgroups"
mvn verify
----

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/jgroups/protocols/aws/S3_PING.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,42 @@ public class S3_PING extends FILE_PING {
protected static final String MAGIC_NUMBER_SYSTEM_PROPERTY="s3ping.magic_number";

@Property(description = "The S3 path-style enable (optional).",
systemProperty = "jgroups.aws.s3.path_style_access_enabled",
systemProperty = {"jgroups.aws.s3.path_style_access_enabled", "JGROUPS_AWS_S3_PATH_STYLE_ACCESS_ENABLED"},
writable = false)
protected boolean path_style_access_enabled;

@Property(description = "The S3 endpoint to use (optional).",
systemProperty = "jgroups.aws.s3.endpoint",
systemProperty = {"jgroups.aws.s3.endpoint", "JGROUPS_AWS_S3_ENDPOINT"},
writable = false)
protected String endpoint;

@Property(description = "The S3 region to use.",
systemProperty = "jgroups.aws.s3.region_name",
systemProperty = {"jgroups.aws.s3.region_name", "JGROUPS_AWS_S3_REGION_NAME"},
writable = false)
protected String region_name;

@Property(description = "The S3 bucket to use.",
systemProperty = "jgroups.aws.s3.bucket_name",
systemProperty = {"jgroups.aws.s3.bucket_name", "JGROUPS_AWS_S3_BUCKET_NAME"},
writable = false)
protected String bucket_name;

@Property(description = "The S3 bucket prefix to use (optional e.g. 'jgroups/').",
systemProperty = "jgroups.aws.s3.bucket_prefix",
systemProperty = {"jgroups.aws.s3.bucket_prefix", "JGROUPS_AWS_S3_BUCKET_PREFIX"},
writable = false)
protected String bucket_prefix;

@Property(description = "Checks if the bucket exists in S3 and creates a new one if missing",
systemProperty = "jgroups.aws.s3.check_if_bucket_exists",
systemProperty = {"jgroups.aws.s3.check_if_bucket_exists", "JGROUPS_AWS_S3_CHECK_IF_BUCKET_EXISTS"},
writable = false)
protected boolean check_if_bucket_exists = true;

@Property(description = "Flag indicating whether or not to grant the bucket owner full control over the bucket on each update. This is useful in multi-region deployments where each region exists in its own AWS account.",
systemProperty = "jgroups.aws.s3.acl_grant_bucket_owner_full_control",
systemProperty = {"jgroups.aws.s3.acl_grant_bucket_owner_full_control", "JGROUPS_AWS_S3_ACL_GRANT_BUCKET_OWNER_FULL_CONTROL"},
writable = false)
protected boolean acl_grant_bucket_owner_full_control;

@Property(description = "KMS key to use for enabling KMS server-side encryption (SSE-KMS) for S3 (optional).",
systemProperty = "jgroups.aws.s3.kms_key_id",
systemProperty = {"jgroups.aws.s3.kms_key_id", "JGROUPS_AWS_S3_KMS_KEY_ID"},
exposeAsManagedAttribute = false)
protected String kms_key_id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ public static void setUp() {
s3Mock = new S3MockContainer("latest");
s3Mock.start();

// TODO workaround using S3MockContainer#getHttpEndpoint() by an IP address so it doesn't rely on spoofing DNS records
System.setProperty("org.jgroups.aws.endpoint", "http://127.0.0.1:" + s3Mock.getHttpServerPort());
// Configure the protocol - it has no hardcoded values in the stack xml file, so we can set all values using properties
// TODO workaround using S3MockContainer#getHttpsEndpoint() by an IP address so it doesn't rely on spoofing DNS records
// TODO switch to TLS
System.setProperty("jgroups.aws.s3.endpoint", "http://127.0.0.1:" + s3Mock.getHttpServerPort());
System.setProperty("jgroups.aws.s3.region_name", "ping-testing-region");
System.setProperty("jgroups.aws.s3.bucket_name", "ping-test-bucket");

// Setup fake credentials against the mock service
System.setProperty("aws.accessKeyId", "foo");
System.setProperty("aws.secretAccessKey", "bar");
System.setProperty("S3_PING_BUCKET_NAME", "testing-ping");
}

@AfterClass
Expand Down
27 changes: 12 additions & 15 deletions src/test/resources/org/jgroups/protocols/aws/tcp-NATIVE_S3_PING.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<!--
Formatted copy of the original jgroups-5.2.2.Final.jar!/tcp.xml reconfigured to use NATIVE_S3_PING and disabled diagnostics.
Formatted copy of the original jgroups-5.3.13.Final.jar!/tcp.xml reconfigured to use NATIVE_S3_PING and disabled diagnostics.
-->

<!--
Expand All @@ -36,27 +36,24 @@
thread_pool.max_threads="200"
thread_pool.keep_alive_time="30000"
diag.enabled="false"/>
<RED/>
<org.jgroups.aws.s3.NATIVE_S3_PING region_name="${S3_PING_REGION_NAME:eu-central-1}"
bucket_name="${S3_PING_BUCKET_NAME}"
endpoint="${org.jgroups.aws.endpoint}"
/>
<MERGE3 min_interval="10000"
max_interval="30000"/>
<NON_BLOCKING_SENDS/>
<org.jgroups.aws.s3.NATIVE_S3_PING/>
<MERGE3 min_interval="10s"
max_interval="30s"/>
<FD_SOCK2/>
<FD_ALL3 timeout="40000"
interval="5000"/>
<VERIFY_SUSPECT2 timeout="1500"/>
<FD_ALL3 timeout="40s"
interval="5s"/>
<VERIFY_SUSPECT2 timeout="1.5s"/>
<BARRIER/>
<pbcast.NAKACK2 use_mcast_xmit="false"/>
<UNICAST3/>
<pbcast.STABLE desired_avg_gossip="50000"
<pbcast.STABLE desired_avg_gossip="50s"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true"
join_timeout="2000"/>
<UFC max_credits="2M"
join_timeout="2s"/>
<MFC max_credits="10M"
min_threshold="0.4"/>
<MFC max_credits="2M"
<UFC max_credits="10M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K"/>
<pbcast.STATE_TRANSFER/>
Expand Down
27 changes: 12 additions & 15 deletions src/test/resources/org/jgroups/protocols/aws/tcp-S3_PING.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<!--
Formatted copy of the original jgroups-5.2.2.Final.jar!/tcp.xml reconfigured to use S3_PING and disabled diagnostics.
Formatted copy of the original jgroups-5.3.13.Final.jar!/tcp.xml reconfigured to use S3_PING and disabled diagnostics.
-->

<!--
Expand All @@ -36,27 +36,24 @@
thread_pool.max_threads="200"
thread_pool.keep_alive_time="30000"
diag.enabled="false"/>
<RED/>
<aws.S3_PING region_name="${S3_PING_REGION_NAME:eu-central-1}"
bucket_name="${S3_PING_BUCKET_NAME}"
endpoint="${org.jgroups.aws.endpoint}"
/>
<MERGE3 min_interval="10000"
max_interval="30000"/>
<NON_BLOCKING_SENDS/>
<aws.S3_PING/>
<MERGE3 min_interval="10s"
max_interval="30s"/>
<FD_SOCK2/>
<FD_ALL3 timeout="40000"
interval="5000"/>
<VERIFY_SUSPECT2 timeout="1500"/>
<FD_ALL3 timeout="40s"
interval="5s"/>
<VERIFY_SUSPECT2 timeout="1.5s"/>
<BARRIER/>
<pbcast.NAKACK2 use_mcast_xmit="false"/>
<UNICAST3/>
<pbcast.STABLE desired_avg_gossip="50000"
<pbcast.STABLE desired_avg_gossip="50s"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true"
join_timeout="2000"/>
<UFC max_credits="2M"
join_timeout="2s"/>
<MFC max_credits="10M"
min_threshold="0.4"/>
<MFC max_credits="2M"
<UFC max_credits="10M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K"/>
<pbcast.STATE_TRANSFER/>
Expand Down

0 comments on commit c78c88c

Please sign in to comment.