cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
cm_vm_test.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 # -*- coding: utf-8 -*-
21 ##
22 # @package src.wi.tests.cm_vm_test
23 #
24 # @author Piotr W√≥jcik
25 # @author Krzysztof Danielowski
26 # @date 13.02.2013
27 #
28 
29 from wi.tests import WiTestCase
30 import unittest
31 import vm_test
32 
33 
34 class CMVMTests(WiTestCase, unittest.TestCase):
35  def _test_destroy_vm(self, name):
36  driver = self.driver
37  self.base_url = self.TEST_SERVER
38 
39  self.login_testuser(self.TEST_admin_cm)
40  self.login_cm_testuser()
41 
42  driver.get(self.base_url + "/admin_cm/vms/")
43 
44  self.wait_for_text("//table[@id='item-list']/tbody", [name])
45 
46  driver.find_element_by_id("auto-refresh").click()
47  self.row_click("Name", name, {"dict": {"State": "running"}, "path": "//table[@id='item-list']/tbody"})
48 
49  self.wait_for_text("//div[@id='vm_details']/div[5]/div/table/tbody/tr[7]/td/div/ul/li[2]/a", ["Destroy"])
50 
51  driver.find_element_by_xpath("//div[@id='vm_details']/div[5]/div/table/tbody/tr[7]/td/div/ul/li[2]/a").click()
52 
53  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to destroy virtual machine"])
54 
55  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
56 
57  self.wait_for_message(["successfully destroyed"])
58 
59  driver.find_element_by_link_text("Logout from CM").click()
60  driver.find_element_by_link_text("Logout").click()
61 
62  def _test_erase_vm(self, name):
63  driver = self.driver
64  self.base_url = self.TEST_SERVER
65 
66  self.login_testuser(self.TEST_admin_cm)
67  self.login_cm_testuser()
68 
69  driver.get(self.base_url + "/admin_cm/vms/")
70 
71  self.wait_for_text("//table[@id='item-list']/tbody", [name])
72 
73  driver.find_element_by_id("auto-refresh").click()
74  self.row_click("Name", name, {"dict": {"State": "running"}, "path": "//table[@id='item-list']/tbody"})
75 
76  self.wait_for_text("//div[@id='vm_details']/div[5]/div/table/tbody/tr[7]/td/div/ul/li[3]/a", ["Erase"])
77 
78  driver.find_element_by_xpath("//div[@id='vm_details']/div[5]/div/table/tbody/tr[7]/td/div/ul/li[3]/a").click()
79 
80  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to erase virtual machine"])
81 
82  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
83 
84  self.wait_for_message(["successfully erased"])
85 
86  driver.find_element_by_link_text("Logout from CM").click()
87  driver.find_element_by_link_text("Logout").click()
88 
89  def _test_erase_multiple_vm(self, list):
90  driver = self.driver
91  self.base_url = self.TEST_SERVER
92 
93  self.login_testuser(self.TEST_admin_cm)
94  self.login_cm_testuser()
95 
96  driver.get(self.base_url + "/admin_cm/vms/")
97 
98  driver.find_element_by_id("auto-refresh").click()
99 
100  for name in list:
101  self.wait_for_text("//table[@id='item-list']/tbody", [name])
102 
103  self.cell_click("Name", name, {"dict": {"State": "running"}, "path": "//table[@id='item-list']/tbody"}, "", "input")
104 
105  driver.find_element_by_xpath("//li[@id='group_action']/a").click()
106 
107  self.wait_for_text("//ul[@id='context-menu-list']/li", ["Erase"])
108 
109  driver.find_element_by_xpath("//ul[@id='context-menu-list']/li[2]").click()
110 
111  self.wait_for_text("//div[@id='dialog-div']/p", ["Do you want to erase"])
112 
113  driver.find_element_by_css_selector("button.ok-button.mid_button").click()
114 
115  self.wait_for_message(["successfully erased"])
116 
117  driver.find_element_by_link_text("Logout from CM").click()
118  driver.find_element_by_link_text("Logout").click()
119 
120  def test_1_destroy(self):
121  name = vm_test.VMTests._test_create_vm(self)
122  self._test_destroy_vm(name)
123 
124  def test_2_erase(self):
125  name = vm_test.VMTests._test_create_vm(self)
126  self._test_erase_vm(name)
127 
129  name = vm_test.VMTests._test_create_vm(self)
130  name2 = vm_test.VMTests._test_create_vm(self)
131  self._test_erase_multiple_vm([name2, name])
132