From d53177e44c25b77289dad90a57cef8ee8113b4a3 Mon Sep 17 00:00:00 2001 From: sarahcaseybot Date: Thu, 6 Jun 2024 13:30:12 -0400 Subject: [PATCH] Add domain creates to the load testing client (#2458) * Add domain creates to the load testing client * Update contact create --- .../google/registry/client/EppClient.java | 44 +++++++++++++++++-- .../client/resources/contact_create.xml | 30 +++++++++++++ .../client/resources/domain_create.xml | 22 ++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 load-testing/src/main/java/google/registry/client/resources/contact_create.xml create mode 100644 load-testing/src/main/java/google/registry/client/resources/domain_create.xml diff --git a/load-testing/src/main/java/google/registry/client/EppClient.java b/load-testing/src/main/java/google/registry/client/EppClient.java index 21ccf5076..13b8b84be 100644 --- a/load-testing/src/main/java/google/registry/client/EppClient.java +++ b/load-testing/src/main/java/google/registry/client/EppClient.java @@ -22,6 +22,7 @@ import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; +import com.google.common.io.BaseEncoding; import com.google.common.io.Files; import com.google.common.io.Resources; import io.netty.bootstrap.Bootstrap; @@ -59,6 +60,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; +import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.bouncycastle.cert.X509CertificateHolder; @@ -80,6 +83,11 @@ public class EppClient implements Runnable { private static final String LOGIN_FILE = "login.xml"; private static final String LOGOUT_FILE = "logout.xml"; + + private static final String CONTACT_CREATE_FILE = "contact_create.xml"; + + private static final String DOMAIN_CREATE_FILE = "domain_create.xml"; + static final AttributeKey> REQUEST_SENT = AttributeKey.valueOf("REQUEST_SENT"); static final AttributeKey> RESPONSE_RECEIVED = @@ -95,6 +103,7 @@ public class EppClient implements Runnable { AttributeKey.valueOf("LOGGING_REQUEST_COMPLETE"); private static final int PORT = 700; private static final int TIMEOUT_SECONDS = 600; + private static final Random random = new Random(); public static class InetAddressConverter implements IStringConverter { @@ -148,6 +157,16 @@ public class EppClient implements Runnable { description = "Registrar password.") private String password = "abcde12345"; + @Parameter( + names = {"--domain_creates"}, + description = "The number of domains to create.") + private int domainCreates = 0; + + @Parameter( + names = {"--tld"}, + description = "TLD to create domains on.") + private String tld = "test"; + @Parameter( names = {"--force_terminate", "-ft"}, description = "Whether to explicitly close the connection after receiving a logout response.") @@ -164,17 +183,35 @@ public class EppClient implements Runnable { eppClient.run(); } + private static String generateRandomString(int length) { + byte[] buffer = new byte[length]; + random.nextBytes(buffer); + return BaseEncoding.base32().encode(buffer).toLowerCase(Locale.US); + } + private ImmutableList makeInputList(ZonedDateTime now) { ImmutableList.Builder templatesList = ImmutableList.builder(); ImmutableList.Builder inputList = ImmutableList.builder(); templatesList.add(readStringFromFile(LOGIN_FILE)); + for (int i = 0; i < domainCreates; i++) { + String randomString = generateRandomString(5); + templatesList.add( + readStringFromFile(CONTACT_CREATE_FILE) + .replace("@@REPEAT_NUMBER@@", String.valueOf(i)) + .replace("@@RANDOM@@", randomString)); + templatesList.add( + readStringFromFile(DOMAIN_CREATE_FILE) + .replace("@@REPEAT_NUMBER@@", String.valueOf(i)) + .replace("@@RANDOM@@", randomString)); + } templatesList.add(readStringFromFile(LOGOUT_FILE)); for (String template : templatesList.build()) { inputList.add( template .replace("@@CLIENT@@", client) .replace("@@PASSWORD@@", password) - .replace("@@NOW@@", now.toString())); + .replace("@@NOW@@", now.toString()) + .replace("@@TLD@@", tld)); } return inputList.build(); } @@ -292,8 +329,9 @@ public class EppClient implements Runnable { List channelFutures = new ArrayList<>(); - // Three requests: hello (from the proxy), login and logout. - int requestPerConnection = 3; + // Three requests: hello (from the proxy), login and logout plus additional configured EPP + // requests. + int requestPerConnection = 3 + (domainCreates * 2); for (int i = 0; i < connections; i++) { bootstrap.attr(CHANNEL_NUMBER, i); diff --git a/load-testing/src/main/java/google/registry/client/resources/contact_create.xml b/load-testing/src/main/java/google/registry/client/resources/contact_create.xml new file mode 100644 index 000000000..729ab9177 --- /dev/null +++ b/load-testing/src/main/java/google/registry/client/resources/contact_create.xml @@ -0,0 +1,30 @@ + + + + + + @@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@ + + John Doe + Example, Inc. + + 111 Example Street + + Los Angeles + CA + 90210 + US + + + +1.2020202022 + +1.2022022022 + test@email.com + + somepassword + + + + epp-client-contact-create-@@NOW@@-@@CHANNEL_NUMBER@@ + + diff --git a/load-testing/src/main/java/google/registry/client/resources/domain_create.xml b/load-testing/src/main/java/google/registry/client/resources/domain_create.xml new file mode 100644 index 000000000..2828b4712 --- /dev/null +++ b/load-testing/src/main/java/google/registry/client/resources/domain_create.xml @@ -0,0 +1,22 @@ + + + + + + @@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@.@@TLD@@ + 1 + + ns1.domain.com + + @@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@ + @@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@ + @@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@ + + somepassword + + + + epp-client-domain-create-@@NOW@@-@@CHANNEL_NUMBER@@ + +