Skip to content

Commit 88125ff

Browse files
kishankavalaDaanHoogland
authored andcommitted
add smoke test for bucket life cycle
1 parent 9619696 commit 88125ff

File tree

2 files changed

+150
-1
lines changed

2 files changed

+150
-1
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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

tools/marvin/marvin/lib/base.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6735,4 +6735,42 @@ def update(self, apiclient, **kwargs):
67356735
cmd = updateObjectStoragePool.updateObjectStoragePoolCmd()
67366736
cmd.id = self.id
67376737
[setattr(cmd, k, v) for k, v in list(kwargs.items())]
6738-
return apiclient.updateObjectStoragePool(cmd)
6738+
return apiclient.updateObjectStoragePool(cmd)
6739+
6740+
class Bucket:
6741+
"""Manage Bucket Life cycle"""
6742+
6743+
def __init__(self, items):
6744+
self.__dict__.update(items)
6745+
6746+
@classmethod
6747+
def create(cls, apiclient, name, objectstorageid, **kwargs):
6748+
"""Create Bucket"""
6749+
cmd = createBucket.createBucketCmd()
6750+
cmd.name = name
6751+
cmd.objectstorageid = objectstorageid
6752+
[setattr(cmd, k, v) for k, v in list(kwargs.items())]
6753+
6754+
return Bucket(apiclient.createBucket(cmd).__dict__)
6755+
6756+
def delete(self, apiclient):
6757+
"""Delete Bucket"""
6758+
cmd = deleteBucket.deleteBucketCmd()
6759+
cmd.id = self.id
6760+
apiclient.deleteBucket(cmd)
6761+
6762+
@classmethod
6763+
def list(cls, apiclient, **kwargs):
6764+
cmd = listBuckets.listBucketsCmd()
6765+
[setattr(cmd, k, v) for k, v in list(kwargs.items())]
6766+
if 'account' in list(kwargs.keys()) and 'domainid' in list(kwargs.keys()):
6767+
cmd.listall = True
6768+
return (apiclient.listBuckets(cmd))
6769+
6770+
def update(self, apiclient, **kwargs):
6771+
"""Update Bucket"""
6772+
6773+
cmd = updateBucket.updateBucketCmd()
6774+
cmd.id = self.id
6775+
[setattr(cmd, k, v) for k, v in list(kwargs.items())]
6776+
return apiclient.updateBucket(cmd)

0 commit comments

Comments
 (0)