Not sure of the best solution, but a couple of ideas:

* A lot of code is already setup to use the Time interface. You could use
an modification of SystemTime that allows you to start at a specific
timestamp. There aren't as many System.currentTimeMillis as I thought there
would be so getting them all to use the Time interface might not be so bad.
The more annoying part is all the places we have a default parameter of
SystemTime and would want to make sure a non-default Time object is
actually passed in.
* Use ptrace to intercept and modify the relevant syscalls. You can
definitely do this to modify syscall input, I'd assume it's easy to hook in
right after the syscall and modify the output as well.
* If you can, just modify system time :) This isn't unreasonable if you're
willing to test in VMs.

I think either of the first 2 would be better because if you really want to
test this then you probably want to use > 1s jumps to make it more likely
to trigger any issues. Additionally, since both would allow you to make
arbitrary adjustments, you wouldn't even need to adjust the time to when a
leap second was supposed to occur, you could just simulate one by
adding/removing the second anytime you wanted.

If anyone else is curious, I had to go check the effect of leap seconds on
Unix time: http://en.wikipedia.org/wiki/Unix_time#Leap_seconds The upcoming
leap second is an insertion. The first second of the day effectively occurs
twice, so there's a 1 second jump backwards.

Could similar issues arise with ntp adjustments? Arguably many of the
places we use currentTimeMillis we should be using nanoTime instead since
we only need elapsed time, not an absolute timestamp. I believe that's
backed by clock_gettime's monotonic timer on Linux, which might avoid some
of these issues, but unfortunately that's not specified, so we probably
couldn't rely on it.

-Ewen


On Thu, Apr 23, 2015 at 8:06 PM, Gwen Shapira <gshap...@cloudera.com> wrote:

> Any ideas on how to simulate leap seconds on test environments?
>
> On Thu, Apr 23, 2015 at 7:51 PM, Ewen Cheslack-Postava
> <e...@confluent.io> wrote:
> > That sounds like a great candidate for a system test.
> >
> >
> > On Thu, Apr 23, 2015 at 7:48 PM, Gwen Shapira <gshap...@cloudera.com>
> wrote:
> >
> >> Hi,
> >>
> >> Looks like we are getting a new leap second on June 30.
> >>
> >> Is anyone planning on testing Kafka with leap seconds before it
> >> happens in production?
> >>
> >> Gwen
> >>
> >
> >
> >
> > --
> > Thanks,
> > Ewen
>



-- 
Thanks,
Ewen

Reply via email to