Permalink
Browse files

CBQE-813:move _wait_warmup_completed in ClusterOperationHelper

it's better to move this method in ClusterOperationHelper from basetestcase because it can be used not only in tests that extend basetestcase

Change-Id: I508d6c8f8c117d66664b2cd8c00524d2a037567f
Reviewed-on: http://review.couchbase.org/22610
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Andrei Baranouski <andrei.baranouski@gmail.com>
  • Loading branch information...
1 parent 86fb4ad commit 3666b7a8678d4a19449d596f957f2131bd44e606 @andreibaranouski andreibaranouski committed with andreibaranouski Nov 18, 2012
@@ -85,6 +85,57 @@ def wait_for_ns_servers_or_assert(servers, testcase):
testcase.assertTrue(RestHelper(rest).is_ns_server_running(),
"ns_server is not running in {0}".format(server.ip))
+ #returns true if warmup is completed in wait_time sec
+ #otherwise return false
+ @staticmethod
+ def _wait_warmup_completed(self, servers, bucket_name, wait_time=300):
+ warmed_up = False
+ log = logger.Logger.get_logger()
+ for server in servers:
+ mc = None
+ start = time.time()
+ # Try to get the stats for 5 minutes, else hit out.
+ while time.time() - start < wait_time:
+ # Get the wamrup time for each server
+ try:
+ mc = MemcachedClientHelper.direct_client(server, bucket_name)
+ stats = mc.stats()
+ if stats is not None:
+ warmup_time = int(stats["ep_warmup_time"])
+ log.info("ep_warmup_time is %s " % warmup_time)
+ log.info(
+ "Collected the stats %s for server %s:%s" % (stats["ep_warmup_time"], server.ip,
+ server.port))
+ break
+ else:
+ log.info(" Did not get the stats from the server yet, trying again.....")
+ time.sleep(2)
+ except Exception as e:
+ log.error(
+ "Could not get warmup_time stats from server %s:%s, exception %s" % (server.ip,
+ server.port, e))
+ else:
+ self.fail(
+ "Fail! Unable to get the warmup-stats from server %s:%s after trying for %s seconds." % (
+ server.ip, server.port, wait_time))
+
+ # Waiting for warm-up
+ start = time.time()
+ warmed_up = False
+ while time.time() - start < wait_time and not warmed_up:
+ if mc.stats()["ep_warmup_thread"] == "complete":
+ log.info("warmup completed, awesome!!! Warmed up. %s items " % (mc.stats()["curr_items_tot"]))
+ warmed_up = True
+ continue
+ elif mc.stats()["ep_warmup_thread"] == "running":
+ log.info(
+ "still warming up .... curr_items_tot : %s" % (mc.stats()["curr_items_tot"]))
+ else:
+ fail("Value of ep warmup thread does not exist, exiting from this server")
+ time.sleep(5)
+ mc.close()
+ return warmed_up
+
@staticmethod
def verify_persistence(servers, test, keys_count=400000, timeout_in_seconds=300):
log = logger.Logger.get_logger()
View
@@ -330,55 +330,3 @@ def verify_cluster_stats(self, servers=None, master=None, max_verify=None):
for bucket in self.buckets:
verified &= RebalanceHelper.wait_till_total_numbers_match(master, bucket)
self.assertTrue(verified, "Lost items!!! Replication was completed but sum(curr_items) don't match the curr_items_total")
-
-
- #returns true if warmup is completed in wait_time sec,
- #otherwise return false
- @staticmethod
- def _wait_warmup_completed(self, servers, bucket_name, wait_time=300):
- warmed_up = False
- log = logger.Logger.get_logger()
- for server in servers:
- mc = None
- start = time.time()
- # Try to get the stats for 5 minutes, else hit out.
- while time.time() - start < wait_time:
- # Get the wamrup time for each server
- try:
- mc = MemcachedClientHelper.direct_client(server, bucket_name)
- stats = mc.stats()
- if stats is not None:
- warmup_time = int(stats["ep_warmup_time"])
- log.info("ep_warmup_time is %s " % warmup_time)
- log.info(
- "Collected the stats %s for server %s:%s" % (stats["ep_warmup_time"], server.ip,
- server.port))
- break
- else:
- log.info(" Did not get the stats from the server yet, trying again.....")
- time.sleep(2)
- except Exception as e:
- log.error(
- "Could not get warmup_time stats from server %s:%s, exception %s" % (server.ip,
- server.port, e))
- else:
- self.fail(
- "Fail! Unable to get the warmup-stats from server %s:%s after trying for %s seconds." % (
- server.ip, server.port, wait_time))
-
- # Waiting for warm-up
- start = time.time()
- warmed_up = False
- while time.time() - start < wait_time and not warmed_up:
- if mc.stats()["ep_warmup_thread"] == "complete":
- log.info("warmup completed, awesome!!! Warmed up. %s items " % (mc.stats()["curr_items_tot"]))
- warmed_up = True
- continue
- elif mc.stats()["ep_warmup_thread"] == "running":
- log.info(
- "still warming up .... curr_items_tot : %s" % (mc.stats()["curr_items_tot"]))
- else:
- fail("Value of ep warmup thread does not exist, exiting from this server")
- time.sleep(5)
- mc.close()
- return warmed_up
@@ -7,6 +7,7 @@
from membase.api.rest_client import RestConnection
from couchbase.documentgenerator import BlobGenerator
from remote.remote_util import RemoteMachineShellConnection
+from membase.helper.cluster_helper import ClusterOperationHelper
class RebalanceInTests(RebalanceBaseTest):
@@ -287,8 +288,8 @@ def rebalance_in_with_warming_up(self):
rebalance.result()
except RebalanceFailedException:
self.log.info("rebalance was failed as expected")
- self.assertTrue(self._wait_warmup_completed(self, [warmup_node], self.default_bucket_name,
- wait_time=self.wait_timeout * 10))
+ self.assertTrue(ClusterOperationHelper._wait_warmup_completed(self, [warmup_node], \
+ self.default_bucket_name, wait_time=self.wait_timeout * 10))
self.log.info("second attempt to rebalance")
rebalance = self.cluster.async_rebalance(servs_init + servs_in, [], [])
@@ -6,6 +6,7 @@
from membase.api.rest_client import RestConnection
from remote.remote_util import RemoteMachineShellConnection
from membase.api.exception import RebalanceFailedException
+from membase.helper.cluster_helper import ClusterOperationHelper
class RebalanceOutTests(RebalanceBaseTest):
@@ -271,8 +272,8 @@ def rebalance_out_with_warming_up(self):
rebalance.result()
except RebalanceFailedException:
self.log.info("rebalance was failed as expected")
- self.assertTrue(self._wait_warmup_completed(self, [warmup_node], self.default_bucket_name,
- wait_time=self.wait_timeout * 10))
+ self.assertTrue(ClusterOperationHelper._wait_warmup_completed(self, [warmup_node], \
+ self.default_bucket_name, wait_time=self.wait_timeout * 10))
self.log.info("second attempt to rebalance")
rebalance = self.cluster.async_rebalance(self.servers, [], servs_out)
View
@@ -6,7 +6,7 @@
from couchbase.cluster import Cluster
from membase.api.rest_client import RestConnection, RestHelper
from membase.helper.bucket_helper import BucketOperationHelper
-from membase.helper.cluster_helper import ClusterOperationHelper as ClusterHelper, ClusterOperationHelper
+from membase.helper.cluster_helper import ClusterOperationHelper
from membase.helper.rebalance_helper import RebalanceHelper
from memcached.helper.data_helper import LoadWithMcsoda
from couchbase.stats_tools import StatsCommon
@@ -405,7 +405,7 @@ def _common_test_body_failed_swap_rebalance(self):
time.sleep(10)
# we can't get stats for new node when rebalance falls
if not self.swap_orchestrator:
- BaseTestCase._wait_warmup_completed(self, [master], bucket, wait_time=600)
+ ClusterOperationHelper._wait_warmup_completed(self, [master], bucket, wait_time=600)
i = 0
#we expect that rebalance will be failed
while rest._rebalance_progress_status() == "running" and i < 60:

0 comments on commit 3666b7a

Please sign in to comment.