mv com/google/domain/registry google/registry

This change renames directories in preparation for the great package
rename. The repository is now in a broken state because the code
itself hasn't been updated. However this should ensure that git
correctly preserves history for each file.
This commit is contained in:
Justine Tunney 2016-05-13 18:55:08 -04:00
parent a41677aea1
commit 5012893c1d
2396 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package(
default_visibility = ["//java/com/google/domain/registry:registry_project"],
)
filegroup(
name = "templates",
srcs = glob(["templates/*.xml"]),
)
java_library(
name = "loadtest",
srcs = glob(["*.java"]),
resources = [":templates"],
deps = [
"//java/com/google/common/base",
"//java/com/google/common/collect",
"//java/com/google/domain/registry/config",
"//java/com/google/domain/registry/flows",
"//java/com/google/domain/registry/model",
"//java/com/google/domain/registry/request",
"//java/com/google/domain/registry/util",
"//third_party/java/appengine:appengine-api",
"//third_party/java/dagger",
"//third_party/java/joda_time",
"//third_party/java/jsr330_inject",
"//third_party/java/objectify:objectify-v4_1",
"//third_party/java/servlet/servlet_api",
],
)

View file

@ -0,0 +1,49 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.loadtest;
import static com.google.cloud.sql.jdbc.internal.Charsets.UTF_8;
import static com.google.domain.registry.flows.EppController.handleEppCommand;
import com.google.appengine.api.taskqueue.DeferredTask;
import com.google.domain.registry.flows.SessionMetadata.SessionSource;
import com.google.domain.registry.flows.StatelessRequestSessionMetadata;
import com.google.domain.registry.model.eppcommon.ProtocolDefinition;
/** A task that executes a single EPP command. */
public class LoadTask implements DeferredTask {
private static final long serialVersionUID = -7541344556045675149L;
private final String clientId;
private final String xml;
LoadTask(String clientId, String xml) {
this.clientId = clientId;
this.xml = xml;
}
@Override
public void run() {
handleEppCommand(
xml.getBytes(UTF_8),
new StatelessRequestSessionMetadata(
clientId,
false,
false,
ProtocolDefinition.getVisibleServiceExtensionUris(),
SessionSource.LOADTEST));
}
}

View file

