Ignore log messages in unittests
[ganeti-local] / qa / qa_rapi.py
index f2f68f9..da7f90d 100644 (file)
@@ -41,46 +41,35 @@ NoProxyOpener = urllib2.build_opener(urllib2.ProxyHandler({}))
 
 
 INSTANCE_FIELDS = ("name", "os", "pnode", "snodes",
-                   "admin_state", "admin_ram",
-                   "disk_template", "ip", "mac", "bridge",
-                   "sda_size", "sdb_size", "vcpus",
-                   "oper_state", "status", "tags")
+                   "admin_state",
+                   "disk_template", "disk.sizes",
+                   "nic.ips", "nic.macs", "nic.modes", "nic.links",
+                   "beparams", "hvparams",
+                   "oper_state", "oper_ram", "status", "tags")
 
 NODE_FIELDS = ("name", "dtotal", "dfree",
                "mtotal", "mnode", "mfree",
                "pinst_cnt", "sinst_cnt", "tags")
 
-LIST_FIELDS = ("name", "uri")
+LIST_FIELDS = ("id", "uri")
 
 
 def Enabled():
   """Return whether remote API tests should be run.
 
   """
-  return constants.RAPI_ENABLE and qa_config.TestEnabled('rapi')
-
-
-def PrintRemoteAPIWarning():
-  """Print warning if remote API is not enabled.
-
-  """
-  if constants.RAPI_ENABLE or not qa_config.TestEnabled('rapi'):
-    return
-  msg = ("Remote API is not enabled in this Ganeti build. Please run"
-         " `configure [...] --enable-rapi'.")
-  print
-  print qa_utils.FormatWarning(msg)
+  return qa_config.TestEnabled('rapi')
 
 
 def _DoTests(uris):
   master = qa_config.GetMasterNode()
   host = master["primary"]
-  port = qa_config.get("rapi-port", default=constants.RAPI_PORT)
+  port = qa_config.get("rapi-port", default=constants.DEFAULT_RAPI_PORT)
 
   for uri, verify in uris:
     assert uri.startswith("/")
 
-    url = "http://%s:%s%s" % (host, port, uri)
+    url = "https://%s:%s%s" % (host, port, uri)
 
     print "Testing %s ..." % url
 
@@ -119,8 +108,8 @@ def TestEmptyCluster():
 
   def _VerifyNodes(data):
     master_entry = {
-      "name": master_name,
-      "uri": "/nodes/%s" % master_name,
+      "id": master_name,
+      "uri": "/2/nodes/%s" % master_name,
       }
     AssertIn(master_entry, data)
 
@@ -131,13 +120,13 @@ def TestEmptyCluster():
 
   _DoTests([
     ("/", None),
-    ("/info", _VerifyInfo),
-    ("/tags", None),
-    ("/nodes", _VerifyNodes),
-    ("/nodes?bulk=1", _VerifyNodesBulk),
-    ("/instances", []),
-    ("/instances?bulk=1", []),
-    ("/os", None),
+    ("/2/info", _VerifyInfo),
+    ("/2/tags", None),
+    ("/2/nodes", _VerifyNodes),
+    ("/2/nodes?bulk=1", _VerifyNodesBulk),
+    ("/2/instances", []),
+    ("/2/instances?bulk=1", []),
+    ("/2/os", None),
     ])
 
 
@@ -159,9 +148,9 @@ def TestInstance(instance):
       _VerifyInstance(instance_data)
 
   _DoTests([
-    ("/instances/%s" % instance["name"], _VerifyInstance),
-    ("/instances", _VerifyInstancesList),
-    ("/instances?bulk=1", _VerifyInstancesBulk),
+    ("/2/instances/%s" % instance["name"], _VerifyInstance),
+    ("/2/instances", _VerifyInstancesList),
+    ("/2/instances?bulk=1", _VerifyInstancesBulk),
     ])
 
 
@@ -183,9 +172,9 @@ def TestNode(node):
       _VerifyNode(node_data)
 
   _DoTests([
-    ("/nodes/%s" % node["primary"], _VerifyNode),
-    ("/nodes", _VerifyNodesList),
-    ("/nodes?bulk=1", _VerifyNodesBulk),
+    ("/2/nodes/%s" % node["primary"], _VerifyNode),
+    ("/2/nodes", _VerifyNodesList),
+    ("/2/nodes?bulk=1", _VerifyNodesBulk),
     ])
 
 
@@ -194,11 +183,11 @@ def TestTags(kind, name, tags):
 
   """
   if kind == constants.TAG_CLUSTER:
-    uri = "/tags"
+    uri = "/2/tags"
   elif kind == constants.TAG_NODE:
-    uri = "/nodes/%s/tags" % name
+    uri = "/2/nodes/%s/tags" % name
   elif kind == constants.TAG_INSTANCE:
-    uri = "/instances/%s/tags" % name
+    uri = "/2/instances/%s/tags" % name
   else:
     raise errors.ProgrammerError("Unknown tag kind")