def test_extend_pool(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver

        strip_size = ["64 KB", "128 KB", "256 KB", "512 KB", "1 MB"]
        sector_size = ["512 Bytes", "1 KB", "2 KB", "4 KB"]

        Prefer_ctrl = [1, 2]
        #disklist = ["1", "4", "5", "6", "8", "9", "10", "11", "12"]
        #disklist = [1, 3, 4, 5, 6, 8, 9, 10, 11, 12]
        disklist = ["1", "5", "6", "9", "10"]
        diskrem = [4, 8, 11, 12]

        # block_size = ['512 Bytes', '1 KB', '2 KB', '4 KB', '8 KB', '16 KB', '32 KB', '64 KB', '128 KB']
        # volume_sector = ['512 Bytes', '1 KB', '2 KB', '4 KB']

        raid_level = ["RAID0", "RAID1", "RAID5", "RAID6"]

        tolog("Start to create pool!")
        sleep(5)
        driver.find_element_by_link_text("Pool").click()
        sleep(3)
        driver.find_element_by_xpath("//div[2]/button").click()
        sleep(1)

        #poolnum0=poolnum1=volnum0=volnum1=snapnum0=snapnum1=clonenum0=clonenum1=0
        validatelist = list()

        sleep(1)
        driver.find_element_by_name("name").clear()
        pool_name = random_key(10)
        driver.find_element_by_name("name").send_keys(pool_name)
        sleep(1)
        Select(driver.find_element_by_name("mediatype")).select_by_visible_text("Hard Disk Drive")
        raid = random.choice(raid_level)
        stripsize=random.choice(strip_size)
        sectorsize=random.choice(sector_size)
        if raid == "RAID0":
            disks = random.sample(disklist, 1)
        elif raid == "RAID1":
            disks = random.sample(disklist, 2)
        # elif raid == "RAID50":
        #     disks = random.sample(disklist, 6)
        # elif raid == "RAID60":
        #     disks = random.sample(disklist, 8)
        else:
            disks = random.sample(disklist, 4)

        # for pool extend
        # diskrem=list()
        # for disk in disklist:
        #     if disk in disks:
        #         pass
        #     else:
        #         diskrem.append(int(disk))
        #diskrem = disklist - disks



        disks.sort()
        verifydisk = list()
        for disk in disks:
            verifydisk.append(int(disk))
        # the verifydisk list will be verified in detail list by removing spaces
        verifydisk.sort()

        disks = verifydisk[::-1]
        # print disks
        # click disk in reverse order to avoid the unapplicable disk selection
        #

        for disk in disks:
            sleep(1)
            driver.find_element_by_xpath("//div[2]/div/div/ul/li[%s]" % (str(disk))).click()

        sleep(2)
        # verifydisk.sort()
        Select(driver.find_element_by_name("raidlevel")).select_by_visible_text(raid)
        sleep(1)
        # sectorsize=random.choice(sector_size)
        Select(driver.find_element_by_name("strip")).select_by_visible_text(stripsize)
        sleep(1)
        Select(driver.find_element_by_name("sector")).select_by_visible_text(sectorsize)
        # sleep(1)
        # ctrlid = random.choice(Prefer_ctrl)

        # driver.find_element_by_xpath("//label[%d]/span" % ctrlid).click()
        sleep(5)

        driver.find_element_by_xpath("//button[@type='submit']").click()
        for i in range(60):
            try:
                if re.search(r"^[\s\S]*Pool was added successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("Pool %s was added successfully." % pool_name);
                    break
            except:
                pass
            time.sleep(1)
        else:
            self.fail("time out")
        sleep(5)
        validatelist.append(VerifyWords(driver, (pool_name, raid)))
        sleep(2)
        driver.find_element_by_xpath("//pr-gear-button/div/a").click()
        sleep(2)

        driver.find_element_by_link_text("View Detail").click()
        sleep(5)
        verifydiskstr = str(verifydisk).replace("[", "").replace("]", "").replace(" ", "")
        validatelist.append(VerifyWords(driver, (pool_name, raid, stripsize, sectorsize, verifydiskstr)))

        tolog("Start to extend pool from gear button")
        sleep(4)
        validatelist.append(VerifyWords(driver, (pool_name, raid, stripsize, sectorsize, verifydiskstr)))

        driver.find_element_by_xpath("//li/ul/li/a/span/span").click()
        sleep(2)
        driver.find_element_by_xpath("//pr-gear-button/div/a").click()
        sleep(2)

        driver.find_element_by_link_text("Extend Pool").click()

        diskrem=random.sample(diskrem, len(disks))
        diskrem.sort()

        #disklistrem = list()

        disklistrem = diskrem[::-1]

        for disk in disklistrem:
            sleep(1)
            driver.find_element_by_xpath("//div[2]/div/div/ul/li[%s]" % (str(disk))).click()
        # # li3 is a location that not contain disk, clicking li3 leads the hover information upwards
        # # so the submit button can be clicked
        # driver.find_element_by_xpath("//div[2]/div/div/ul/li3").click()
        # sleep(2)
        driver.find_element_by_xpath("//button[@type='submit']").click()

        for i in range(60):
            try:
                if re.search(r"^[\s\S]*Pool was extended successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("Pool %s was extended successfully." % pool_name);
                    break
            except:
                pass
            time.sleep(1)
        else:
            self.fail("time out")

        sleep(5)
        validatelist.append(VerifyWords(driver, (pool_name, raid)))
        # sleep(2)
        # driver.find_element_by_xpath("//li/ul/li/a/span/span").click()
        sleep(5)
        driver.find_element_by_xpath("//pr-gear-button/div/a").click()
        sleep(2)

        driver.find_element_by_link_text("View Detail").click()
        sleep(3)
        verifydiskstr = verifydiskstr+","+str(diskrem).replace("[", "").replace("]", "").replace(" ", "")
        validatelist.append(VerifyWords(driver, (pool_name, raid, stripsize, sectorsize, verifydiskstr)))
        sleep(2)
        driver.find_element_by_xpath("//li/ul/li/a/span/span").click()
        sleep(2)
        driver.find_element_by_xpath("//pr-gear-button/div/a").click()
        sleep(2)

        driver.find_element_by_link_text("Delete").click()

        time.sleep(2)
        driver.find_element_by_name("name").clear()
        driver.find_element_by_name("name").send_keys("confirm")
        time.sleep(2)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        for i in range(60):
            try:
                if re.search(r"^[\s\S]*Pool was deleted successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("Pool %s was deleted successful!" % pool_name);
                    break
            except:
                pass
            time.sleep(1)
        else:
            self.fail("time out")
        for val in validatelist:
            if val:
                Failflag=True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #2
0
    def test_create_snapshot(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver

        sleep(shortterm)

        validatelist = list()
        try:
            tolog("Create snapshot from volume")
            driver.find_element_by_xpath(
                ".//*[@id='sidebar-menu']/ul/li[4]/a").click()
            sleep(shortterm)
            driver.find_element_by_link_text("Volume").click()

            driver.find_element_by_xpath(
                "//div/ul/li[2]/a/span/span").click()  # click v0
            sleep(shortterm)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[4]").click(
                )  # click "snapshot&clone" button
            sleep(shortterm)
            driver.find_element_by_xpath(
                "//pr-button-bar/div/div/div/button[1]").click(
                )  # click 'Create snapshot' button
            sleep(shortterm)
            driver.find_element_by_name("name").clear()
            snapshot_name = random_key(18)
            driver.find_element_by_name("name").send_keys(snapshot_name)
            sleep(shortterm)
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(60):
                try:
                    if re.search(
                            r"^[\s\S]*Snapshot was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Snapshot %s was added successfully. " %
                              snapshot_name)

                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(longterm)
            driver.find_element_by_link_text("Volume").click()
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)

            driver.find_element_by_link_text("View Detail").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

            sleep(shortterm)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(mediumterm)
            driver.find_element_by_css_selector("a > small.ng-binding").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

            tolog("Export and Un-export snapshot")
            sleep(longterm)
            driver.find_element_by_link_text("Volume").click()
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)
            driver.find_element_by_link_text("Snapshot & Clone").click()
            sleep(2)
            for i in range(2):
                status = False

                if re.search("Un-Exported",
                             driver.find_element_by_css_selector("BODY").text):
                    status = True

                sleep(shortterm)
                driver.find_element_by_xpath("//pr-gear-button/div/a").click()
                sleep(shortterm)
                if status:
                    driver.find_element_by_link_text("Export Snapshot").click()
                    for i in range(60):
                        try:
                            if re.search(
                                    r"^[\s\S]*Snapshot was exported successfully.[\s\S]*$",
                                    driver.find_element_by_css_selector(
                                        "BODY").text):
                                tolog("Snapshot was exported successfully.")
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

                else:
                    driver.find_element_by_link_text(
                        "Un-export Snapshot").click()
                    for i in range(60):
                        try:
                            if re.search(
                                    r"^[\s\S]*Snapshot was un-exported successfully.[\s\S]*$",
                                    driver.find_element_by_css_selector(
                                        "BODY").text):
                                tolog("Snapshot was un-exported successfully.")
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

            tolog("Modify snapshot")
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)
            driver.find_element_by_link_text("Modify Snapshot").click()
            sleep(shortterm)
            driver.find_element_by_name("name").clear()
            snapshot_name = random_key(20)
            driver.find_element_by_name("name").send_keys(snapshot_name)
            sleep(shortterm)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            sleep(mediumterm)
            validatelist.append(VerifyWords(driver, ({snapshot_name})))
            for i in range(60):
                try:
                    if re.search(
                            r"^[\s\S]*Snapshot was changed successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Snapshot was changed successfully..")
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(longterm)
            driver.find_element_by_link_text("Volume").click()
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)

            driver.find_element_by_link_text("View Detail").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

            sleep(shortterm)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(mediumterm)
            driver.find_element_by_css_selector("a > small.ng-binding").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

            tolog("Create snapshot from gear button")
            sleep(shortterm)
            driver.find_element_by_link_text("Volume").click()
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)
            driver.find_element_by_link_text("Snapshot & Clone").click()
            sleep(shortterm)

            driver.find_element_by_xpath("//button[@type='button']").click()
            sleep(shortterm)
            driver.find_element_by_name("name").clear()
            snapshot_name = random_key(18)
            driver.find_element_by_name("name").send_keys(snapshot_name)
            sleep(shortterm)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            for i in range(60):
                try:
                    if re.search(
                            r"^[\s\S]*Snapshot was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Snapshot %s was added successfully. " %
                              snapshot_name)

                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(longterm)
            driver.find_element_by_link_text("Volume").click()
            sleep(shortterm)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(shortterm)

            driver.find_element_by_link_text("View Detail").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

            sleep(shortterm)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(mediumterm)
            driver.find_element_by_css_selector("a > small.ng-binding").click()
            sleep(shortterm)
            validatelist.append(
                VerifyWords(driver, ({"Snapshot " + snapshot_name})))

        except:
            driver.get_screenshot_as_file("snapshot at " + re.sub(
                ':', '.',
                time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
                    time.time()))) + "create_delete_multi" + "." + "png")
            tolog("Error: please refer to the screen-shot in the folder")
            Failflag = True

        for val in validatelist:
            if val:
                Failflag = True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #3
