cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-8308) Add test cases for volume/VM snapshot test path
Date Wed, 15 Apr 2015 10:03:00 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-8308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14495976#comment-14495976
] 

ASF GitHub Bot commented on CLOUDSTACK-8308:
--------------------------------------------

Github user gauravaradhye commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/170#discussion_r28407300
  
    --- Diff: test/integration/testpaths/testpath_snapshot_limits.py ---
    @@ -0,0 +1,355 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you 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.
    +""" Test cases for VM/Volume snapshot Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources)
    +from marvin.lib.base import (Account,
    +                             ServiceOffering,
    +                             DiskOffering,
    +                             Volume,
    +                             Resources,
    +                             VirtualMachine,
    +                             Snapshot
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template
    +                               )
    +
    +
    +class TestStorageSnapshotsLimits(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestStorageSnapshotsLimits, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +
    +        # Get Zone, Domain and templates
    +        cls.domain = get_domain(cls.apiclient)
    +        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
    +
    +        cls.template = get_template(
    +            cls.apiclient,
    +            cls.zone.id,
    +            cls.testdata["ostype"])
    +
    +        cls._cleanup = []
    +
    +        try:
    +
    +            # Create an account
    +            cls.account = Account.create(
    +                cls.apiclient,
    +                cls.testdata["account"],
    +                domainid=cls.domain.id
    +            )
    +            cls._cleanup.append(cls.account)
    +
    +            # Create user api client of the account
    +            cls.userapiclient = testClient.getUserApiClient(
    +                UserName=cls.account.name,
    +                DomainName=cls.account.domain
    +            )
    +
    +            # Create Service offering
    +            cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offering"],
    +            )
    +            cls._cleanup.append(cls.service_offering)
    +
    +            cls.disk_offering = DiskOffering.create(
    +                cls.apiclient,
    +                cls.testdata["disk_offering"],
    +            )
    +
    +            cls._cleanup.append(cls.disk_offering)
    +
    +            cls.vm = VirtualMachine.create(
    +                cls.userapiclient,
    +                cls.testdata["small"],
    +                templateid=cls.template.id,
    +                accountid=cls.account.name,
    +                domainid=cls.account.domainid,
    +                serviceofferingid=cls.service_offering.id,
    +                zoneid=cls.zone.id,
    +                mode=cls.zone.networktype
    +            )
    +
    +        except Exception as e:
    +            cls.tearDownClass()
    +            raise e
    +        return
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            cleanup_resources(cls.apiclient, cls._cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +
    +    def setUp(self):
    +        self.apiclient = self.testClient.getApiClient()
    +        self.dbclient = self.testClient.getDbConnection()
    +        self.cleanup = []
    +
    +    def tearDown(self):
    +        try:
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @attr(tags=["basic", "advanced"])
    +    def test_01_storage_snapshots_limits(self):
    +        """ Storage and Snapshot Limit
    +            1.   Create Snapshot of ROOT disk.
    +            2.   Verify the Secondary Storage value
    +                 is increased by the size of snapshot.
    +            3.   Delete Snaphshot.
    +            4.   Verify the Secondary
    +                 Storage value is decreased by the size of snapshot.
    +            5.   Set the Snapshot limit of Account.
    +            6.   Create Snasphots till limit is reached.
    +            7.   Create Snapshot of ROOT Volume.
    +                 Creation should fail.
    +            8.   Delete few Snapshots.
    +            9.   Create Snapshot again.
    +                 Creation should succeed.
    +        """
    +
    +        # Get ROOT Volume
    +        root_volumes_list = Volume.list(
    +            self.userapiclient,
    +            virtualmachineid=self.vm.id,
    +            type='ROOT',
    +            listall=True
    +        )
    +
    +        self.assertEqual(
    +            isinstance(
    +                root_volumes_list,
    +                list),
    +            True,
    +            "Check listVolumes for ROOT Disk returns a valid list")
    +
    +        self.assertNotEqual(len(root_volumes_list),
    +                            0,
    +                            "Check listVolumes response for ROOT Disk")
    +
    +        root_volume = root_volumes_list[0]
    +
    +        data_volume_created = Volume.create(
    +            self.userapiclient,
    +            self.testdata["volume"],
    +            zoneid=self.zone.id,
    +            account=self.account.name,
    +            domainid=self.account.domainid,
    +            diskofferingid=self.disk_offering.id
    +        )
    +
    +        self.vm.attach_volume(
    +            self.userapiclient,
    +            data_volume_created
    +        )
    +
    +        data_volumes_list = Volume.list(
    +            self.userapiclient,
    +            listall=self.testdata["listall"],
    +            id=data_volume_created.id
    +        )
    +
    +        data_volume = data_volumes_list[0]
    +
    +        # Get Secondary Storage Value from Database
    +        qryresult_before_snapshot = self.dbclient.execute(
    +            " select id, account_name, secondaryStorageTotal\
    +                    from account_view where account_name = '%s';" %
    +            self.account.name)
    +
    +        self.assertNotEqual(
    +            len(qryresult_before_snapshot),
    +            0,
    +            "Check sql query to return SecondaryStorageTotal of account")
    +
    +        secStorageBeforeSnapshot = qryresult_before_snapshot[0][2]
    +
    +        # Step 1
    +        snapshot = Snapshot.create(
    +            self.userapiclient,
    +            root_volume.id)
    +
    +        snapshots_list = Snapshot.list(self.userapiclient,
    +                                       id=snapshot.id)
    +
    +        self.assertEqual(isinstance(snapshots_list, list),
    +                         True,
    +                         "Check listSnapshots returns a valid list")
    +
    +        self.assertNotEqual(len(snapshots_list),
    +                            0,
    +                            "Check listSnapshots response")
    +
    +        # Verify Snapshot state
    +        self.assertEqual(
    +            snapshots_list[0].state in [
    +                'BackedUp',
    +            ],
    +            True,
    +            "Snapshot state is not as expected. It is %s" %
    +            snapshots_list[0].state
    +        )
    +
    +        # Step 2
    +        qryresult_after_snapshot = self.dbclient.execute(
    +            " select id, account_name, secondaryStorageTotal\
    +                        from account_view where account_name = '%s';" %
    +            self.account.name)
    +
    +        self.assertNotEqual(
    +            len(qryresult_after_snapshot),
    +            0,
    +            "Check sql query to return SecondaryStorageTotal of account")
    +
    +        secStorageAfterSnapshotCreated = qryresult_after_snapshot[0][2]
    +
    +        snapshot_size = snapshots_list[0].physicalsize
    +        secStorageIncreased = secStorageBeforeSnapshot + \
    +            snapshot_size
    +
    +        self.assertEqual(
    +            secStorageIncreased,
    +            secStorageAfterSnapshotCreated,
    +            "Secondary storage Total after Snapshot\
    +                        should be incremented by size of snapshot.")
    +
    +        # Step 3
    +        snapshot.delete(self.apiclient)
    +
    +        snapshots_list = Snapshot.list(self.userapiclient,
    +                                       id=snapshot.id)
    +
    +        self.assertEqual(
    +            snapshots_list,
    +            None,
    +            "Snapshot not deleted."
    +        )
    +
    +        # Step 4
    +        qryresult_after_snapshot_deleted = self.dbclient.execute(
    +            " select id, account_name, secondaryStorageTotal\
    +                        from account_view where account_name = '%s';" %
    +            self.account.name)
    +
    +        self.assertNotEqual(
    +            len(qryresult_after_snapshot_deleted),
    +            0,
    +            "Check sql query to return SecondaryStorageTotal of account")
    +
    +        secStorageAfterSnapshotDeleted = qryresult_after_snapshot_deleted[0][2]
    +
    +        secStorageDecreased = secStorageAfterSnapshotCreated - \
    +            snapshot_size
    +
    +        self.assertEqual(
    +            secStorageDecreased,
    +            secStorageAfterSnapshotDeleted,
    +            "Secondary storage Total after Snapshot\
    +                        should be incremented by size of snapshot.")
    +
    +        # Step 5
    +        # Set Snapshot Limit for account
    +        Resources.updateLimit(self.apiclient, resourcetype=3,
    +                              max=1, account=self.account.name,
    +                              domainid=self.account.domainid)
    +
    +        # Step 6
    +        snapshot = Snapshot.create(
    +            self.userapiclient,
    +            root_volume.id)
    +
    +        snapshots_list = Snapshot.list(self.userapiclient,
    +                                       id=snapshot.id)
    +
    +        self.assertEqual(isinstance(snapshots_list, list),
    +                         True,
    +                         "Check listSnapshots returns a valid list")
    +
    +        self.assertNotEqual(len(snapshots_list),
    +                            0,
    +                            "Check listSnapshots response")
    +
    +        # Verify Snapshot state
    +        self.assertEqual(
    +            snapshots_list[0].state in [
    +                'BackedUp',
    +            ],
    +            True,
    +            "Snapshot state is not as expected. It is %s" %
    +            snapshots_list[0].state
    +        )
    +
    +        # Step 7
    +        with self.assertRaises(Exception):
    +            Snapshot.create(
    +                self.userapiclient,
    +                data_volume.id)
    +
    +        # Step 8
    +        snapshot.delete(self.userapiclient)
    +
    +        snapshots_list = Snapshot.list(self.userapiclient,
    +                                       id=snapshot.id)
    +
    +        self.assertEqual(
    +            snapshots_list,
    +            None,
    +            "Snapshot not deleted."
    +        )
    +
    +        # Step 9
    +        snapshot = Snapshot.create(
    +            self.userapiclient,
    +            root_volume.id)
    +
    +        snapshots_list = Snapshot.list(self.userapiclient,
    +                                       id=snapshot.id)
    +
    +        self.assertEqual(isinstance(snapshots_list, list),
    +                         True,
    --- End diff --
    
    use validateList method


> Add test cases for volume/VM snapshot test path
> -----------------------------------------------
>
>                 Key: CLOUDSTACK-8308
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8308
>             Project: CloudStack
>          Issue Type: Test
>      Security Level: Public(Anyone can view this level - this is the default.) 
>    Affects Versions: Future
>            Reporter: Priti Sarap
>              Labels: automation
>             Fix For: Future
>
>
> Add test cases for volume/VM snapshot test path



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message