This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 5e497b37162 HDDS-17941. Reduce AWS CLI profile setup overhead in STS
acceptance test (#12180)
5e497b37162 is described below
commit 5e497b37162f9c792b2a2de65d899e8b468e1af2
Author: Chi-Hsuan Huang <[email protected]>
AuthorDate: Fri Nov 27 18:30:37 2026 +0800
HDDS-17941. Reduce AWS CLI profile setup overhead in STS acceptance test
(#12180)
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../src/main/smoketest/security/aws_profile.py | 45 ++++++++++++++++++++++
.../smoketest/security/ozone-secure-sts.resource | 11 ++----
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/hadoop-ozone/dist/src/main/smoketest/security/aws_profile.py
b/hadoop-ozone/dist/src/main/smoketest/security/aws_profile.py
new file mode 100644
index 00000000000..b07a6bcbf70
--- /dev/null
+++ b/hadoop-ozone/dist/src/main/smoketest/security/aws_profile.py
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Writes AWS CLI profiles directly, same result as a series of `aws configure
set` calls,
+without starting the AWS CLI for each setting."""
+
+import configparser
+import os
+
+
+def _update(path, section, values):
+ parser = configparser.RawConfigParser()
+ parser.read(path)
+ if not parser.has_section(section):
+ parser.add_section(section)
+ for key, value in values.items():
+ parser.set(section, key, value)
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ # Same as AWS CLI: new files are readable only by the owner
+ with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
0o600), "w") as f:
+ parser.write(f)
+
+
+def write_aws_profile(profile, access_key, secret_key, session_token="",
region="us-east-1"):
+ aws_dir = os.path.expanduser("~/.aws")
+ config_file = os.environ.get("AWS_CONFIG_FILE", os.path.join(aws_dir,
"config"))
+ credentials_file = os.environ.get("AWS_SHARED_CREDENTIALS_FILE",
os.path.join(aws_dir, "credentials"))
+ config_section = profile if profile == "default" else "profile " + profile
+ _update(config_file, config_section, {"s3": "\nsignature_version = s3v4",
"region": region})
+ credentials = {"aws_access_key_id": access_key, "aws_secret_access_key":
secret_key}
+ if session_token:
+ credentials["aws_session_token"] = session_token
+ _update(credentials_file, profile, credentials)
diff --git
a/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-sts.resource
b/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-sts.resource
index 9c6c6fbbac1..774a044ca93 100644
--- a/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-sts.resource
+++ b/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-sts.resource
@@ -19,6 +19,7 @@ Library String
Library BuiltIn
Library DateTime
Library Collections
+Library ./aws_profile.py
Resource ../admincli/lib.resource
Resource ../commonlib.robot
Resource ../s3/commonawslib.robot
@@ -39,11 +40,7 @@ Configure AWS Profile
[Arguments] ${profile} ${access_key} ${secret_key}
${session_token}=${EMPTY} ${region}=us-east-1
Run Keyword Install aws cli
# Use v4 signatures so presign URL will work (Ozone rejects v2 signatures)
- Execute aws configure set s3.signature_version s3v4
--profile ${profile}
- Execute aws configure set aws_access_key_id
${access_key} --profile ${profile}
- Execute aws configure set aws_secret_access_key
${secret_key} --profile ${profile}
- Execute aws configure set region ${region} --profile
${profile}
- Run Keyword If '${session_token}' != '${EMPTY}' Execute
aws configure set aws_session_token ${session_token} --profile ${profile}
+ Write AWS Profile ${profile} ${access_key} ${secret_key}
${session_token} ${region}
Configure STS Profile
[Arguments] ${access_key} ${secret_key}
${session_token}
@@ -272,8 +269,8 @@ Assign User To Tenant And Get Credentials
[Arguments] ${user} ${tenant}
${output} = Execute ozone tenant
--verbose user assign ${user} --tenant=${tenant}
Should Contain ${output} Assigned
'${user}' to '${tenant}'
- @{access_key_matches} = Get Regexp Matches ${output}
(?m)(?<=export AWS_ACCESS_KEY_ID=).*$
- @{secret_key_matches} = Get Regexp Matches ${output}
(?m)(?<=export AWS_SECRET_ACCESS_KEY=).*$
+ @{access_key_matches} = Get Regexp Matches ${output}
(?m)(?<=export AWS_ACCESS_KEY_ID=')[^']*
+ @{secret_key_matches} = Get Regexp Matches ${output}
(?m)(?<=export AWS_SECRET_ACCESS_KEY=')[^']*
${access_key_id} = Strip String
${access_key_matches[0]}
${secret_key} = Strip String
${secret_key_matches[0]}
[Return] ${access_key_id} ${secret_key}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]