@ -0,0 +1,293 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.loadtest;
import static com.google.appengine.api.taskqueue.QueueConstants.maxTasksPerAdd;
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withPayload;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Lists.partition;
import static com.google.common.collect.Lists.transform;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.util.Arrays.asList;
import static org.joda.time.DateTimeZone.UTC;
import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.domain.registry.config.RegistryEnvironment;
import com.google.domain.registry.request.Action;
import com.google.domain.registry.request.Parameter;
import com.google.domain.registry.util.TaskEnqueuer;
import org.joda.time.DateTime;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import javax.inject.Inject;
/** Simple load test action that can generate configurable QPSes of various EPP actions. */
@Action(
path = "/_dr/loadtest",
method = Action.Method.POST,
automaticallyPrintOk = true)
public class LoadTestAction implements Runnable {
private static final int NUM_QUEUES = 10;
private static final int ARBITRARY_VALID_HOST_LENGTH = 40;
private static final int MAX_CONTACT_LENGTH = 13;
private static final int MAX_DOMAIN_LABEL_LENGTH = 63;
private static final String EXISTING_DOMAIN = "testdomain";
private static final String EXISTING_CONTACT = "contact";
private static final String EXISTING_HOST = "ns1";
private static final Random random = new Random();
/** The client identifier of the registrar to use for load testing. */
@Inject
@Parameter("loadtestClientId")
String clientId;
/**
* The number of seconds to delay the execution of the first load testing tasks by. Preparatory
* work of creating independent contacts and hosts that will be used for later domain creation
* testing occurs during this period, so make sure that it is long enough.
*/
@Inject
@Parameter("delaySeconds")
int delaySeconds;
/**
* The number of seconds that tasks will be enqueued for. Note that if system QPS cannot handle
* the given load then it will take longer than this number of seconds for the test to complete.
*/
@Inject
@Parameter("runSeconds")
int runSeconds;
/** The number of successful domain creates to enqueue per second over the length of the test. */
@Inject
@Parameter("successfulDomainCreates")
int successfulDomainCreatesPerSecond;
/** The number of failed domain creates to enqueue per second over the length of the test. */
@Inject
@Parameter("failedDomainCreates")
int failedDomainCreatesPerSecond;
/** The number of successful domain infos to enqueue per second over the length of the test. */
@Inject
@Parameter("domainInfos")
int domainInfosPerSecond;
/** The number of successful domain checks to enqueue per second over the length of the test. */
@Inject
@Parameter("domainChecks")
int domainChecksPerSecond;
/** The number of successful contact creates to enqueue per second over the length of the test. */
@Inject
@Parameter("successfulContactCreates")
int successfulContactCreatesPerSecond;
/** The number of failed contact creates to enqueue per second over the length of the test. */
@Inject
@Parameter("failedContactCreates")
int failedContactCreatesPerSecond;
/** The number of successful contact infos to enqueue per second over the length of the test. */
@Inject
@Parameter("contactInfos")
int contactInfosPerSecond;
/** The number of successful host creates to enqueue per second over the length of the test. */
@Inject
@Parameter("successfulHostCreates")
int successfulHostCreatesPerSecond;
/** The number of failed host creates to enqueue per second over the length of the test. */
@Inject
@Parameter("failedHostCreates")
int failedHostCreatesPerSecond;
/** The number of successful host infos to enqueue per second over the length of the test. */
@Inject
@Parameter("hostInfos")
int hostInfosPerSecond;
@Inject
TaskEnqueuer taskEnqueuer;
private final String xmlContactCreateTmpl;
private final String xmlContactCreateFail;
private final String xmlContactInfo;
private final String xmlDomainCheck;
private final String xmlDomainCreateTmpl;
private final String xmlDomainCreateFail;
private final String xmlDomainInfo;
private final String xmlHostCreateTmpl;
private final String xmlHostCreateFail;
private final String xmlHostInfo;
@Inject
LoadTestAction(@Parameter("tld") String tld) {
xmlContactCreateTmpl = loadXml("contact_create");
xmlContactCreateFail = xmlContactCreateTmpl.replace("%contact%", EXISTING_CONTACT);
xmlContactInfo = loadXml("contact_info").replace("%contact%", EXISTING_CONTACT);
xmlDomainCheck =
loadXml("domain_check").replace("%tld%", tld).replace("%domain%", EXISTING_DOMAIN);
xmlDomainCreateTmpl = loadXml("domain_create").replace("%tld%", tld);
xmlDomainCreateFail =
xmlDomainCreateTmpl
.replace("%domain%", EXISTING_DOMAIN)
.replace("%contact%", EXISTING_CONTACT)
.replace("%host%", EXISTING_HOST);
xmlDomainInfo =
loadXml("domain_info").replace("%tld%", tld).replace("%domain%", EXISTING_DOMAIN);
xmlHostCreateTmpl = loadXml("host_create");
xmlHostCreateFail = xmlHostCreateTmpl.replace("%host%", EXISTING_HOST);
xmlHostInfo = loadXml("host_info").replace("%host%", EXISTING_HOST);
}
@Override
public void run() {
checkArgument(
RegistryEnvironment.get() != RegistryEnvironment.PRODUCTION,
"DO NOT RUN LOADTESTS IN PROD!");
DateTime initialStartSecond = DateTime.now(UTC).plusSeconds(delaySeconds);
ImmutableList.Builder<String> preTaskXmls = new ImmutableList.Builder<>();
ImmutableList.Builder<String> contactNamesBuilder = new ImmutableList.Builder<>();
ImmutableList.Builder<String> hostPrefixesBuilder = new ImmutableList.Builder<>();
for (int i = 0; i < successfulDomainCreatesPerSecond; i++) {
String contactName = getRandomLabel(MAX_CONTACT_LENGTH);
String hostPrefix = getRandomLabel(ARBITRARY_VALID_HOST_LENGTH);
contactNamesBuilder.add(contactName);
hostPrefixesBuilder.add(hostPrefix);
preTaskXmls.add(
xmlContactCreateTmpl.replace("%contact%", contactName),
xmlHostCreateTmpl.replace("%host%", hostPrefix));
}
enqueue(createTasks(preTaskXmls.build(), DateTime.now(UTC)));
ImmutableList<String> contactNames = contactNamesBuilder.build();
ImmutableList<String> hostPrefixes = hostPrefixesBuilder.build();
ImmutableList.Builder<TaskOptions> tasks = new ImmutableList.Builder<>();
for (int offsetSeconds = 0; offsetSeconds < runSeconds; offsetSeconds++) {
DateTime startSecond = initialStartSecond.plusSeconds(offsetSeconds);
// The first "failed" creates might actually succeed if the object doesn't already exist, but
// that shouldn't affect the load numbers.
tasks.addAll(
createTasks(
createNumCopies(xmlContactCreateFail, failedContactCreatesPerSecond), startSecond));
tasks.addAll(
createTasks(createNumCopies(xmlHostCreateFail, failedHostCreatesPerSecond), startSecond));
tasks.addAll(
createTasks(
createNumCopies(xmlDomainCreateFail, failedDomainCreatesPerSecond), startSecond));
// We can do infos on the known existing objects.
tasks.addAll(
createTasks(createNumCopies(xmlContactInfo, contactInfosPerSecond), startSecond));
tasks.addAll(createTasks(createNumCopies(xmlHostInfo, hostInfosPerSecond), startSecond));
tasks.addAll(createTasks(createNumCopies(xmlDomainInfo, domainInfosPerSecond), startSecond));
// The domain check template uses "example.TLD" which won't exist, and one existing domain.
tasks.addAll(
createTasks(createNumCopies(xmlDomainCheck, domainChecksPerSecond), startSecond));
// Do successful creates on random names
tasks.addAll(
createTasks(
transform(
createNumCopies(xmlContactCreateTmpl, successfulContactCreatesPerSecond),
randomNameReplacer("%contact%", MAX_CONTACT_LENGTH)),
startSecond));
tasks.addAll(
createTasks(
transform(
createNumCopies(xmlHostCreateTmpl, successfulHostCreatesPerSecond),
randomNameReplacer("%host%", ARBITRARY_VALID_HOST_LENGTH)),
startSecond));
tasks.addAll(
createTasks(
FluentIterable.from(
createNumCopies(xmlDomainCreateTmpl, successfulDomainCreatesPerSecond))
.transform(randomNameReplacer("%domain%", MAX_DOMAIN_LABEL_LENGTH))
.transform(listNameReplacer("%contact%", contactNames))
.transform(listNameReplacer("%host%", hostPrefixes))
.toList(),
startSecond));
}
enqueue(tasks.build());
}
private String loadXml(String name) {
return readResourceUtf8(LoadTestAction.class, String.format("templates/%s.xml", name));
}
private List<String> createNumCopies(String xml, int numCopies) {
String[] xmls = new String[numCopies];
Arrays.fill(xmls, xml);
return asList(xmls);
}
private Function<String, String> listNameReplacer(final String toReplace, List<String> choices) {
final Iterator<String> iterator = Iterators.cycle(choices);
return new Function<String, String>() {
@Override
public String apply(String xml) {
return xml.replace(toReplace, iterator.next());
}};
}
private Function<String, String> randomNameReplacer(final String toReplace, final int numChars) {
return new Function<String, String>() {
@Override
public String apply(String xml) {
return xml.replace(toReplace, getRandomLabel(numChars));
}};
}
private String getRandomLabel(int numChars) {
StringBuilder name = new StringBuilder();
for (int j = 0; j < numChars; j++) {
name.append(Character.forDigit(random.nextInt(Character.MAX_RADIX), Character.MAX_RADIX));
}
return name.toString();
}
private List<TaskOptions> createTasks(List<String> xmls, DateTime start) {
ImmutableList.Builder<TaskOptions> tasks = new ImmutableList.Builder<>();
for (int i = 0; i < xmls.size(); i++) {
// Space tasks evenly within across a second.
int offsetMillis = (int) (1000.0 / xmls.size() * i);
tasks.add(withPayload(new LoadTask(clientId, xmls.get(i)))
.etaMillis(start.plusMillis(offsetMillis).getMillis()));
}
return tasks.build();
}
private void enqueue(List<TaskOptions> tasks) {
List<List<TaskOptions>> chunks = partition(tasks, maxTasksPerAdd());
// Farm out tasks to multiple queues to work around queue qps quotas.
for (int i = 0; i < chunks.size(); i++) {
taskEnqueuer.enqueue(getQueue("load" + (i % NUM_QUEUES)), chunks.get(i));
}
}
}

