mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Change the LoadTestAction to use /_dr/epptool
The load tests used to directly build EPP, but that becomes problematic for an upcoming CL that refactors a lot of the EPP flow code. Instead, use the existing tool endpoint (conveniently, LoadTestAction is already in the tools module). This required changing the EppToolServlet to get its xml from a param rather than from the request payload, since task queues won't allow both a payload and request params on the same task. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124351878
This commit is contained in:
parent
5a2f63cf58
commit
366c5a344d
19 changed files with 227 additions and 255 deletions
|
@ -16,19 +16,22 @@ package google.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 google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
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.base.Joiner;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.net.MediaType;
|
||||
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.request.Action;
|
||||
|
@ -37,6 +40,8 @@ import google.registry.util.TaskEnqueuer;
|
|||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -278,12 +283,28 @@ public class LoadTestAction implements Runnable {
|
|||
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()));
|
||||
tasks.add(TaskOptions.Builder.withUrl("/_dr/epptool")
|
||||
.etaMillis(start.getMillis() + offsetMillis)
|
||||
.payload(
|
||||
Joiner.on('&').withKeyValueSeparator('=').join(
|
||||
ImmutableMap.of(
|
||||
"clientIdentifier", clientId,
|
||||
"superuser", false,
|
||||
"dryRun", false,
|
||||
"xml", urlEncode(xmls.get(i)))),
|
||||
MediaType.FORM_DATA.toString()));
|
||||
}
|
||||
return tasks.build();
|
||||
}
|
||||
|
||||
private String urlEncode(String xml) {
|
||||
try {
|
||||
return URLEncoder.encode(xml, UTF_8.toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue