amazon-s3 - 如何通过机器人框架运行 AWS CLI 命令?
问题描述
更新我的问题:我的测试场景是获取特定 S3 存储桶中的文件大小。为此,我安装了 robotframework-aws 库。现在我不确定要使用哪个关键字来获取文件大小。这是我到目前为止编写的代码:
Run AWS CLI Command to capture file size of S3 MRL Hub Source
Create Session With Keys region: us-east-1 access_key: xxxx secret_key: xxxx aws_session_token: str
Read File From S3 bucket_name: com-abc-def-ghi key: name/of/the/file/i/am/looking/for.parquet
使用此代码,我收到以下错误:
InvalidRegionError: Provided region_name 'region: us-east-1' doesn't match a supported format.
解决方案
您可以使用运行命令,它是OperatingSystem
库的一部分,在安装 RobotFramework 时默认已包含该命令。
有了这个,你可以让 Robotframework 运行你想要的任何命令提示符。例如:
*** Settings ***
Library OperatingSystem
*** Test Cases ***
Test run command
${output}= Run aws --version
log ${output}
当您想要使用aws configure
. 我的意思是,你不能指望 Robotframework 测试用例会要求你输入。在这种情况下,您需要事先提供所有aws configure
选项。这意味着您需要profile
为您的测试用例准备一个文件,然后您可以连接更多命令,例如:
*** Test Cases ***
Test run command
${output}= Run aws configure --profile <profilename> && set https_proxy http://webproxy.xyz.com:8080
log ${output}
或者更好地使用profile
s3 直接使用文件,例如aws s3 ls --profile <profilename>
.
请记住,最好的方法是使用某种外部库,例如使用boto3 Python libraryAWSLibrary
创建您自己的自定义库。
推荐阅读
- ruby-on-rails - 如何在 Rails 中真正发送电子邮件
- docker - 使用 docker 提供 tensorflow 服务我做错了什么?
- python - DataFrame.select_dtypes(exclude=['object']) 实际上做了什么?
- linux - Rider 和 xamarin.forms 使用主机 linux 系统创建跨平台解决方案的问题
- python - 如何使用我的电报机器人存储来自用户的输入,然后在需要时获取输入
- node.js - 使用 Passport js 进行身份验证的端点测试
- android - 如何获取我的 Firestore 的新更新图像的 url?
- html - 引导折叠关闭
- graphql - Postman 在 GraphQL 调用中没有得到正确类型的 Int 变量
- python - 使用 Python ElementTree 从 xml 文档中提取文本