View file

@ -0,0 +1,118 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.loadtest;
import static com.google.domain.registry.request.RequestParameters.extractOptionalIntParameter;
import static com.google.domain.registry.request.RequestParameters.extractRequiredParameter;
import com.google.domain.registry.request.Parameter;
import dagger.Module;
import dagger.Provides;
import org.joda.time.Minutes;
import javax.servlet.http.HttpServletRequest;
/**
* Dagger module for loadtest package.
*
* @see "com.google.domain.registry.module.backend.ToolsComponent"
*/
@Module
public final class LoadTestModule {
// There's already an @Parameter("clientId") for CreateGroupsAction that's only optional, and we
// want this one to be required, so give it a different name.
@Provides
@Parameter("loadtestClientId")
static String provideClientId(HttpServletRequest req) {
return extractRequiredParameter(req, "clientId");
}
@Provides
@Parameter("delaySeconds")
static int provideDelaySeconds(HttpServletRequest req) {
return extractOptionalIntParameter(req, "delaySeconds")
.or(Minutes.ONE.toStandardSeconds().getSeconds());
}
@Provides
@Parameter("runSeconds")
static int provideRunSeconds(HttpServletRequest req) {
return extractOptionalIntParameter(req, "runSeconds")
.or(Minutes.ONE.toStandardSeconds().getSeconds());
}
@Provides
@Parameter("successfulDomainCreates")
static int provideSuccessfulDomainCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulDomainCreates").or(0);
}
@Provides
@Parameter("failedDomainCreates")
static int provideFailedDomainCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedDomainCreates").or(0);
}
@Provides
@Parameter("domainInfos")
static int provideDomainInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "domainInfos").or(0);
}
@Provides
@Parameter("domainChecks")
static int provideDomainChecks(HttpServletRequest req) {
return extractOptionalIntParameter(req, "domainChecks").or(0);
}
@Provides
@Parameter("successfulContactCreates")
static int provideSuccessfulContactCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulContactCreates").or(0);
}
@Provides
@Parameter("failedContactCreates")
static int provideFailedContactCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedContactCreates").or(0);
}
@Provides
@Parameter("contactInfos")
static int provideContactInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "contactInfos").or(0);
}
@Provides
@Parameter("successfulHostCreates")
static int provideSuccessfulHostCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "successfulHostCreates").or(0);
}
@Provides
@Parameter("failedHostCreates")
static int provideFailedHostCreates(HttpServletRequest req) {
return extractOptionalIntParameter(req, "failedHostCreates").or(0);
}
@Provides
@Parameter("hostInfos")
static int provideHostInfos(HttpServletRequest req) {
return extractOptionalIntParameter(req, "hostInfos").or(0);
}
}