0
    def test_create_pool(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver

        strip_size = ["64 KB", "128 KB", "256 KB", "512 KB", "1 MB"]
        sector_size = ["512 Bytes", "1 KB", "2 KB", "4 KB"]

        Prefer_ctrl = [1, 2]
        disklist = ["1", "3", "4", "5", "6", "8", "9", "10", "11", "12"]
        # disklist = [1, 3, 4, 5, 6, 8, 9, 10, 11, 12]

        volume_capacity = str(random.randint(16, 10000))
        block_size = ['512 Bytes', '1 KB', '2 KB', '4 KB', '8 KB', '16 KB', '32 KB', '64 KB', '128 KB']
        volume_sector = ['512 Bytes', '1 KB', '2 KB', '4 KB']

        raid_level = ["RAID0", "RAID1", "RAID5", "RAID6", "RAID10", "RAID50", "RAID60"]

        tolog("Start to create pool with different settings")
        driver.find_element_by_link_text("Pool").click()

        #driver.find_element_by_xpath("//div[2]/button").click()
        sleep(1)


        validatelist = list()
        # try:
        sleep(1)

        # raid = random.choice(raid_level)

        for raid in raid_level:


            for stripsize in strip_size:
                # stripsize=random.choice(strip_size)


                for sectorsize in sector_size:

                    #driver.find_element_by_link_text("Pool").click()

                    driver.find_element_by_xpath("//div[2]/button").click()
                    time.sleep(2)
                    driver.find_element_by_name("name").clear()
                    pool_name = random_key(10)
                    driver.find_element_by_name("name").send_keys(pool_name)
                    sleep(0.5)
                    Select(driver.find_element_by_name("mediatype")).select_by_visible_text("Hard Disk Drive")
                    sleep(0.5)
                    if raid=="RAID0":
                        disks = random.sample(disklist, 1)
                    if raid == "RAID1":
                        disks = random.sample(disklist, 2)
                    elif raid == "RAID50":
                        disks = random.sample(disklist, 6)
                    elif raid == "RAID60":
                        disks = random.sample(disklist, 8)
                    else:
                        disks = random.sample(disklist, 4)

                    disks.sort()
                    verifydisk=list()
                    for disk in disks:
                        verifydisk.append(int(disk))
                    # the verifydisk list will be verified in detail list by removing spaces
                    verifydisk.sort()

                    disks = verifydisk[::-1]
                    # print disks
                    # click disk in reverse order to avoid the unapplicable disk selection
                    #
                    for disk in disks:
                        sleep(1)
                        driver.find_element_by_xpath("//div[2]/div/div/ul/li[%s]" % (str(disk))).click()

                    sleep(0.5)
                    #verifydisk.sort()
                    Select(driver.find_element_by_name("raidlevel")).select_by_visible_text(raid)
                    sleep(0.5)
                    # sectorsize=random.choice(sector_size)
                    Select(driver.find_element_by_name("strip")).select_by_visible_text(stripsize)
                    Select(driver.find_element_by_name("sector")).select_by_visible_text(sectorsize)
                    # sleep(1)
                    # ctrlid = random.choice(Prefer_ctrl)

                    # driver.find_element_by_xpath("//label[%d]/span" % ctrlid).click()
                    sleep(5)

                    driver.find_element_by_xpath("//button[@type='submit']").click()
                    for i in range(60):
                        try:
                            if re.search(r"^[\s\S]*Pool was added successfully.[\s\S]*$",
                                         driver.find_element_by_css_selector("BODY").text):
                                tolog("Pool %s was added successfully." % pool_name);
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

                    time.sleep(3)
                    validatelist.append(VerifyWords(driver, (pool_name, raid)))

                    driver.find_element_by_xpath("//pr-gear-button/div/a").click()
                    time.sleep(2)
                    try:
                        driver.find_element_by_link_text("View Detail").click()
                        sleep(5)
                        verifydiskstr = str(verifydisk).replace("[", "").replace("]", "").replace(" ", "")
                        validatelist.append(VerifyWords(driver, (pool_name, raid, stripsize, sectorsize,verifydiskstr)))
                    except:
                        pass
                    #driver.find_element_by_link_text("Pool").click()
                    #time.sleep(1)
                    driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
                    time.sleep(1)
                    driver.find_element_by_xpath("//button[@type='button']").click()
                    time.sleep(2)
                    driver.find_element_by_name("name").clear()
                    driver.find_element_by_name("name").send_keys("confirm")
                    time.sleep(1)
                    driver.find_element_by_xpath("//button[@type='submit']").click()
                    # time.sleep(5)

                    for i in range(60):
                        try:
                            if re.search(r"^[\s\S]*Pool was deleted successfully.[\s\S]*$",
                                         driver.find_element_by_css_selector("BODY").text):
                                tolog("Pool %s was deleted successful!" % pool_name);
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")


                    time.sleep(2)



        # except:
        #     driver.get_screenshot_as_file("snapshot at " +
        #                                   re.sub(':', '.', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
        #                                       time.time()))) + "create_pool" + "." + "png")
        #     tolog("Error: please refer to the screen-shot in the folder")

        for val in validatelist:
            if val:
                Failflag = True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #4
0
    def test_create_volume(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver

        strip_size = ["64 KB", "128 KB", "256 KB", "512 KB", "1 MB"]
        sector_size = ["512 Bytes", "1 KB", "2 KB", "4 KB"]

        Prefer_ctrl = [1, 2]
        disklist = ["1", "3", "4", "5", "6", "8", "9", "10", "11", "12"]
        #disklist = [1, 3, 4, 5, 6, 8, 9, 10, 11, 12]

        volume_block_size = [
            '512 Bytes', '1 KB', '2 KB', '4 KB', '8 KB', '16 KB', '32 KB',
            '64 KB', '128 KB'
        ]
        volume_sector = ['512 Bytes', '1 KB', '2 KB', '4 KB']

        raid_level = [
            "RAID0", "RAID1", "RAID5", "RAID6", "RAID10", "RAID50", "RAID60"
        ]

        tolog("Start to create pool!")
        driver.find_element_by_link_text("Pool").click()

        driver.find_element_by_xpath("//div[2]/button").click()
        sleep(1)

        #poolnum0=poolnum1=volnum0=volnum1=snapnum0=snapnum1=clonenum0=clonenum1=0
        validatelist = list()

        sleep(1)
        driver.find_element_by_name("name").clear()
        pool_name = random_key(10)
        driver.find_element_by_name("name").send_keys(pool_name)
        Select(driver.find_element_by_name(
            "mediatype")).select_by_visible_text("Hard Disk Drive")
        raid = random.choice(raid_level)
        stripsize = random.choice(strip_size)
        sectorsize = random.choice(sector_size)

        if raid == "RAID0":
            disks = random.sample(disklist, 1)
        if raid == "RAID1":
            disks = random.sample(disklist, 2)
        elif raid == "RAID50":
            disks = random.sample(disklist, 6)
        elif raid == "RAID60":
            disks = random.sample(disklist, 8)
        else:
            disks = random.sample(disklist, 4)

        disks.sort()
        verifydisk = list()
        for disk in disks:
            verifydisk.append(int(disk))
        # the verifydisk list will be verified in detail list by removing spaces
        verifydisk.sort()

        disks = verifydisk[::-1]
        # print disks
        # click disk in reverse order to avoid the unapplicable disk selection
        #
        for disk in disks:
            sleep(1)
            driver.find_element_by_xpath("//div[2]/div/div/ul/li[%s]" %
                                         (str(disk))).click()

        sleep(1)
        # verifydisk.sort()
        Select(driver.find_element_by_name(
            "raidlevel")).select_by_visible_text(raid)
        sleep(1)
        # sectorsize=random.choice(sector_size)
        Select(driver.find_element_by_name("strip")).select_by_visible_text(
            stripsize)
        sleep(1)
        Select(driver.find_element_by_name("sector")).select_by_visible_text(
            sectorsize)
        # sleep(1)
        # ctrlid = random.choice(Prefer_ctrl)

        # driver.find_element_by_xpath("//label[%d]/span" % ctrlid).click()
        sleep(5)

        driver.find_element_by_xpath("//button[@type='submit']").click()
        for i in range(60):
            try:
                if re.search(r"^[\s\S]*Pool was added successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("Pool %s was added successfully." % pool_name)
                    break
            except:
                pass
            time.sleep(1)
        else:
            self.fail("time out")

        tolog("Start to create volume")
        sync_mode = ["Always", "Standard", "Disabled"]
        for sector in volume_sector:
            for block in volume_block_size:
                for sync in sync_mode:
                    tolog(
                        "Create volume with sector: %s, blocksize: %s, sync mode: %s"
                        % (sector, block, sync))
                    volume_capacity = str(random.randint(1, 10))
                    time.sleep(2)
                    driver.find_element_by_xpath(
                        ".//*[@id='sidebar-menu']/ul/li[4]/a").click()
                    sleep(2)
                    driver.find_element_by_link_text("Volume").click()
                    sleep(2)
                    driver.find_element_by_xpath("//div[2]/button").click()
                    sleep(2)
                    driver.find_element_by_name("volumename").clear()
                    volume_name = random_key(10)
                    sleep(2)
                    driver.find_element_by_name("volumename").send_keys(
                        volume_name)
                    sleep(2)

                    driver.find_element_by_xpath(
                        "//form/div[4]/div[1]/input").clear()
                    # Enable Thin Provision
                    time.sleep(2)
                    #driver.find_element_by_xpath("//input[@type='checkbox']").click()

                    driver.find_element_by_xpath("//form/div[4]/div[1]/input"
                                                 ).send_keys(volume_capacity)
                    sleep(2)
                    # driver.find_element_by_css_selector("div.row.m-t-20").click()
                    #volumesector = random.choice(volume_sector)
                    Select(driver.find_element_by_name(
                        "sectorsize")).select_by_visible_text(sector)
                    sleep(2)
                    # driver.find_element_by_css_selector("option[value=\"string:1KB\"]").click()
                    #blocksize = random.choice(block_size)
                    Select(driver.find_element_by_name(
                        "blocksize")).select_by_visible_text(block)
                    sleep(2)

                    Select(driver.find_element_by_name(
                        "syncmode")).select_by_visible_text(sync)

                    sleep(2)

                    driver.find_element_by_xpath(
                        "//button[@type='submit']").click()
                    for i in range(60):
                        try:
                            if re.search(
                                    r"^[\s\S]*Volume was added successfully.[\s\S]*$",
                                    driver.find_element_by_css_selector(
                                        "BODY").text):
                                tolog("Volume %s was added successfully." %
                                      volume_name)
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

                    validatelist.append(
                        VerifyWords(driver, (volume_name, pool_name, block)))
                    time.sleep(2)
                    driver.find_element_by_xpath(
                        "//pr-gear-button/div/a").click()
                    time.sleep(2)

                    driver.find_element_by_link_text("View Detail").click()
                    sleep(2)
                    validatelist.append(
                        VerifyWords(driver, (volume_name, "Exported",
                                             pool_name, block, sector)))

                    driver.find_element_by_xpath(
                        "//div/ul/li[2]/a/span/span").click()
                    time.sleep(3)
                    driver.find_element_by_css_selector(
                        "a > small.ng-binding").click()
                    time.sleep(2)
                    validatelist.append(
                        VerifyWords(driver,
                                    ("Enabled", "Exported", volume_name,
                                     pool_name, block, sector)))
                    sleep(2)
                    driver.find_element_by_xpath(
                        "//div[2]/div/ul/li[4]/a").click()
                    sleep(4)
                    driver.find_element_by_xpath(
                        "(//input[@type='checkbox'])[2]").click()
                    sleep(2)
                    driver.find_element_by_xpath(
                        "//button[@type='button']").click()
                    sleep(2)
                    driver.find_element_by_name("name").click()
                    sleep(2)
                    driver.find_element_by_name("name").clear()
                    driver.find_element_by_name("name").send_keys("confirm")
                    sleep(2)
                    driver.find_element_by_xpath(
                        "//button[@type='submit']").click()

                    for i in range(60):
                        try:
                            if re.search(
                                    r"^[\s\S]*Volume was deleted successfully.[\s\S]*$",
                                    driver.find_element_by_css_selector(
                                        "BODY").text):
                                tolog("volume %s was deleted successfully." %
                                      volume_name)

                                break
                        except:
                            Failflag = True
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

        for val in validatelist:
            if val:
                Failflag = True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #5
0
    def test_create_volume(self):
        Failflag = False

        self.driver = loginFirefox()
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver
        #volume_capacity = str(random.randint(1, 1000000))
        block_size = [
            '512 Bytes', '1 KB', '2 KB', '4 KB', '8 KB', '16 KB', '32 KB',
            '64 KB', '128 KB'
        ]
        volume_sector = ['512 Bytes', '1 KB', '2 KB', '4 KB']
        raid_level = ["RAID1", "RAID5", "RAID6"]
        tolog("Start to create volume.")
        validatelist = []
        block = random.choice(block_size)
        sector = random.choice(volume_sector)
        sync_mode = ["Always", "Standard", "Disabled"]
        sync = random.choice(sync_mode)
        volume_capacity = str(random.randint(1, 10000))
        time.sleep(2)
        driver.find_element_by_xpath(
            ".//*[@id='sidebar-menu']/ul/li[4]/a").click()
        sleep(2)
        driver.find_element_by_link_text("Volume").click()
        sleep(2)
        driver.find_element_by_xpath("//div[2]/button").click()
        sleep(2)
        driver.find_element_by_name("volumename").clear()
        volume_name = random_key(10)
        sleep(2)
        driver.find_element_by_name("volumename").send_keys(volume_name)
        sleep(2)

        driver.find_element_by_xpath("//form/div[4]/div[1]/input").clear()
        # Enable Thin Provision
        sleep(2)
        driver.find_element_by_xpath("//input[@type='checkbox']").click()
        sleep(2)
        driver.find_element_by_xpath("//form/div[4]/div[1]/input").send_keys(
            volume_capacity)
        sleep(2)
        # driver.find_element_by_css_selector("div.row.m-t-20").click()
        # volumesector = random.choice(volume_sector)
        Select(driver.find_element_by_name(
            "sectorsize")).select_by_visible_text(sector)
        sleep(2)
        # driver.find_element_by_css_selector("option[value=\"string:1KB\"]").click()
        # blocksize = random.choice(block_size)
        Select(driver.find_element_by_name(
            "blocksize")).select_by_visible_text(block)
        sleep(2)

        Select(driver.find_element_by_name("syncmode")).select_by_visible_text(
            sync)

        sleep(2)

        driver.find_element_by_xpath("//button[@type='submit']").click()
        for i in range(60):
            try:
                if re.search(r"^[\s\S]*Volume was added successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("Volume %s was added successfully." % volume_name)
                    break
            except:
                pass
            time.sleep(1)
        else:
            self.fail("time out")

        # validatelist.append(VerifyWords(driver, (volume_name,block)))
        # time.sleep(2)
        # driver.find_element_by_xpath("//pr-gear-button/div/a").click()
        # time.sleep(2)
        #
        # driver.find_element_by_link_text("View Detail").click()
        # sleep(2)
        # validatelist.append(VerifyWords(driver, (volume_name, "Exported",block, sector)))
        #
        # driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
        # time.sleep(3)
        # driver.find_element_by_css_selector("a > small.ng-binding").click()
        # time.sleep(2)
        # validatelist.append(VerifyWords(driver, ("Enabled", "Exported", volume_name,block, sector)))

        for val in validatelist:
            if val:
                Failflag = True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #6
0
    def test_create_delete_multi(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver

        strip_size = ["64 KB", "128 KB", "256 KB", "512 KB", "1 MB"]
        sector_size = ["512 Bytes", "1 KB", "2 KB", "4 KB"]

        Prefer_ctrl = [1, 2]
        disklist = ["1", "3", "4", "5", "6", "8", "9", "10", "11", "12"]

        volume_capacity = str(random.randint(16, 10000))
        block_size = [
            '512 Bytes', '1 KB', '2 KB', '4 KB', '8 KB', '16 KB', '32 KB',
            '64 KB', '128 KB'
        ]
        volume_sector = ['512 Bytes', '1 KB', '2 KB', '4 KB']

        raid_level = ["RAID1", "RAID5", "RAID6"]

        tolog(
            "Start to creating new pool/volume/snapshot/clone,then delete clone/snapshot/volume/pool!"
        )

        sleep(1)

        poolnum0 = poolnum1 = volnum0 = volnum1 = snapnum0 = snapnum1 = clonenum0 = clonenum1 = 0
        validatelist = list()

        try:

            sleep(1)

            driver.find_element_by_link_text("Pool").click()
            sleep(1)
            driver.find_element_by_xpath("//div[2]/button").click()
            driver.find_element_by_name("name").clear()
            pool_name = random_key(10)
            driver.find_element_by_name("name").send_keys(pool_name)

            raid = random.choice(raid_level)
            if raid == "RAID1":
                disks = random.sample(disklist, 2)
            else:
                disks = random.sample(disklist, 4)
            sleep(1)
            for disk in disks:
                sleep(1)
                driver.find_element_by_xpath("//div[2]/div/div/ul/li[%s]" %
                                             (disk)).click()

            sleep(0.5)
            Select(driver.find_element_by_name(
                "raidlevel")).select_by_visible_text(raid)
            sleep(0.5)
            stripsize = random.choice(strip_size)
            Select(driver.find_element_by_name(
                "strip")).select_by_visible_text(stripsize)
            sleep(1)
            sectorsize = random.choice(sector_size)
            Select(driver.find_element_by_name(
                "sector")).select_by_visible_text(sectorsize)
            sleep(1)
            ctrlid = random.choice(Prefer_ctrl)
            driver.find_element_by_xpath("//label[%d]/span" % ctrlid).click()
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Pool was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Pool %s was added successfully." % pool_name)
                        poolnum0 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")
            sleep(1)
            validatelist.append(VerifyWords(driver, (pool_name, raid)))
            sleep(2)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(2)
            driver.find_element_by_link_text("View Detail").click()
            sleep(1)
            validatelist.append(
                VerifyWords(driver, (pool_name, raid, stripsize, sectorsize)))

            driver.find_element_by_xpath(
                ".//*[@id='sidebar-menu']/ul/li[4]/a").click()
            sleep(1)
            driver.find_element_by_link_text("Volume").click()
            sleep(1)
            driver.find_element_by_xpath("//div[2]/button").click()
            sleep(1)

            # Select(driver.find_element_by_name("pool")).select_by_value(pool_name)
            # sleep(1)
            driver.find_element_by_name("volumename").clear()
            volume_name = random_key(15)
            driver.find_element_by_name("volumename").send_keys(volume_name)
            sleep(1)
            # Enable Thin Provision
            driver.find_element_by_xpath("//form/div[4]/div[1]/input").clear()

            driver.find_element_by_xpath(
                "//form/div[4]/div[1]/input").send_keys(volume_capacity)
            sleep(1)
            # driver.find_element_by_css_selector("div.row.m-t-20").click()
            volumesector = random.choice(volume_sector)
            Select(driver.find_element_by_name(
                "sectorsize")).select_by_visible_text(volumesector)
            sleep(1)
            # driver.find_element_by_css_selector("option[value=\"string:1KB\"]").click()
            blocksize = random.choice(block_size)
            Select(driver.find_element_by_name(
                "blocksize")).select_by_visible_text(blocksize)
            sleep(1)
            sync_mode = ["Always", "Standard", "Disabled"]
            syncmode = random.choice(sync_mode)
            Select(driver.find_element_by_name(
                "syncmode")).select_by_visible_text(syncmode)
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Volume was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Volume %s was added successfully." %
                              volume_name)
                        volnum0 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")
            sleep(1)
            validatelist.append(VerifyWords(driver, (volume_name, blocksize)))

            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(1)
            driver.find_element_by_link_text("View Detail").click()
            sleep(1)
            validatelist.append(
                VerifyWords(driver, (volume_name, blocksize, volumesector)))

            driver.find_element_by_xpath(
                "//div/ul/li[2]/a/span/span").click()  # click v0
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[4]").click(
                )  # click "snapshot&clone" button
            sleep(1)
            driver.find_element_by_xpath(
                "//pr-button-bar/div/div/div/button[1]").click(
                )  # click 'Create snapshot' button
            sleep(1)
            driver.find_element_by_name("name").clear()
            snapshot_name = random_key(18)
            driver.find_element_by_name("name").send_keys(snapshot_name)
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Snapshot was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Snapshot %s was added successfully. " %
                              snapshot_name)
                        snapnum0 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")
            a = list()
            a.append(snapshot_name)
            sleep(1)
            validatelist.append(VerifyWords(driver, a))
            sleep(1)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(2)
            driver.find_element_by_link_text("View Detail").click()
            sleep(2)
            validatelist.append(
                VerifyWords(driver, (snapshot_name, pool_name, volume_name)))

            driver.find_element_by_xpath(
                "//div[2]/div/ul/li[4]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[4]").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//input[@type='checkbox'])[2]").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[2]").click()
            sleep(1)
            driver.find_element_by_name("name").clear()
            clone_name = random_key(10)
            driver.find_element_by_name("name").send_keys(clone_name)
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Clone was added successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Clone %s was added successfully. " %
                              snapshot_name)
                        clonenum0 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")
            sleep(1)
            driver.find_element_by_xpath("//td[2]/a/i").click()
            sleep(2)
            driver.find_element_by_xpath(
                "//tr[3]/td[6]/pr-gear-button/div/a/b").click()
            sleep(1)
            driver.find_element_by_xpath(
                "//tr[3]/td[6]/pr-gear-button/div/ul/li/a").click()

            # driver.find_element_by_xpath("//tr[3]/td[6]/pr-gear-button/div/a").click()
            # driver.find_element_by_xpath("//tr[3]/td[6]/pr-gear-button/div/ul/li/a").click()
            sleep(1)
            validatelist.append(
                VerifyWords(driver,
                            (snapshot_name, clone_name, pool_name, "volume")))

            sleep(1)
            driver.find_element_by_xpath(
                "//div[2]/div/ul/li[4]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[4]").click()
            sleep(1)
            driver.find_element_by_xpath("//td[2]/a/i").click()
            sleep(1)
            driver.find_element_by_xpath(
                "//tr[3]/td[6]/pr-gear-button/div/a").click()
            sleep(1)
            driver.find_element_by_xpath(
                "//tr[3]/td[6]/pr-gear-button/div/ul/li[3]/a").click()
            sleep(1)
            driver.find_element_by_name("name").clear()
            driver.find_element_by_name("name").send_keys("confirm")
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Clone was deleted successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Clone %s was deleted successfully." %
                              clone_name)
                        clonenum1 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(1)
            driver.find_element_by_xpath(
                "//div[2]/div/ul/li[4]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[4]").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//input[@type='checkbox'])[2]").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//button[@type='button'])[3]").click()
            sleep(1)
            driver.find_element_by_name("name").clear()
            driver.find_element_by_name("name").send_keys("confirm")
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Snapshot was deleted successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Snapshot %s was deleted successfully." %
                              snapshot_name)
                        snapnum1 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(1)
            driver.find_element_by_xpath("//div[2]/div/ul/li[4]/a").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//input[@type='checkbox'])[2]").click()
            sleep(1)
            driver.find_element_by_xpath("//button[@type='button']").click()
            sleep(1)
            driver.find_element_by_name("name").click()
            sleep(1)
            driver.find_element_by_name("name").clear()
            driver.find_element_by_name("name").send_keys("confirm")
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(10):
                try:
                    if re.search(
                            r"^[\s\S]*Volume was deleted successfully.[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("volume %s was deleted successfully." %
                              volume_name)
                        volnum1 += 1
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            sleep(1)
            driver.find_element_by_xpath(
                "//div[2]/div/ul/li[3]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath(
                "(//input[@type='checkbox'])[2]").click()
            sleep(1)
            driver.find_element_by_xpath("//button[@type='button']").click()
            sleep(1)
            driver.find_element_by_name("name").clear()
            driver.find_element_by_name("name").send_keys("confirm")
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()

            for i in range(100):
                try:
                    if re.search(
                            r"^[\s\S]*Pool was deleted successfully[\s\S]*$",
                            driver.find_element_by_css_selector("BODY").text):
                        tolog("Pool %s was deleted successfully." % pool_name)
                        poolnum1 += 1
                        break
                except:
                    pass
                time.sleep(0.1)
            else:
                self.fail("time out")

        except:
            Failflag = True
            driver.get_screenshot_as_file("snapshot at " + re.sub(
                ':', '.',
                time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
                    time.time()))) + "create_delete_multi" + "." + "png")
            tolog("Error: please refer to the screen-shot in the folder")

        if poolnum0 == poolnum1:
            tolog("Pool created %d, pool deleted %d, this case pass" %
                  (poolnum0, poolnum1))

        else:
            tolog("Pool created %d, pool deleted %d, this case fail" %
                  (poolnum0, poolnum1))
            Failflag = True

        for val in validatelist:
            if val:
                Failflag = True
                break
        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #7
