DESCRIPTION

CBQE-3675: wait until nodes total memory is initialized

before initializing nodes in tests.

This commit adds a simple function that repeatedly calls a
function until the function's return value satisfies an
arbitrary condition. This is then used in the node initialization
routine to wait until the node is ready to be set up.

Change-Id: Ib96ff5a434ba9f0bc4197278440ddaac428c02e6


COMMENTS

author: Kian Santos
date: 2016-10-19 18:50:50.868000000

Uploaded patch set 2: Patch Set 1 was rebased.

-------------------------------------
author: Kian Santos
date: 2016-10-19 18:51:52.562000000

Patch Set 2:

@Tommie, @Emerson Duke - who should review my change? thanks

-------------------------------------
author: Kian Santos
date: 2016-10-20 03:23:33.144000000

Patch Set 2: Verified+1

-------------------------------------
author: Titus Ho
date: 2016-10-20 14:00:10.060000000

Patch Set 2: Code-Review-1

Hi Dave, we have a StatsWaitTask for this specific use case:
https://github.com/couchbase/testrunner/blob/master/lib/tasks/task.py#L532
Your implementation is also very nice, so if that task doesn't do what you're trying to do perhaps you could enhance it to support your use case.

-------------------------------------
author: Kian Santos
date: 2016-10-24 21:15:45.784000000

Patch Set 2:

Hi Tommie

There are a number of problems with using the StatsWaitTask. The first problem is that it calls memcached, and I need it to call the REST API. We could potentially pop another type of task into existence or modify the "stats wait task" to be a "stats or REST API wait task". Or we could write a generic waiter task that takes an action function to perform and a condition function to tell when the action is done. 

But this all seems really heavy weight - a lot of code and more threads than I need. All I really want to do is wait the 20-30 ms for this condition to be true in the current executing thread so I can advance to the next step in terms of setting up the cluster. I'd prefer not to spawn a thread, kick it off and then simply wait until it's done.

I think that the tasks and the function to synchronously wait are both useful. Tasks are particularly good for longer running things that you don't want to wait on. Simple synchronous wait is nice for things where you can't make progress until they're done anyway. I think there are lots of place where we blind sleep in the testrunner code where we could use the wait_until() function to make the tests more robust. 

So I guess I'm asking that you reconsider your -1. I don't want to create a new task type or modify the StatsWaitTask to also wait against the REST API - for the reasons outlined above and I believe the the synchronous wait_util() function is useful all by itself. 

By the way, I would be happy to explicitly point to the tasks in the function comment for wait_until() so that folks who find themselves there don't fail to notice the predefined tasks that they might want to use.

-------------------------------------
author: Kian Santos
date: 2016-10-24 21:16:46.593000000

Patch Set 2:

(of course when I say "spawn a thread" what I mean is "create a task and have it be run by a thread in the task harness")

-------------------------------------
author: Titus Ho
date: 2016-10-28 12:13:11.172000000

Patch Set 2: Code-Review+2

Ok, I like the idea of reusing this wait_util() method as it can help us refactor StatsWait.  Thanks Dave

-------------------------------------
author: Tate Garrett
date: 2017-01-12 06:16:04.125000000

Change has been successfully cherry-picked as 0fc41bfce32d57cb634af570c81b5967e357fafe by Kian Santos

-------------------------------------
