예제 #1
0
        self.vm_params["Image"] = self.params.get('name', '*/Image/*')
        self.vm_params["Location"] = self.params.get('location', '*/Image/*')
        self.vm_params["VMName"] = self.params.get('vm_name', '*/wala_conf/*')

        if self.azure_mode == "asm":
            azure_cli_common.set_config_mode("asm")
            self.vm_test01 = azure_asm_vm.VMASM(self.vm_params["VMName"],
                                                self.vm_params["VMSize"],
                                                self.vm_params)
        elif self.azure_mode == "arm":
            azure_cli_common.set_config_mode("asm")
            self.vm_test01 = azure_arm_vm.VMARM(self.vm_params["VMName"],
                                                self.vm_params["VMSize"],
                                                self.vm_params)

        self.log.debug("Create the vm %s", self.vm_params["VMName"])
        self.vm_test01.vm_create()
        self.vm_test01.start()

    def test_disk_attach_new(self):
        """
        Attach a new disk to the VM

        :return:
        """
        self.log.debug("Attach a new disk to the vm %s", self.vm_params["VMName"])
        self.vm_test01.disk_attach_new()

if __name__ == "__main__":
    main()
    def test(self):
        """
        Creates namespace on the device.
        """
        cmd = "echo -n %s > /sys/bus/pci/drivers/%s/unbind" \
            % (self.slot, self.driver)
        process.run(cmd, shell=True, sudo=True)
        time.sleep(5)
        cmd = 'ls /sys/bus/pci/drivers/%s' % self.driver
        process.run(cmd, shell=True)
        if os.path.exists("/sys/bus/pci/drivers/%s/%s" %
                          (self.driver, self.slot)):
            self.return_code = 1
        cmd = "echo -n %s > /sys/bus/pci/drivers/%s/bind" \
            % (self.slot, self.driver)
        process.run(cmd, shell=True, sudo=True)
        time.sleep(5)
        cmd = 'ls /sys/bus/pci/drivers/%s' % self.driver
        process.run(cmd, shell=True)
        if not os.path.exists("/sys/bus/pci/drivers/%s/%s" %
                              (self.driver, self.slot)):
            self.return_code = 2
        if self.return_code == 1:
            self.fail('%s not unbound' % self.slot)
        if self.return_code == 2:
            self.fail('%s not bound back' % self.slot)


if __name__ == "__main__":
    main()
예제 #3
0
#!/usr/bin/python

import avocado


class FailOnException(avocado.Test):

    """
    Test illustrating the behavior of the fail_on decorator.
    """

    # @avocado.fail_on(ValueError) also possible
    @avocado.fail_on
    def test(self):
        """
        This should end with FAIL.

        Avocado tests should end with ERROR when a generic exception such as
        ValueError is raised. The avocado.fail_on_error decorator allows you
        to override this behavior, and turn your generic exceptions into
        errors.
        """
        raise ValueError('This raises a ValueError and should end as a FAIL')

if __name__ == "__main__":
    avocado.main()
예제 #4
0
        except ValueError as e:
            if str(e) != "'unsupported-partition-table' is not a supported partition table!":
                self.fail("parsing did not return the error we expected!")
        except avocado.core.exceptions.TestFail:
            raise
        except Exception as e:
            self.fail("parsing caused an unknown error: %s" % str(type(e)))

class PartitionMissingLabel(avocado.Test):
    def test(self):
        try:
            build = BuildCmd()
            build.loads("""
                image:
                    filename: simple-test.img
                    partitions:
                          where: /
            """)
            build.parse()
            self.fail("parsing should have failed (missing partition label)!")
        except ValueError as e:
            if str(e) != "one of the partitions does not have a 'label' defined!":
                self.fail("parsing did not return the error we expected!")
        except avocado.core.exceptions.TestFail:
            raise
        except Exception as e:
            self.fail("parsing caused an unknown error: %s" % str(type(e)))

if __name__ == "__main__":
    avocado.main()