0
    def test_ops(self):
        Failflag = False

        validatelist=list()
        driver = self.driver

        sleep(1)

        driver.get(self.base_url + "/index.html")
        sleep(1)

        #print driver.find_element_by_id("overridelink")

        sleep(1)
        driver.find_element_by_name("username").clear()
        driver.find_element_by_name("username").send_keys("administrator")
        driver.find_element_by_name("password").clear()
        driver.find_element_by_name("password").send_keys("password")

        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()

        sleep(1)
        tolog("Verify creating a new user.")
        driver.find_element_by_css_selector("li[name=\"user\"] > a > span.ng-binding.ng-scope").click()

        driver.find_element_by_xpath("(//button[@type='button'])[4]").click()
        sleep(1)
        idname=random_key(10)
        fullname=random_key(15)
        driver.find_element_by_name("id").clear()
        driver.find_element_by_name("id").send_keys(idname)
        driver.find_element_by_name("fulllname").clear()
        driver.find_element_by_name("fulllname").send_keys(fullname)

        pwd=random_key(8)
        driver.find_element_by_name("password").clear()
        driver.find_element_by_name("password").send_keys(pwd)
        driver.find_element_by_name("retypepassword").clear()
        driver.find_element_by_name("retypepassword").send_keys(pwd)
        sleep(1)
        email=address_generator()

        driver.find_element_by_name("email").clear()
        driver.find_element_by_name("email").send_keys(email)


        driver.find_element_by_name("privilege").click()
        sleep(1)
        privilege = ["Super", "Power", "Maintenance", "View"]
        priv="View"

        Select(driver.find_element_by_name("privilege")).select_by_visible_text(priv)
        #driver.find_element_by_css_selector("option[value=\"string:" + priv + "\"]").click()
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()

        for i in range(100):
            try:
                if re.search(r"^[\s\S]*New User was created successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User %s was added successfully." % idname);

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")
        sleep(1)
        validatelist.append(VerifyWords(driver,(idname,fullname,priv,email)))

        tolog("Verify modifying a user's settings.")
        # modify user settings
        sleep(1)
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("(//button[@type='button'])[2]").click()
        sleep(1)
        updatedfullname = "updated_" + fullname
        driver.find_element_by_name("displayname").clear()
        sleep(1)
        driver.find_element_by_name("displayname").send_keys(updatedfullname)
        sleep(1)
        updatedemail="updated_"+email
        driver.find_element_by_name("email").clear()
        sleep(1)
        driver.find_element_by_name("email").send_keys(updatedemail)
        sleep(1)
        privilege.remove(priv)

        updatedpriv=random.choice(privilege)
        # print ("the updatedpriv is %s" % updatedpriv)
        sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        # driver.find_element_by_css_selector("option[value=\"string:"+updatedpriv+"\"]").click()
        # sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        Select(driver.find_element_by_name("privilege")).select_by_visible_text(updatedpriv)
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User Settings were saved successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User settings %s %s %s were saved successfully." % (updatedfullname,updatedemail,updatedpriv));

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")
        time.sleep(2)
        validatelist.append(VerifyWords(driver, (updatedfullname, updatedemail, updatedpriv)))

        # change password
        tolog("Verify changing a new user's password.")
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("//button[@type='button']").click()
        sleep(1)
        driver.find_element_by_name("newpwd").clear()
        driver.find_element_by_name("newpwd").send_keys("password")
        driver.find_element_by_name("newpwd").clear()
        sleep(1)
        driver.find_element_by_name("newpwd").send_keys("1")
        driver.find_element_by_name("retypepwd").clear()
        driver.find_element_by_name("retypepwd").send_keys("1")
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User Password was changed successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User Password was changed successfully." );

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")

        tolog("Verify deleting the created user.")
        driver.find_element_by_xpath("(//input[@type='checkbox'])[3]").click()
        sleep(1)
        driver.find_element_by_xpath("(//button[@type='button'])[3]").click()
        sleep(1)
        driver.find_element_by_name("name").clear()
        driver.find_element_by_name("name").send_keys("confirm")
        sleep(1)
        driver.find_element_by_xpath("//button[@type='submit']").click()
        sleep(1)
        for i in range(100):
            try:
                if re.search(r"^[\s\S]*User was deleted successfully.[\s\S]*$",
                             driver.find_element_by_css_selector("BODY").text):
                    tolog("User %s was deleted successfully."%idname);

                    break
            except:
                pass
            sleep(0.1)
        else:
            Failflag = True
            self.fail("time out")

        for val in validatelist:
            if val:
                Failflag = True
                break

        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)
