Set clock precision to milliseconds for Datetime->Instant migration (#2999)

Our existing precision is milliseconds so we want to stick with that for
Instants. If we want to increase the precision globally after that we can do so
all in one go post-migration, but for now, it would be a bad thing to have mixed
precision going on just depending on whether a class happens to be migrated yet
or not.

This PR also migrates all existing DateTime.nowUtc() calls to use the Clock
interface, so that when they are migrated they will get the benefit of this
precision-setting as well.

BUG= http://b/496985355
This commit is contained in:
Ben McIlwain
2026-04-03 20:38:26 +00:00
committed by GitHub
parent d2881b47dc
commit 49f14b5e1b
69 changed files with 466 additions and 320 deletions
@@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.Throwables;
import google.registry.proxy.handler.HttpsRelayServiceHandler.NonOkHttpResponseException;
import google.registry.testing.FakeClock;
import google.registry.util.SelfSignedCaCertificate;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -49,11 +50,11 @@ class EppProtocolModuleTest extends ProtocolModuleTest {
private static final byte[] HELLO_BYTES =
"""
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
"""
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
"""
.getBytes(UTF_8);
private X509Certificate certificate;
@@ -122,7 +123,7 @@ class EppProtocolModuleTest extends ProtocolModuleTest {
@Override
void beforeEach() throws Exception {
testComponent = makeTestComponent();
certificate = SelfSignedCaCertificate.create().cert();
certificate = SelfSignedCaCertificate.create(new FakeClock()).cert();
initializeChannel(
ch -> {
ch.attr(REMOTE_ADDRESS_KEY).set(CLIENT_ADDRESS);
@@ -32,6 +32,7 @@ import com.google.common.io.BaseEncoding;
import google.registry.proxy.TestUtils;
import google.registry.proxy.handler.HttpsRelayServiceHandler.NonOkHttpResponseException;
import google.registry.proxy.metric.FrontendMetrics;
import google.registry.testing.FakeClock;
import google.registry.util.ProxyHttpHeaders;
import google.registry.util.SelfSignedCaCertificate;
import io.netty.buffer.ByteBuf;
@@ -114,7 +115,7 @@ class EppServiceHandlerTest {
@BeforeEach
void beforeEach() throws Exception {
clientCertificate = SelfSignedCaCertificate.create().cert();
clientCertificate = SelfSignedCaCertificate.create(new FakeClock()).cert();
channel = setUpNewChannel(eppServiceHandler);
}
@@ -171,7 +172,7 @@ class EppServiceHandlerTest {
new EppServiceHandler(
RELAY_HOST, RELAY_PATH, false, () -> ID_TOKEN, HELLO.getBytes(UTF_8), metrics);
EmbeddedChannel channel2 = setUpNewChannel(eppServiceHandler2);
X509Certificate clientCertificate2 = SelfSignedCaCertificate.create().cert();
X509Certificate clientCertificate2 = SelfSignedCaCertificate.create(new FakeClock()).cert();
setHandshakeSuccess(channel2, clientCertificate2);
String certHash2 = getCertificateHash(clientCertificate2);