blob: 6e89539f24c42d2c0d7f1a4704f7450be1470870 [file] [log] [blame]
Attila Fazekasa23f5002012-10-23 19:32:45 +02001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Matthew Treinisha83a16e2012-12-07 13:44:02 -050018from contextlib import closing
19
20from boto.s3.key import Key
Attila Fazekasa23f5002012-10-23 19:32:45 +020021from nose.plugins.attrib import attr
22import unittest2 as unittest
Matthew Treinisha83a16e2012-12-07 13:44:02 -050023
Matthew Treinish481466b2012-12-20 17:16:01 -050024from tempest import clients
Attila Fazekasa23f5002012-10-23 19:32:45 +020025from tempest.common.utils.data_utils import rand_name
Matthew Treinisha83a16e2012-12-07 13:44:02 -050026from tempest.testboto import BotoTestCase
Attila Fazekasa23f5002012-10-23 19:32:45 +020027from tempest.tests import boto
Attila Fazekasa23f5002012-10-23 19:32:45 +020028
29
30@attr("S3")
31class S3BucketsTest(BotoTestCase):
32
33 @classmethod
34 def setUpClass(cls):
35 super(S3BucketsTest, cls).setUpClass()
Matthew Treinish481466b2012-12-20 17:16:01 -050036 cls.os = clients.Manager()
Attila Fazekasa23f5002012-10-23 19:32:45 +020037 cls.client = cls.os.s3_client
38 cls.config = cls.os.config
39
40 @unittest.skip("Skipped until the Bug #1076534 is resolved")
41 @attr(type='smoke')
42 def test_create_get_delete_object(self):
Sean Dague64ef48d2013-01-03 17:54:36 -050043 # S3 Create, get and delete object
Attila Fazekasa23f5002012-10-23 19:32:45 +020044 bucket_name = rand_name("s3bucket-")
45 object_name = rand_name("s3object-")
46 content = 'x' * 42
47 bucket = self.client.create_bucket(bucket_name)
48 self.addResourceCleanUp(self.destroy_bucket,
49 self.client.connection_data,
50 bucket_name)
51
52 self.assertTrue(bucket.name == bucket_name)
53 with closing(Key(bucket)) as key:
54 key.key = object_name
55 key.set_contents_from_string(content)
56 readback = key.get_contents_as_string()
57 self.assertTrue(readback == content)
58 bucket.delete_key(key)
59 self.assertBotoError(self.s3_error_code.client.NoSuchKey,
60 key.get_contents_as_string)