Beispiel #8
0
    def test_create_clone(self):
        Failflag = False
        self.driver = loginFirefox()
        # self.driver.implicitly_wait(30)
        self.verificationErrors = []
        self.accept_next_alert = True
        driver = self.driver
        validatelist = []
        try:
            tolog("Start to create clone from snapshot list")

            driver.find_element_by_xpath("//div[2]/div/ul/li[4]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath("(//button[@type='button'])[4]").click()
            sleep(1)
            driver.find_element_by_xpath("(//input[@type='checkbox'])[2]").click()
            sleep(1)
            driver.find_element_by_xpath("(//button[@type='button'])[2]").click()
            sleep(1)
            sleep(1)
            driver.find_element_by_name("name").clear()
            clone_name = random_key(10)
            driver.find_element_by_name("name").send_keys(clone_name)
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()
            for i in range(60):
                try:
                    if re.search(r"^[\s\S]*Clone was added successfully.[\s\S]*$",
                                 driver.find_element_by_css_selector("BODY").text):
                        tolog("Clone %s was added successfully. " %clone_name);
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")

            driver.find_element_by_xpath("//td[2]/a/i").click()
            # click plus sign to get the clone name
            sleep(1)
            tolog("Verify the clone name in clone list")
            validatelist.append(VerifyWords(driver, ({clone_name})))
            sleep(1)

            # click volume to show latest clone for the volume
            tolog("Verify the latest clone name in volume page")
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            driver.find_element_by_xpath("//a/small").click()
            sleep(1)
            validatelist.append(VerifyWords(driver, ({clone_name})))

            # to create clone from gear button
            driver.find_element_by_xpath("//button[4]").click()
            sleep(1)
            tolog("Start to create clone from gear button")
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(1)
            driver.find_element_by_link_text("Create Clone").click()
            sleep(1)
            clone_name = random_key(15)
            driver.find_element_by_name("name").send_keys(clone_name)
            sleep(1)
            driver.find_element_by_xpath("//button[@type='submit']").click()

            driver.find_element_by_xpath("//td[2]/a/i").click()
            # click plus sign to get the clone name
            sleep(1)
            tolog("Verify the clone name in clone list")
            validatelist.append(VerifyWords(driver, ({clone_name})))
            sleep(1)

            # click volume to show latest clone for the volume
            tolog("Verify the latest clone name in volume page")
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath("//a/small").click()
            sleep(1)
            validatelist.append(VerifyWords(driver, ({clone_name})))

            tolog("Modify clone name")
            driver.find_element_by_xpath("//div[2]/div/ul/li[3]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div[2]/div/ul/li[4]/a/span").click()
            sleep(1)
            driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
            sleep(1)
            driver.find_element_by_xpath("//button[4]").click()
            sleep(1)
            driver.find_element_by_xpath("//td[2]/a/i").click()
            sleep(1)
            driver.find_element_by_xpath("//tr[3]/td[7]/pr-gear-button/div/a").click()
            sleep(1)
            driver.find_element_by_link_text("Modify Clone").click()
            driver.find_element_by_name("name").clear()
            modifiedname=random_key(10)
            driver.find_element_by_name("name").send_keys(modifiedname)
            sleep(1)
            driver.find_element_by_xpath("//div[3]/div/div/div/div[2]/button").click()
            sleep(1)
            driver.find_element_by_xpath("//td[2]/a/i").click()
            sleep(1)
            validatelist.append(VerifyWords(driver, ({modifiedname})))

            tolog("Export and Un-export clone")
            sleep(1)
            driver.find_element_by_link_text("Volume").click()
            sleep(1)
            driver.find_element_by_xpath("//pr-gear-button/div/a").click()
            sleep(1)
            driver.find_element_by_link_text("Snapshot & Clone").click()
            sleep(2)



            for i in range(3):
                sleep(1)
                driver.find_element_by_xpath("//td[2]/a/i").click()
                if driver.find_element_by_xpath("//tr[3]/td[3]").text == "Exported":

                    # driver.find_element_by_xpath("//div[2]/div/ul/li[3]/a/span").click()
                    # sleep(1)
                    # driver.find_element_by_xpath("//div[2]/div/ul/li[4]/a/span").click()
                    # sleep(1)
                    # driver.find_element_by_xpath("//div/ul/li[2]/a/span/span").click()
                    # sleep(1)
                    # driver.find_element_by_xpath("//button[4]").click()
                    # sleep(1)
                    # driver.find_element_by_xpath("//td[2]/a/i").click()
                    sleep(1)
                    driver.find_element_by_xpath("//tr[3]/td[7]/pr-gear-button/div/a").click()
                    sleep(1)
                    # driver.find_element_by_link_text("Unexport Clone").click()

                    driver.find_element_by_link_text("Un-export Clone").click()
                    for i in range(60):
                        try:
                            if re.search(r"^[\s\S]*Clone was un-exported successfully.[\s\S]*$",
                                         driver.find_element_by_css_selector("BODY").text):
                                tolog("Clone was un-exported successfully.");
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

                    if driver.find_element_by_xpath("//tr[3]/td[3]").text == "Un-Exported":
                        tolog("Un-exported successfully.")
                else:

                    sleep(1)
                    driver.find_element_by_xpath("//tr[3]/td[7]/pr-gear-button/div/a").click()
                    sleep(1)
                    # driver.find_element_by_link_text("Unexport Clone").click()

                    driver.find_element_by_link_text("Export Clone").click()
                    sleep(1)
                    for i in range(60):
                        try:
                            if re.search(r"^[\s\S]*Clone was exported successfully.[\s\S]*$",
                                         driver.find_element_by_css_selector("BODY").text):
                                tolog("Clone was exported successfully.");
                                break
                        except:
                            pass
                        time.sleep(1)
                    else:
                        self.fail("time out")

                    if driver.find_element_by_xpath("//tr[3]/td[3]").text == "Exported":
                        tolog("Exported successfully.")


        except:
            driver.get_screenshot_as_file("snapshot at " +
                                          re.sub(':', '.', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(
                                              time.time()))) + "create_delete_multi" + "." + "png")
            tolog("Error: please refer to the screen-shot in the folder")
            validatelist.append("True")
        for val in validatelist:
            if val:
                Failflag = True
                break

        if Failflag:
            tolog(Fail)
        else:
            tolog(Pass)