Commit 3f1b8ec1 authored by Łukasz Nowak's avatar Łukasz Nowak

Follow changes and simplify.

The KVM ordering interface has extremely simplified - customer is just one
click away from instance, so modify test to follow it.

Simplify test:

 * drop all server side scripts and rewrite AJAX calls to use already
   implemented SoftwareInstance_getStatus
 * where required implement client (browser) side analysis of data instead of
   relying on server side implementation (eg. fetching path of Software
   Instance)
 * avoid big pauses; pause just once (as client side logic to know when
   Software Instance is indexed would be cumbersome and complicated and anyway
   10s to index object is really long and shall be treat as failure)
 * flatten macros into main test for readability and beacuse they become
   oneliners
parent 755e626c
......@@ -56,12 +56,12 @@
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//img[@alt="My Services"]</td>\n
<td>link=Order a KVM now</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>//img[@alt="My Services"]</td>\n
<td>link=Order a KVM now</td>\n
<td></td>\n
</tr>\n
<tr>\n
......@@ -71,257 +71,97 @@
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>link=New service</td>\n
<td>//div[text()="Your instance is under creation. Please wait few minutes for partitions to appear."]</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>link=New service</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//td[contains(.,"KVM")]/input</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeAttribute</td>\n
<td>//td[contains(.,"KVM")]/input@value</td>\n
<td>value</td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=listbox_cb_${value}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_service_title</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=dialog_submit_button</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>click</td>\n
<td>id=listbox_cb_${value}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>store</td>\n
<td>javascript{"kvm_test_" + new Date().getTime();}</td>\n
<td>kvm</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_service_title</td>\n
<td>${kvm}</td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest3.png</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>id=dialog_submit_button</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//td[contains(.,"KVM")]/input</td>\n
<td>storeLocation</td>\n
<td>hosting_subscription_url</td>\n
<td></td>\n
</tr>\n
<!--\n
Unfortunately there is currently now way to do good client-server waiting for reindexation\n
of Software Instance, so just wait 10s.\n
\n
It shall be maximum of reindexation.\n
\n
-->\n
<tr>\n
<td>storeAttribute</td>\n
<td>//td[contains(.,"KVM")]/input@value</td>\n
<td>value</td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=listbox_cb_${value}</td>\n
<td>pause</td>\n
<td>10000</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=dialog_submit_button</td>\n
<td>open</td>\n
<td>${hosting_subscription_url}</td>\n
<td></td>\n
</tr>\n
<!-- XXX : vifib UI should automatically propose the latest version of KVM.-->\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//tr[contains(.,"001")][last()]/td[contains(.,"KVM")]/input</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeAttribute</td>\n
<td>//tr[contains(.,"001")][last()]/td[contains(.,"KVM")]/input@value</td>\n
<td>value</td>\n
</tr>\n
<tr>\n
<td>click</td>\n
<td>id=listbox_cb_${value}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest4.png</td>\n
<td>link=Vifib KVM*</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>id=dialog_submit_button</td>\n
<td>link=Vifib KVM*</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_last_name</td>\n
<td>storeLocation</td>\n
<td>software_instance_url</td>\n
<td></td>\n
</tr>\n
<!-- Allows to fetch clean instance status -->\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_first_name</td>\n
<td></td>\n
<td>storeEval</td>\n
<td>window.location.pathname</td>\n
<td>software_instance_path</td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_default_email_text</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_default_address_city</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_default_address_zip_code</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=field_your_default_address_street_address</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=dialog_submit_button</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_last_name</td>\n
<td>Last Name</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_first_name</td>\n
<td>First Name</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_default_email_text</td>\n
<td>email@domain.com</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_default_address_city</td>\n
<td>City</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_default_address_zip_code</td>\n
<td>12345</td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>name=field_your_default_address_street_address</td>\n
<td>Address</td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest5.png</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>id=dialog_submit_button</td>\n
<td>echo</td>\n
<td>${software_instance_path}</td>\n
<td></td>\n
</tr>\n
\n
<!-- Hackish, but there is no other way to fetch software instance status -->\n
<!-- XXX: It is hammering server, needs to make it a bit nicer -->\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest6.png</td>\n
<td></td>\n
<td>waitForCondition</td>\n
<td>new\n
Ajax.Request(\'${software_instance_path}/SoftwareInstance_getStatus\',\n
{asynchronous: false}).transport.responseText === "Started"; var i;\n
for (i = 0; i < 10000000; i++) { };</td>\n
<td>600000</td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//img[@alt="My Services"]</td>\n
<td></td>\n
</tr>\n
<!-- Here we wait 15 minutes too see if vifib has calculated everything and\n
instance is "instantiation in progress" or better. -->\n
<tr>\n
<td>pause</td>\n
<td>900000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>//img[@alt="My Services"]</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest7.png</td>\n
<td>open</td>\n
<td>${software_instance_url}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>link=${kvm}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>link=${kvm}</td>\n
<td>css=span:contains("Started")</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>link=${kvm}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>link=${kvm}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest8.png</td>\n
<td>css=td:contains("url")</td>\n
<td></td>\n
</tr>\n
<span metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/check_for_started_instance" />\n
<tr>\n
<td>pause</td>\n
<td>90000</td>\n
<td>assertElementPresent</td>\n
<td>css=td:contains("password")</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeText</td>\n
<td>//div[@class=&quot;inline&quot;]</td>\n
<td>xml</td>\n
</tr>\n
<tr>\n
<td>store</td>\n
<td>javascript{storedVars[\'xml\'].split(\'&lt;parameter id=&quot;url&quot;&gt;\')[1].split(\'&lt;/parameter&gt;\')[0];}</td>\n
<td>css=td:contains(\'url\') + td</td>\n
<td>ip</td>\n
</tr>\n
<tr>\n
<td>store</td>\n
<td>javascript{storedVars[\'xml\'].split(\'&lt;parameter id=&quot;password&quot;&gt;\')[1].split(\'&lt;/parameter&gt;\')[0];}</td>\n
<td>storeText</td>\n
<td>css=td:contains(\'password\') + td</td>\n
<td>password</td>\n
</tr>\n
<tr>\n
......@@ -377,7 +217,7 @@
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}</td>\n
<td>${software_instance_url}</td>\n
<td></td>\n
</tr>\n
<span metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/destroy_instance" />\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
#Couldn\'t make query work so feel free to modify this script\n
#from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ERP5Type.DateUtils import createDateTimeFromMillis \n
\n
instance_list = [\'empty\']\n
time = DateTime().millis() - 1800000\n
#query = Query(**{\'delivery.start_date\':createDateTimeFromMillis(time), \'range\':\'ngt\'})\n
\n
for document in context.portal_catalog.searchResults(portal_type="Software Instance", client="First Name Last Name"):\n
instance = document.getObject()\n
instanceCreationDate = instance.getCreationDate()\n
if time >= instanceCreationDate.millis():\n
if instance.SoftwareInstance_getStatus() not in ("Destroyed", "Destruction in progress", "Instanciation in progress"):\n
try:\n
instance.requestDestroyComputerPartition()\n
except:\n
instance_list.append(["Couldn\'t destroy instance %s with status %s" % (instance.getReference(), instance.SoftwareInstance_getStatus())])\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_deleteTestDocument</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Check if the instance has the right status\n
"""\n
request = context.REQUEST\n
instance_reference = request.get("instance_reference")\n
instance = context.portal_catalog.searchResults(portal_type="Software Instance", reference=instance_reference)[0].getObject()\n
\n
return instance.SoftwareInstance_getStatus()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getInstanceStatus</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
We wait until all activities are finished\n
"""\n
if len(context.portal_activities.getMessageList()) > 0:\n
return \'False.\'\n
else:\n
return \'True.\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_hasFinishedProcessingActivity</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -56,59 +56,6 @@
</tr>\n
</tal:block>\n
\n
<tal:block metal:define-macro="finished_processing_activities">\n
<!-- We wait for zope to finish his activities processing -->\n
<tr>\n
<td>storeAttribute</td>\n
<td>//head/base@href</td>\n
<td>address</td>\n
</tr>\n
<tr>\n
<td>waitForCondition</td>\n
<td>new Ajax.Request(\'ERP5Site_hasFinishedProcessingActivity\',\n
{asynchronous: false}).transport.responseText === "True."; var i;\n
for (i = 0; i < 10000000; i++){};</td>\n
<td>120000</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}</td>\n
<td></td>\n
</tr>\n
</tal:block>\n
\n
<tal:block metal:define-macro="check_for_started_instance">\n
<!-- Wait until the instance is Started -->\n
<tr>\n
<td>storeAttribute</td>\n
<td>//head/base@href</td>\n
<td>address</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}/getReference</td>\n
<td></td>\n
</tr>\n
<tr> \n
<td>storeText</td>\n
<td>//body/pre</td>\n
<td>instance_reference</td>\n
</tr>\n
<tr>\n
<td>waitForCondition</td>\n
<td>new\n
Ajax.Request(\'ERP5Site_getInstanceStatus?instance_reference=${instance_reference}\',\n
{asynchronous: false}).transport.responseText === "Started"; var i;\n
for (i = 0; i < 10000000; i++){};</td>\n
<td>600000</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}</td>\n
<td></td>\n
</tr>\n
</tal:block>\n
\n
<tal:block metal:define-macro="destroy_instance">\n
<!-- Order the destruction of the instance and check for it -->\n
<tr>\n
......@@ -121,26 +68,11 @@
<td>name=SoftwareInstance_requestDestroy:method</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeAttribute</td>\n
<td>//head/base@href</td>\n
<td>address</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}/getReference</td>\n
<td></td>\n
</tr>\n
<tr> \n
<td>storeText</td>\n
<td>//body/pre</td>\n
<td>instance_reference</td>\n
</tr>\n
<tr>\n
<td>waitForCondition</td>\n
<!-- XXX-Cedric : should be "Destroyed". -->\n
<td>new\n
Ajax.Request(\'ERP5Site_getInstanceStatus?instance_reference=${instance_reference}\',\n
Ajax.Request(\'${software_instance_path}/SoftwareInstance_getStatus\',\n
{asynchronous: false}).transport.responseText === "Destruction in progress"; var\n
i; for (i = 0; i < 10000000; i++){};</td>\n
<td>600000</td>\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment