Skip to content

Commit

Permalink
CBQE-2304 add upload test
Browse files Browse the repository at this point in the history
Change-Id: I5cdef1f936a0c1652bca50cd9630f71f6dbb48a2
Reviewed-on: http://review.couchbase.org/39508
Reviewed-by: Thuan Nguyen <soccon@gmail.com>
Tested-by: Thuan Nguyen <soccon@gmail.com>
  • Loading branch information
saigon committed Jul 18, 2014
1 parent 2b3236d commit 29aef80
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 33 deletions.
48 changes: 24 additions & 24 deletions conf/py-cwc.conf
@@ -1,27 +1,27 @@
### test without upload ###
cwc.cwctests.CWCTests:
test_start_collect_log_without_upload
test_start_collect_log_without_upload,sasl_buckets=1
test_start_collect_log_without_upload,sasl_buckets=1,standard_buckets=1
test_start_collect_log_without_upload,nodes_init=4
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1
test_start_collect_log_without_upload,nodes_init=4,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,replicas=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,replicas=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2
test_start_collect_log_without_upload,nodes_init=4,replicas=2,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,replicas=2,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,replicas=2,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,replicas=2,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2,collect_nodes=2
test_start_collect_log_without_upload,nodes_init=4,replicas=3
test_start_collect_log_without_upload,nodes_init=4,replicas=3,collect_nodes=3
test_start_collect_log_without_upload,nodes_init=4,replicas=3,collect_nodes=2
test_start_collect_log
test_start_collect_log,sasl_buckets=1
test_start_collect_log,sasl_buckets=1,standard_buckets=1
test_start_collect_log,nodes_init=4
test_start_collect_log,nodes_init=4,sasl_buckets=1
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1
test_start_collect_log,nodes_init=4,collect_nodes=3
test_start_collect_log,nodes_init=4,sasl_buckets=1,collect_nodes=3
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1,collect_nodes=3
test_start_collect_log,nodes_init=4,collect_nodes=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,collect_nodes=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1,collect_nodes=2
test_start_collect_log,nodes_init=4,replicas=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,replicas=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2
test_start_collect_log,nodes_init=4,replicas=2,collect_nodes=3
test_start_collect_log,nodes_init=4,sasl_buckets=1,replicas=2,collect_nodes=3
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2,collect_nodes=3
test_start_collect_log,nodes_init=4,replicas=2,collect_nodes=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,replicas=2,collect_nodes=2
test_start_collect_log,nodes_init=4,sasl_buckets=1,standard_buckets=1,replicas=2,collect_nodes=2
test_start_collect_log,nodes_init=4,replicas=3
test_start_collect_log,nodes_init=4,replicas=3,collect_nodes=3
test_start_collect_log,nodes_init=4,replicas=3,collect_nodes=2

2 changes: 1 addition & 1 deletion lib/membase/api/rest_client.py
Expand Up @@ -2219,7 +2219,7 @@ def is_zone_exist(self, zone_name):
return False

def start_cluster_logs_collection(self, nodes="*", upload=False,\
uploadHost=None, customer=None, ticket=None):
uploadHost=None, customer="", ticket=""):
if not upload:
params = urllib.urlencode({"nodes":nodes})
else:
Expand Down
4 changes: 2 additions & 2 deletions pytests/cwc/cwc_base.py
Expand Up @@ -17,8 +17,8 @@ def setUp(self):
self.doc_ops = self.input.param("doc_ops", None)
self.upload = self.input.param("upload", False)
self.uploadHost = self.input.param("uploadHost", None)
self.customer_id = self.input.param("customer_id", None)
self.ticket = self.input.param("ticket", None)
self.customer = self.input.param("customer", "")
self.ticket = self.input.param("ticket", "")
self.collect_nodes = self.input.param("collect_nodes", "*")
self.shutdown_nodes = self.input.param("shutdown_nodes", None)
if self.doc_ops is not None:
Expand Down
43 changes: 37 additions & 6 deletions pytests/cwc/cwctests.py
@@ -1,5 +1,6 @@
import time
import unittest
import urllib
import random
import testconstants
from TestInput import TestInputSingleton
Expand All @@ -24,21 +25,29 @@ def setUp(self):
def tearDown(self):
super(CWCTests, self).tearDown()

def test_start_collect_log_without_upload(self):
def test_start_collect_log(self):
rest = RestConnection(self.master)
shell = RemoteMachineShellConnection(self.master)
if "*" not in str(self.collect_nodes) and self.nodes_init > 1:
self.collect_nodes = self._generate_random_collecting_node(rest)
status, content = rest.start_cluster_logs_collection(nodes=self.collect_nodes)
status, content = rest.start_cluster_logs_collection(nodes=self.collect_nodes, \
upload=self.upload, uploadHost=self.uploadHost, \
customer=self.customer, ticket=self.ticket)
if status:
collected = self._monitor_collecting_log(rest, timeout=1200)
collected, uploaded = self._monitor_collecting_log(rest, timeout=1200)
if collected:
self._verify_log_file(rest)
shell.disconnect()
if self.upload and uploaded:
self._verify_log_uploaded(rest)
shell.disconnect()
else:
self.fail("ERROR: {0}".format(content))

def _monitor_collecting_log(self, rest, timeout):
start_time = time.time()
end_time = start_time + timeout
collected = False
uploaded = False
progress = 0
progress, stt, perNode = rest.get_cluster_logs_collection_status()
while (progress != 100 or stt == "running") and time.time() <= end_time :
Expand All @@ -48,14 +57,18 @@ def _monitor_collecting_log(self, rest, timeout):
for node in perNode:
self.log.info("Node: {0} **** Collect status: {1}" \
.format(node, perNode[node]["status"]))
if "collected" in perNode[node]["status"]:
collected = True
elif "uploaded" in perNode[node]["status"]:
uploaded = True
self.sleep(10)
if time.time() > end_time:
self.log.error("log could not collect after {0} seconds ".format(timeout))
return False
return collected, uploaded
else:
duration = time.time() - start_time
self.log.info("log collection took {0} seconds ".format(duration))
return True
return collected, uploaded


def _verify_log_file(self, rest):
Expand Down Expand Up @@ -89,6 +102,24 @@ def _verify_log_file(self, rest):
self.fail("Cluster-wide collectinfo failed to collect log at {0}" \
.format(node_failed_to_collect))

def _verify_log_uploaded(self, rest):
node_failed_to_uploaded = []
progress, status, perNode = rest.get_cluster_logs_collection_status()
for node in perNode:
self.log.info("Verify log of node {0} uploaded to host: {1}" \
.format(node, self.uploadHost))
uploaded = urllib.urlopen(perNode[node]["url"]).getcode()
if uploaded == 200 and self.uploadHost in perNode[node]["url"]:
self.log.info("Log of node {0} was uploaded to {1}" \
.format(node, perNode[node]["url"]))
else:
node_failed_to_uploaded.append(node)
if not node_failed_to_uploaded:
return True
else:
self.fail("Cluster-wide collectinfo failed to upload log at node(s) {0}" \
.format(node_failed_to_uploaded))

def _generate_random_collecting_node(self, rest):
random_nodes = []
nodes = rest.get_nodes()
Expand Down

0 comments on commit 29aef80

Please sign in to comment.