1
0
mirror of https://github.com/google/nomulus synced 2026-02-09 06:20:29 +00:00

Convert GenerateZoneFilesAction to SQL (#1668)

I'm not 100% sure that this is strictly necessary, but for now we can
replicate the ability to generate zonefiles for any point in time in the
recent past.
This commit is contained in:
gbrodman
2022-06-21 15:51:52 -04:00
committed by GitHub
parent dddeb48356
commit bb9b669014
2 changed files with 99 additions and 149 deletions

View File

@@ -37,28 +37,32 @@ import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DualDatabaseTest;
import google.registry.testing.FakeClock;
import google.registry.testing.TmOverrideExtension;
import google.registry.testing.mapreduce.MapreduceTestCase;
import google.registry.testing.TestSqlOnly;
import java.net.InetAddress;
import java.util.Map;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Duration;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Tests for {@link GenerateZoneFilesAction}. */
class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAction> {
@DualDatabaseTest
class GenerateZoneFilesActionTest {
@RegisterExtension
@Order(Order.DEFAULT - 1)
TmOverrideExtension tmOverrideExtension = TmOverrideExtension.withOfy();
public final AppEngineExtension appEngine =
AppEngineExtension.builder()
.withDatastoreAndCloudSql()
.withLocalModules()
.withTaskQueue()
.build();
private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions());
@Test
@TestSqlOnly
void testGenerate() throws Exception {
DateTime now = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay();
createTlds("tld", "com");
@@ -118,7 +122,6 @@ class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAct
.build());
GenerateZoneFilesAction action = new GenerateZoneFilesAction();
action.mrRunner = makeDefaultRunner();
action.bucket = "zonefiles-bucket";
action.gcsUtils = gcsUtils;
action.datastoreRetention = standardDays(29);
@@ -132,13 +135,6 @@ class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAct
ImmutableMap.<String, Object>of("tlds", ImmutableList.of("tld"), "exportTime", now));
assertThat(response)
.containsEntry("filenames", ImmutableList.of("gs://zonefiles-bucket/tld-" + now + ".zone"));
assertThat(response).containsKey("mapreduceConsoleLink");
assertThat(response.get("mapreduceConsoleLink").toString())
.startsWith(
"Mapreduce console: https://backend-dot-projectid.appspot.com"
+ "/_ah/pipeline/status.html?root=");
executeTasksUntilEmpty("mapreduce");
BlobId gcsFilename = BlobId.of("zonefiles-bucket", String.format("tld-%s.zone", now));
String generatedFile = new String(gcsUtils.readBytesFrom(gcsFilename), UTF_8);