1+ # Licensed to the Apache Software Foundation (ASF) under one
2+ # or more contributor license agreements. See the NOTICE file
3+ # distributed with this work for additional information
4+ # regarding copyright ownership. The ASF licenses this file
5+ # to you under the Apache License, Version 2.0 (the
6+ # "License"); you may not use this file except in compliance
7+ # with the License. You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing,
12+ # software distributed under the License is distributed on an
13+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ # KIND, either express or implied. See the License for the
15+ # specific language governing permissions and limitations
16+ # under the License.
17+ """ BVT tests for Bucket Operations"""
18+
19+ #Import Local Modules
20+ from marvin .cloudstackTestCase import *
21+ from nose .plugins .attrib import attr
22+ from marvin .lib .base import (ObjectStoragePool , Bucket )
23+ from marvin .lib .utils import (cleanup_resources )
24+
25+ _multiprocess_shared_ = True
26+
27+ class TestObjectStore (cloudstackTestCase ):
28+
29+ def setUp (self ):
30+ self .services = self .testClient .getParsedTestDataConfig ()
31+ self .apiclient = self .testClient .getApiClient ()
32+ self .dbclient = self .testClient .getDbConnection ()
33+ self .cleanup = []
34+ return
35+
36+ def tearDown (self ):
37+ try :
38+ #Clean up, terminate the created resources
39+ cleanup_resources (self .apiclient , self .cleanup )
40+
41+ except Exception as e :
42+ raise Exception ("Warning: Exception during cleanup : %s" % e )
43+ return
44+
45+ @attr (tags = ["smoke" ], required_hardware = "false" )
46+ def test_01_create_bucket (self ):
47+ """Test to create bucket in object store
48+
49+ """
50+
51+ object_store = ObjectStoragePool .create (
52+ self .apiclient ,
53+ "testOS-8" ,
54+ "http://localhost" ,
55+ "Simulator" ,
56+ None
57+ )
58+
59+ self .debug ("Created Object Store with ID: %s" % object_store .id )
60+
61+ bucket = Bucket .create (
62+ self .apiclient ,
63+ "myBucket" ,
64+ object_store .id
65+ )
66+
67+ list_buckets_response = Bucket .list (
68+ self .apiclient ,
69+ id = bucket .id
70+ )
71+
72+ self .assertNotEqual (
73+ len (list_buckets_response ),
74+ 0 ,
75+ "Check List Bucket response"
76+ )
77+
78+ bucket_response = list_buckets_response [0 ]
79+ self .assertEqual (
80+ object_store .id ,
81+ bucket_response .objectstorageid ,
82+ "Check object store id of the created Bucket"
83+ )
84+ self .assertEqual (
85+ "myBucket" ,
86+ bucket_response .name ,
87+ "Check Name of the created Bucket"
88+ )
89+
90+ bucket .update (
91+ self .apiclient ,
92+ quota = 100
93+ )
94+
95+ list_buckets_response_updated = Bucket .list (
96+ self .apiclient ,
97+ id = bucket .id
98+ )
99+
100+ bucket_response_updated = list_buckets_response_updated [0 ]
101+
102+ self .assertEqual (
103+ 100 ,
104+ bucket_response_updated .quota ,
105+ "Check quota of the updated bucket"
106+ )
107+
108+ self .cleanup .append (bucket )
109+ self .cleanup .append (object_store )
110+
111+ return
0 commit comments