lifecycle功能测试方法是什么
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,本篇内容主要讲解"lifecycle功能测试方法是什么",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"lifecycle功能测试方法是什么"吧!lifecy
千家信息网最后更新 2025年12月02日lifecycle功能测试方法是什么
本篇内容主要讲解"lifecycle功能测试方法是什么",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"lifecycle功能测试方法是什么"吧!
lifecycle功能测试
功能描述:
1.目前从k版本开始支持lifecycle,且仅支持Expired,既过期对象删除。
2.AWS4认证下无法进行lifecycle的修改操作,HTTP层面会出现501错误。
3.boto和boto3可以支持AWS2认证下的get和put操作,测试功能可用。
4.测试发现先对bucket进行get_lifecycle操作,如果返回404,则对应的response的内容不完整,之后的一次request请求中的response会被污染。
get_bucket_lifecycle 测试用例
boto3用例
import boto3from botocore.client import Configaws_access_key_id = ''aws_secret_access_key = ''bucket_name = 'test1'# aws4s3 = boto3.client('s3', region_name='CN', use_ssl=False, endpoint_url='http://ceph.work', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, config=Config(signature_version='s3v4', s3={'addressing_style': 'virtual'}))# aws2s3 = boto3.client('s3', region_name=None, use_ssl=False, endpoint_url='http://ceph.work', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, config=Config(s3={'addressing_style': 'virtual'}))print s3.get_bucket_lifecycle(Bucket=bucket_name)print s3.get_bucket_lifecycle_configuration(Bucket=bucket_name)boto用例
from boto.s3.connection import S3Connectionimport boto# import os# os.environ['S3_USE_SIGV4'] = 'True' #use aws4access_key = ''secret_key = ''host = 'ceph.work'bucket_name = 'test1'conn = boto.connect_s3( aws_access_key_id=access_key, aws_secret_access_key=secret_key, host=host, is_secure=False, calling_format=boto.s3.connection.SubdomainCallingFormat(), validate_certs=True,)bucket = conn.get_bucket(bucket_name)config = bucket.get_lifecycle_config()for i in config: print i.endElement print i.expiration print i.id print i.startElement print i.to_xml()
put_bucket_lifecycle 测试用例
boto3用例
import boto3from botocore.client import Configimport datetimeaws_access_key_id = ''aws_secret_access_key = ''bucket_name = 'test1'#aws2 可用s3 = boto3.client('s3', region_name=None, use_ssl=False, endpoint_url='http://ceph.work', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, config=Config(s3={'addressing_style': 'virtual'}))#aws4 错误,返回501s3 = boto3.client('s3', region_name='CN', use_ssl=False, endpoint_url='http://ceph.work', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, config=Config(signature_version='s3v4', s3={'addressing_style': 'virtual'}))print s3.put_bucket_lifecycle( Bucket=bucket_name, LifecycleConfiguration={ 'Rules': [ { 'Expiration': { 'Date': datetime.datetime(2015, 3, 15), 'Days': 123, 'ExpiredObjectDeleteMarker': True|False }, 'ID': 'demo1', 'Prefix': '/abc', 'Status': 'Enabled', 'Transition': { 'Date': datetime.datetime(2017, 3, 15), 'Days': 123, 'StorageClass': 'STANDARD_IA' }, 'NoncurrentVersionTransition': { 'NoncurrentDays': 123, 'StorageClass': 'STANDARD_IA' }, 'NoncurrentVersionExpiration': { 'NoncurrentDays': 123 }, 'AbortIncompleteMultipartUpload': { 'DaysAfterInitiation': 123 } }, ] })501错误提示,应该是官方还没完成该部分特性。
NotImplementedtx000000000000000000056-0058d0d70b-10b2-default 10b2-default-default
boto用例
from boto.s3.connection import S3Connectionimport botoimport boto.s3.lifecycleimport os# os.environ['S3_USE_SIGV4'] = 'True' #use aws4from boto.s3.lifecycle import ( Lifecycle, Expiration,)access_key = ''secret_key = ''host = 'ceph.work'bucket_name = 'test1'conn = boto.connect_s3( aws_access_key_id=access_key, aws_secret_access_key=secret_key, host=host, is_secure=False, calling_format=boto.s3.connection.SubdomainCallingFormat(), validate_certs=True,)bucket = conn.get_bucket(bucket_name)#type 1lifecycle_config = boto.s3.lifecycle.Lifecycle()lifecycle_config.add_rule('lc_rule_1', 'del/', 'Enabled', 1)lifecycle_config.add_rule('lc_rule_2', '/abc', 'Enabled', 10)bucket.configure_lifecycle(lifecycle_config)#type 2lifecycle = Lifecycle()lifecycle.add_rule('lc_rule_1', prefix='del/', status='Enable', expiration=Expiration(days=1))lifecycle.add_rule('lc_rule_2', prefix='data/', status='Enabled', expiration=Expiration(days=10))bucket.configure_lifecycle(lifecycle)get_bucket_lifecycled的bug
from boto.s3.connection import S3Connectionimport botoaccess_key = ''secret_key = ''host = 'ceph.work'bucket_name = 'test1'conn = boto.connect_s3( aws_access_key_id=access_key, aws_secret_access_key=secret_key, host=host, is_secure=False, calling_format=boto.s3.connection.SubdomainCallingFormat(), validate_certs=True,)bucket = conn.get_bucket(bucket_name)print bucket.get_lifecycle_config() #未设置bucket的lifecycle,返回404,报以下错误
错误提示
Traceback (most recent call last): File "/Users/Diluga/SourceCode/PycharmProjects/kv_server/boto_demo/demo1.py", line 56, inprint bucket.get_lifecycle_config() File "/Users/Diluga/lwc/lib/python2.7/site-packages/boto/s3/bucket.py", line 1387, in get_lifecycle_config response.status, response.reason, body)boto.exception.S3ResponseError: S3ResponseError: 404 Not Found #xml未结束,下一个request请求所返回的response会被污染 NoSuchLifecycleConfigurationsnappy-test tx00000000000000000008f-0058d0dc3b-10b2-default 10b2-default-default
s3cmd同样报错
DEBUG: signature-v4 headers: {'x-amz-content-sha256': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': 'AWS4-HMAC-SHA256 Credential=W7L3YC842AGADI1T8BV9/20170321/CN/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=d0a6ca337af207d00d170f5bb999782f49928b01395494c96d3dd31f88d987c7', 'x-amz-date': '20170321T075840Z'}DEBUG: Processing request, please wait...DEBUG: get_hostname(snappy-test): snappy-test.ceph.workDEBUG: ConnMan.get(): re-using connection: http://snappy-test.ceph.work#2DEBUG: format_uri(): /?lifecycleDEBUG: Sending request method_string='GET', uri='/?lifecycle', headers={'x-amz-content-sha256': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': 'AWS4-HMAC-SHA256 Credential=W7L3YC842AGADI1T8BV9/20170321/CN/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=d0a6ca337af207d00d170f5bb999782f49928b01395494c96d3dd31f88d987c7', 'x-amz-date': '20170321T075840Z'}, body=(0 bytes)DEBUG: Response: {'status': 404, 'headers': {'date': 'Tue, 21 Mar 2017 07:58:40 GMT', 'content-length': '237', 'x-amz-request-id': 'tx000000000000000000092-0058d0dd30-10b2-default', 'content-type': 'application/xml', 'accept-ranges': 'bytes'}, 'reason': 'Not Found', 'data': 'NoSuchLifecycleConfigurationsnappy-test tx000000000000000000092-0058d0dd30-10b2-default 10b2-default-default '}DEBUG: ConnMan.put(): connection put back to pool (http://snappy-test.ceph.work#3)DEBUG: S3Error: 404 (Not Found)DEBUG: HttpHeader: date: Tue, 21 Mar 2017 07:58:40 GMTDEBUG: HttpHeader: content-length: 237DEBUG: HttpHeader: x-amz-request-id: tx000000000000000000092-0058d0dd30-10b2-defaultDEBUG: HttpHeader: content-type: application/xmlDEBUG: HttpHeader: accept-ranges: bytesDEBUG: ErrorXML: Code: 'NoSuchLifecycleConfiguration'DEBUG: ErrorXML: BucketName: 'snappy-test'DEBUG: ErrorXML: RequestId: 'tx000000000000000000092-0058d0dd30-10b2-default'DEBUG: ErrorXML: HostId: '10b2-default-default'DEBUG: Could not get /?lifecycle - lifecycle probably not configured for this bucket Expiration Rule: noneDEBUG: CreateRequest: resource[uri]=/?aclDEBUG: Using signature v4DEBUG: get_hostname(snappy-test): snappy-test.ceph.workDEBUG: canonical_headers = host:snappy-test.ceph.workx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date:20170321T075840ZDEBUG: Canonical Request:GET/acl=host:snappy-test.ceph.workx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855x-amz-date:20170321T075840Zhost;x-amz-content-sha256;x-amz-datee3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855----------------------DEBUG: signature-v4 headers: {'x-amz-content-sha256': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': 'AWS4-HMAC-SHA256 Credential=W7L3YC842AGADI1T8BV9/20170321/CN/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=03386b844b8600b0cdd28d38d8a6e528fa75385cab056771f9148266905a33dd', 'x-amz-date': '20170321T075840Z'}DEBUG: Processing request, please wait...DEBUG: get_hostname(snappy-test): snappy-test.ceph.workDEBUG: ConnMan.get(): re-using connection: http://snappy-test.ceph.work#3DEBUG: format_uri(): /?aclDEBUG: Sending request method_string='GET', uri='/?acl', headers={'x-amz-content-sha256': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': 'AWS4-HMAC-SHA256 Credential=W7L3YC842AGADI1T8BV9/20170321/CN/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=03386b844b8600b0cdd28d38d8a6e528fa75385cab056771f9148266905a33dd', 'x-amz-date': '20170321T075840Z'}, body=(0 bytes)DEBUG: Response: {'status': 200, 'headers': {}, 'reason': '', 'data': ' HTTP/1.1 200 OK\r\nx-amz-request-id: tx000000000000000000093-0058d0dd30-10b2-default\r\nContent-Type: application/xml\r\nContent-Length: 441\r\nDate: Tue, 21 Mar 2017 07:58:40 GMT\r\n\r\nu-gfn2636 u-gfn2636 u-gfn2636 u-gfn2636 FULL_CONTROL '}DEBUG: ConnMan.put(): connection put back to pool (http://snappy-test.ceph.work#4)ERROR: Error parsing xml: not well-formed (invalid token): line 1, column 101ERROR: HTTP/1.1 200 OKx-amz-request-id: tx000000000000000000093-0058d0dd30-10b2-defaultContent-Type: application/xmlContent-Length: 441Date: Tue, 21 Mar 2017 07:58:40 GMTu-gfn2636 u-gfn2636 u-gfn2636 u-gfn2636 FULL_CONTROL 到此,相信大家对"lifecycle功能测试方法是什么"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
测试
功能
错误
功能测试
方法
内容
支持
学习
提示
污染
认证
实用
更深
兴趣
官方
实用性
实际
对象
层面
操作简单
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
把照片存数据库
聊天软件开发的特点有哪些
数据库分离sql
服务器怎么能进安全模式
联通网络安全维护
服务器辐射危害防护
相片编辑软件开发
哪些服务器属于常用软件包
南通网络服务器机柜可按要求定制
roblox唐县服务器
怎么提高软件开发的单价
阳江无限软件开发供应商家
数据库标识符命名
辽宁服务器电源专卖店
华为的网络技术怎么样
ug10.0许可证服务器
联盟电竞互联网科技有限公司
合肥软件开发公司招聘
杭州同欣网络技术有限公司广告
如何设计一个软件开发规范
数据库中真子集
山东恒来源网络技术有限公司
剑与远征不同服务器有什么不同
软件开发未来还能做销售吗
总参网络安全
网络安全技术与应用优秀论文
多数据库管理工具
服务器2008r2安装
徐州it关于网络安全培训机构
银行软件开发项目外包