Mock access to time-related methods
-----------------------------------

                 Key: ZOOKEEPER-1369
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1369
             Project: ZooKeeper
          Issue Type: Improvement
            Reporter: Henry Robinson


As we began to discuss in ZOOKEEPER-1366, it would be great to have the ability 
to mock out time methods anywhere to help with deterministic, more efficient 
testing. 

The general idea is to have a 'mock clock' that any thread can interact with as 
though it were the real clock. Time would typically be advanced by an 
independent thread of control (normally the thread that the test is running 
in). 

There are two main method calls that interact with the JVM clock:

# {{System.currentTimeMillis}} - very easy to mock
# {{Thread.sleep}} - slightly harder, since the mock clock would need to keep 
an ordered list of threads that need to be woken up and release a barrier for 
each one as time was advanced. 

Other implicit methods, such as setting the socket rx timeout, are probably too 
hard to mock and are out of scope for this ticket. 


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to