View file

@ -0,0 +1,33 @@
<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>%contact%</contact:id>
<contact:postalInfo type="int">
<contact:name>John Doe</contact:name>
<contact:org>Example Inc.</contact:org>
<contact:addr>
<contact:street>123 Example Dr.</contact:street>
<contact:street>Suite 100</contact:street>
<contact:city>Dulles</contact:city>
<contact:sp>VA</contact:sp>
<contact:pc>20166-6503</contact:pc>
<contact:cc>US</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice x="1234">+1.7035555555</contact:voice>
<contact:fax>+1.7035555556</contact:fax>
<contact:email>jdoe@example.com</contact:email>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
<contact:disclose flag="1">
<contact:voice/>
<contact:email/>
</contact:disclose>
</contact:create>
</create>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,14 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<contact:info
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>%contact%</contact:id>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
</contact:info>
</info>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,11 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>%domain%.%tld%</domain:name>
<domain:name>example.%tld%</domain:name>
</domain:check>
</check>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,21 @@
<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>%domain%.%tld%</domain:name>
<domain:period unit="y">2</domain:period>
<domain:ns>
<domain:hostObj>%host%.example.com</domain:hostObj>
</domain:ns>
<domain:registrant>%contact%</domain:registrant>
<domain:contact type="admin">%contact%</domain:contact>
<domain:contact type="tech">%contact%</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,11 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<domain:info
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name hosts="all">%domain%.%tld%</domain:name>
</domain:info>
</info>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,11 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<host:create
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>%host%.example.com</host:name>
</host:create>
</create>
<clTRID>trid</clTRID>
</command>
</epp>

View file

@ -0,0 +1,11 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<host:info
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>%host%.example.com</host:name>
</host:info>
</info>
<clTRID>trid</clTRID>
</command>
</epp>