mirror of
https://github.com/google/nomulus
synced 2025-12-23 06:15:42 +00:00
Add domain creates to the load testing client (#2458)
* Add domain creates to the load testing client * Update contact create
This commit is contained in:
@@ -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<ArrayList<ZonedDateTime>> REQUEST_SENT =
|
||||
AttributeKey.valueOf("REQUEST_SENT");
|
||||
static final AttributeKey<ArrayList<ZonedDateTime>> 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<InetAddress> {
|
||||
|
||||
@@ -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<String> makeInputList(ZonedDateTime now) {
|
||||
ImmutableList.Builder<String> templatesList = ImmutableList.builder();
|
||||
ImmutableList.Builder<String> 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<ChannelFuture> 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);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
<contact:create
|
||||
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
|
||||
<contact:id>@@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@</contact:id>
|
||||
<contact:postalInfo type="int">
|
||||
<contact:name>John Doe</contact:name>
|
||||
<contact:org>Example, Inc.</contact:org>
|
||||
<contact:addr>
|
||||
<contact:street>111 Example Street</contact:street>
|
||||
<contact:street></contact:street>
|
||||
<contact:city>Los Angeles</contact:city>
|
||||
<contact:sp>CA</contact:sp>
|
||||
<contact:pc>90210</contact:pc>
|
||||
<contact:cc>US</contact:cc>
|
||||
</contact:addr>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>+1.2020202022</contact:voice>
|
||||
<contact:fax>+1.2022022022</contact:fax>
|
||||
<contact:email>test@email.com</contact:email>
|
||||
<contact:authInfo>
|
||||
<contact:pw>somepassword</contact:pw>
|
||||
</contact:authInfo>
|
||||
</contact:create>
|
||||
</create>
|
||||
<clTRID>epp-client-contact-create-@@NOW@@-@@CHANNEL_NUMBER@@</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>@@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@.@@TLD@@</domain:name>
|
||||
<domain:period unit="y">1</domain:period>
|
||||
<domain:ns>
|
||||
<domain:hostObj>ns1.domain.com</domain:hostObj>
|
||||
</domain:ns>
|
||||
<domain:registrant>@@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@</domain:registrant>
|
||||
<domain:contact type="admin">@@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@</domain:contact>
|
||||
<domain:contact type="tech">@@RANDOM@@-@@CHANNEL_NUMBER@@-@@REPEAT_NUMBER@@</domain:contact>
|
||||
<domain:authInfo>
|
||||
<domain:pw>somepassword</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:create>
|
||||
</create>
|
||||
<clTRID>epp-client-domain-create-@@NOW@@-@@CHANNEL_NUMBER@@</clTRID>
|
||||
</command>
|
||||
</epp>
|
||||
Reference in New Issue
Block a user