cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gauravaradhye <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8308:Adding automation testcas...
Date Mon, 15 Jun 2015 06:03:33 GMT
Github user gauravaradhye commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/384#discussion_r32393368
  
    --- Diff: test/integration/testpaths/testpath_delta_snapshots.py ---
    @@ -0,0 +1,516 @@
    +# 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 Delta Snapshots Test Path
    +"""
    +
    +from nose.plugins.attrib import attr
    +from marvin.cloudstackTestCase import cloudstackTestCase
    +from marvin.lib.utils import (cleanup_resources,
    +                              validateList,
    +                              is_snapshot_on_nfs)
    +from marvin.lib.base import (Account,
    +                             ServiceOffering,
    +                             Template,
    +                             VirtualMachine,
    +                             Volume,
    +                             Configurations,
    +                             Snapshot
    +                             )
    +from marvin.lib.common import (get_domain,
    +                               get_zone,
    +                               get_template,
    +                               list_volumes,
    +                               createChecksum,
    +                               compareChecksum
    +                               )
    +from marvin.sshClient import SshClient
    +from marvin.codes import (FAIL)
    +import time
    +
    +
    +def checkIntegrityOfSnapshot(
    +        self, snapshotsToRestore, checksumToCompare, disk_type="root"):
    +
    +    if disk_type == "root":
    +        # Create template from snapshot
    +        template_from_snapshot = Template.create_from_snapshot(
    +            self.apiclient,
    +            snapshotsToRestore,
    +            self.testdata["template_2"])
    +
    +        self.assertNotEqual(
    +            template_from_snapshot,
    +            None,
    +            "Check if result exists in list item call"
    +        )
    +
    +        time.sleep(60)
    +
    +        # Deploy VM
    +        vm_from_temp = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=template_from_snapshot.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +            mode=self.zone.networktype
    +        )
    +
    +        self.assertNotEqual(
    +            vm_from_temp,
    +            None,
    +            "Check if result exists in list item call"
    +        )
    +        time.sleep(60)
    +        # Verify contents of ROOT disk match with snapshot
    +
    +        compareChecksum(
    +            self.apiclient,
    +            service=self.testdata,
    +            original_checksum=checksumToCompare,
    +            disk_type="rootdiskdevice",
    +            virt_machine=vm_from_temp
    +        )
    +
    +        vm_from_temp.delete(self.apiclient)
    +        template_from_snapshot.delete(self.apiclient)
    +    else:
    +        volumeFormSnap = Volume.create_from_snapshot(
    +            self.apiclient,
    +            snapshotsToRestore.id,
    +            self.testdata["volume"],
    +            account=self.account.name,
    +            domainid=self.account.domainid,
    +            zoneid=self.zone.id
    +        )
    +
    +        temp_vm = VirtualMachine.create(
    +            self.apiclient,
    +            self.testdata["small"],
    +            templateid=self.template.id,
    +            accountid=self.account.name,
    +            domainid=self.account.domainid,
    +            serviceofferingid=self.service_offering.id,
    +            zoneid=self.zone.id,
    +            mode=self.zone.networktype
    +        )
    +        temp_vm.attach_volume(
    +            self.apiclient,
    +            volumeFormSnap
    +        )
    +
    +        temp_vm.reboot(self.apiclient)
    +
    +        compareChecksum(
    +            self.apiclient,
    +            self.testdata,
    +            checksumToCompare,
    +            "datadiskdevice_1",
    +            temp_vm
    +        )
    +
    +        temp_vm.delete(self.apiclient)
    +        volumeFormSnap.delete(self.apiclient)
    +
    +    return
    +
    +
    +class TestDeltaSnapshots(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +        testClient = super(TestDeltaSnapshots, 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.snapshots_created = []
    +        cls._cleanup = []
    +
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +
    +        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)
    +
    +            if cls.testdata["configurableData"][
    +                    "restartManagementServerThroughTestCase"]:
    +                # Set snapshot delta max value
    +                Configurations.update(cls.apiclient,
    +                                      name="snapshot.delta.max",
    +                                      value="3"
    +                                      )
    +
    +                # Restart management server
    +                cls.RestartServer()
    +                time.sleep(120)
    +
    +            configs = Configurations.list(
    +                cls.apiclient,
    +                name="snapshot.delta.max")
    +            cls.delta_max = configs[0].value
    +
    +            cls.vm = VirtualMachine.create(
    +                cls.apiclient,
    +                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:
    +            for snapshot in self.snapshots_created:
    +                snapshot.delete(self.apiclient)
    +            cleanup_resources(self.apiclient, self.cleanup)
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +
    +    @classmethod
    +    def RestartServer(cls):
    +        """Restart management server"""
    +
    +        sshClient = SshClient(
    +            cls.mgtSvrDetails["mgtSvrIp"],
    +            22,
    +            cls.mgtSvrDetails["user"],
    +            cls.mgtSvrDetails["passwd"]
    +        )
    +        command = "service cloudstack-management restart"
    +        sshClient.execute(command)
    +
    +        return
    +
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_02_delta_snapshots(self):
    +        """ Delta Snapshots
    +            1. Create file on ROOT disk of deployed VM.
    +            2. Create Snapshot of ROOT disk.
    +            3. Verify secondary storage count.
    +            4. Check integrity of Full Snapshot.
    +            5. Delete delta snaphshot and check integrity of\
    +               remaining snapshots.
    +            6. Delete full snapshot and verify it is deleted from\
    +               secondary storage.
    +        """
    +
    --- End diff --
    
    Skip snapshot tests for HyperV and LXC.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message