Merge "Implement tempest tests for share extend API"
This commit is contained in:
commit
b7ab5553fa
@ -378,6 +378,22 @@ class SharesActionsTest(base.BaseSharesTest):
|
|||||||
sorted_list = [snap['share_id'] for snap in snaps]
|
sorted_list = [snap['share_id'] for snap in snaps]
|
||||||
self.assertEqual(sorted_list, sorted(sorted_list))
|
self.assertEqual(sorted_list, sorted(sorted_list))
|
||||||
|
|
||||||
|
@test.attr(type=["gate", ])
|
||||||
|
@testtools.skipUnless(
|
||||||
|
CONF.share.run_extend_tests,
|
||||||
|
"Share extend tests are disabled.")
|
||||||
|
def test_extend_share(self):
|
||||||
|
share = self.create_share(size=1, cleanup_in_class=False)
|
||||||
|
new_size = 2
|
||||||
|
|
||||||
|
# extend share and wait for active status
|
||||||
|
self.shares_client.extend_share(share['id'], new_size)
|
||||||
|
self.shares_client.wait_for_share_status(share['id'], 'available')
|
||||||
|
|
||||||
|
# check state and new size
|
||||||
|
share = self.shares_client.get_share(share['id'])
|
||||||
|
self.assertEqual(new_size, share['size'])
|
||||||
|
|
||||||
|
|
||||||
class SharesRenameTest(base.BaseSharesTest):
|
class SharesRenameTest(base.BaseSharesTest):
|
||||||
|
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
# Copyright 2015 Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from tempest_lib import exceptions as lib_exc # noqa
|
||||||
|
import testtools # noqa
|
||||||
|
|
||||||
|
from tempest.api.share import base
|
||||||
|
from tempest import clients_share as clients
|
||||||
|
from tempest import config_share as config
|
||||||
|
from tempest import test
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class SharesActionsNegativeTest(base.BaseSharesTest):
|
||||||
|
@classmethod
|
||||||
|
def resource_setup(cls):
|
||||||
|
super(SharesActionsNegativeTest, cls).resource_setup()
|
||||||
|
cls.share = cls.create_share(
|
||||||
|
size=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
@test.attr(type=["negative", ])
|
||||||
|
@testtools.skipUnless(
|
||||||
|
CONF.share.run_extend_tests,
|
||||||
|
"Share extend tests are disabled.")
|
||||||
|
def test_share_extend_over_quota(self):
|
||||||
|
tenant_quotas = self.shares_client.show_quotas(
|
||||||
|
self.shares_client.tenant_id)
|
||||||
|
new_size = int(tenant_quotas["gigabytes"]) + 1
|
||||||
|
|
||||||
|
# extend share with over quota and check result
|
||||||
|
self.assertRaises(lib_exc.Forbidden,
|
||||||
|
self.shares_client.extend_share,
|
||||||
|
self.share['id'],
|
||||||
|
new_size)
|
||||||
|
|
||||||
|
@test.attr(type=["negative", ])
|
||||||
|
@testtools.skipUnless(
|
||||||
|
CONF.share.run_extend_tests,
|
||||||
|
"Share extend tests are disabled.")
|
||||||
|
def test_share_extend_with_less_size(self):
|
||||||
|
new_size = int(self.share['size']) - 1
|
||||||
|
|
||||||
|
# extend share with invalid size and check result
|
||||||
|
self.assertRaises(lib_exc.BadRequest,
|
||||||
|
self.shares_client.extend_share,
|
||||||
|
self.share['id'],
|
||||||
|
new_size)
|
||||||
|
|
||||||
|
@test.attr(type=["negative", ])
|
||||||
|
@testtools.skipUnless(
|
||||||
|
CONF.share.run_extend_tests,
|
||||||
|
"Share extend tests are disabled.")
|
||||||
|
def test_share_extend_with_same_size(self):
|
||||||
|
new_size = int(self.share['size'])
|
||||||
|
|
||||||
|
# extend share with invalid size and check result
|
||||||
|
self.assertRaises(lib_exc.BadRequest,
|
||||||
|
self.shares_client.extend_share,
|
||||||
|
self.share['id'],
|
||||||
|
new_size)
|
||||||
|
|
||||||
|
@test.attr(type=["negative", ])
|
||||||
|
@testtools.skipUnless(
|
||||||
|
CONF.share.run_extend_tests,
|
||||||
|
"Share extend tests are disabled.")
|
||||||
|
def test_share_extend_with_invalid_share_state(self):
|
||||||
|
share = self.create_share(size=1, cleanup_in_class=False)
|
||||||
|
new_size = int(share['size']) + 1
|
||||||
|
|
||||||
|
# set "error" state
|
||||||
|
admin_client = clients.AdminManager().shares_client
|
||||||
|
admin_client.reset_state(share['id'])
|
||||||
|
|
||||||
|
# run extend operation on same share and check result
|
||||||
|
self.assertRaises(lib_exc.BadRequest,
|
||||||
|
self.shares_client.extend_share,
|
||||||
|
share['id'],
|
||||||
|
new_size)
|
@ -123,6 +123,11 @@ ShareGroup = [
|
|||||||
cfg.StrOpt("image_password",
|
cfg.StrOpt("image_password",
|
||||||
default="ubuntu",
|
default="ubuntu",
|
||||||
help="Image password."),
|
help="Image password."),
|
||||||
|
cfg.BoolOpt("run_extend_tests",
|
||||||
|
default=True,
|
||||||
|
help="Defines whether to run share extend tests or not."
|
||||||
|
"Disable this feature if used driver doesn't "
|
||||||
|
"support it."),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,6 +157,17 @@ class SharesClient(rest_client.RestClient):
|
|||||||
self.expected_success(202, resp.status)
|
self.expected_success(202, resp.status)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
def extend_share(self, share_id, new_size):
|
||||||
|
post_body = {
|
||||||
|
"os-extend": {
|
||||||
|
"new_size": new_size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body = json.dumps(post_body)
|
||||||
|
resp, body = self.post("shares/%s/action" % share_id, body)
|
||||||
|
self.expected_success(202, resp.status)
|
||||||
|
return body
|
||||||
|
|
||||||
def create_snapshot(self, share_id, name=None, description=None,
|
def create_snapshot(self, share_id, name=None, description=None,
|
||||||
force=False):
|
force=False):
|
||||||
if name is None:
|
if name is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user