Skip to content

Commit

Permalink
CBQE-3394 add test with node only single service or 2 services
Browse files Browse the repository at this point in the history
Change-Id: I637ddc34d19eddce11ecf26c07a9e7847aee6971
Reviewed-on: http://review.couchbase.org/73108
Tested-by: Thuan Nguyen <soccon@gmail.com>
Reviewed-by: Thuan Nguyen <soccon@gmail.com>
  • Loading branch information
saigon committed Feb 7, 2017
1 parent 2edb378 commit 7cc46e4
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2 deletions.
34 changes: 34 additions & 0 deletions conf/py-cwc.conf
Expand Up @@ -28,6 +28,40 @@ cwc.cwctests.CWCTests:
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
# test add services nodes in with or without data service
test_start_collect_log,nodes_init=2,add_services=n1ql
test_start_collect_log,nodes_init=2,add_services=index
test_start_collect_log,nodes_init=2,add_services=fts
test_start_collect_log,nodes_init=2,add_services=fts:n1ql
test_start_collect_log,nodes_init=2,add_services=index:n1ql
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts:kv
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index:kv-fts
test_start_collect_log,nodes_init=2,add_services=n1ql,cancel_collect=true
test_start_collect_log,nodes_init=2,add_services=index,cancel_collect=true
test_start_collect_log,nodes_init=2,add_services=fts,cancel_collect=true
test_start_collect_log,nodes_init=2,add_services=fts:n1ql,cancel_collect=true
test_start_collect_log,nodes_init=2,add_services=index:n1ql,cancel_collect=true
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts,cancel_collect=true
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts:kv,cancel_collect=true
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index:kv-fts,cancel_collect=true
test_start_collect_log,nodes_init=2,add_services=n1ql,collect_nodes=2
test_start_collect_log,nodes_init=2,add_services=index,collect_nodes=2
test_start_collect_log,nodes_init=2,add_services=fts,collect_nodes=1
test_start_collect_log,nodes_init=2,add_services=fts:n1ql,collect_nodes=2
test_start_collect_log,nodes_init=2,add_services=index:n1ql,collect_nodes=3
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts,collect_nodes=2
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts:kv,collect_nodes=3
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index:kv-fts,collect_nodes=2
test_start_collect_log,nodes_init=3,add_services=n1ql,replicas=2
test_start_collect_log,nodes_init=3,add_services=index,replicas=2
test_start_collect_log,nodes_init=3,add_services=fts,replicas=2
test_start_collect_log,nodes_init=3,add_services=fts:n1ql,replicas=2
test_start_collect_log,nodes_init=3,add_services=index:n1ql,replicas=2
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index:kv-fts
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql-index-fts:kv
test_start_collect_log,nodes_init=1,sasl_buckets=1,add_services=n1ql:kv-index:kv-fts


### test CLI without upload. Test with upload put will be put in jenkins job ###
cwc.cwctests.CWCTests:
Expand Down
6 changes: 6 additions & 0 deletions pytests/cwc/cwc_base.py
Expand Up @@ -32,6 +32,12 @@ def setUp(self):
self.cli_cancel_collect = self.input.param("cli_cancel_collect", False)
self.cli_upload = self.input.param("cli_upload", False)
self.shutdown_nodes = self.input.param("shutdown_nodes", None)
self.add_services = self.input.param("add_services", None)
if self.add_services is not None:
if "-" in self.add_services:
self.add_services = self.add_services.split("-")
else:
self.add_services = [self.add_services]
if self.doc_ops is not None:
self.doc_ops = self.doc_ops.split(";")
self.defaul_map_func = "function (doc) {\n emit(doc._id, doc);\n}"
Expand Down
53 changes: 51 additions & 2 deletions pytests/cwc/cwctests.py
@@ -1,13 +1,14 @@
import time
import unittest
import urllib
import random
import random, copy
import testconstants
from TestInput import TestInputSingleton

from cwc.cwc_base import CWCBaseTest
from membase.api.rest_client import RestConnection
from remote.remote_util import RemoteMachineShellConnection
from testconstants import COUCHBASE_FROM_WATSON



Expand All @@ -28,6 +29,26 @@ def tearDown(self):
def test_start_collect_log(self):
rest = RestConnection(self.master)
shell = RemoteMachineShellConnection(self.master)
""" add service nodes to cluster. Test will add with or without data service in """
if self.add_services:
self.add_services = [x.replace(":", ",") or x for x in self.add_services]
if len(self.servers) > 1:
nodes = rest.get_nodes()
cwc_servers = copy.deepcopy(self.servers)
if len(self.add_services) == 1:
self._add_service_node(cwc_servers, len(self.add_services),
services=self.add_services)
elif len(self.add_services) > 1 and \
(len(nodes) + len(self.add_services)) <= len(cwc_servers):
for service in self.add_services:
nodes = rest.get_nodes()
self._add_service_node(cwc_servers, len(self.add_services),
services=[service])
elif (len(nodes) + len(self.add_services)) > len(cwc_servers):
self.fail("Not enough servers to add services nodes")
else:
self.log.error("Need more than 2 servers to run this test")

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, \
Expand All @@ -49,6 +70,33 @@ def test_start_collect_log(self):
else:
self.fail("ERROR: {0}".format(content))

"""
Add node to cluster with different services
"""
def _add_service_node(self, cwc_servers, serices_add, services="kv"):
if serices_add == 1:
total_servers = cwc_servers[:3]
elif services_add > 1:
total_servers = cwc_servers[:len(nodes) + 1]
add_node_rest = RestConnection(cwc_servers[len(nodes)])
try:
add_node_rest.force_eject_node()
status = add_node_rest.init_node_services(
hostname=cwc_servers[len(nodes)].ip,
services=services)
init_node = self.cluster.async_init_node(cwc_servers[len(nodes)])
self.log.info("===== add node %s with service %s =====" \
% (cwc_servers[len(nodes)].ip,
services))
self.cluster.rebalance(total_servers, [cwc_servers[len(nodes)]], \
[], services=services)
except Exception, e:
if e:
print e
if status:
if self.cb_version[:5] in COUCHBASE_FROM_WATSON:
add_node_rest.set_indexer_storage_mode(storageMode="memory_optimized")

def _monitor_collecting_log(self, rest, timeout):
start_time = time.time()
end_time = start_time + timeout
Expand Down Expand Up @@ -97,8 +145,9 @@ def _monitor_collecting_log(self, rest, timeout):
def _verify_log_file(self, rest):
progress, status, perNode = rest.get_cluster_logs_collection_status()
node_failed_to_collect = []
nodes = rest.get_nodes()
for node in perNode:
for server in self.servers[:self.nodes_init]:
for server in self.servers[:len(nodes)]:
if server.ip in node or (self.nodes_init == 1 \
and "127.0.0.1" in node):
shell = RemoteMachineShellConnection(server)
Expand Down

0 comments on commit 7cc46e4

Please sign in to comment.