mirror of
https://github.com/google/nomulus.git
synced 2025-08-12 04:29:39 +02:00
Remove some appengine dependencies (#1874)
Some retriers are no longer needed because transactions are automatically retried by the JPA transaction manager when there's a transient exception. <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1874) <!-- Reviewable:end -->
This commit is contained in:
parent
8c75ce08af
commit
71024c706d
20 changed files with 1054 additions and 1174 deletions
|
@ -28,13 +28,8 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.appengine.tools.remoteapi.RemoteApiException;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
@ -45,9 +40,6 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
|||
import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.DeterministicStringGenerator.Rule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeSleeper;
|
||||
import google.registry.util.Retrier;
|
||||
import google.registry.util.StringGenerator.Alphabets;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
@ -55,7 +47,6 @@ import javax.annotation.Nullable;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
|
||||
/** Unit tests for {@link GenerateAllocationTokensCommand}. */
|
||||
class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAllocationTokensCommand> {
|
||||
|
@ -63,8 +54,6 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
@BeforeEach
|
||||
void beforeEach() {
|
||||
command.stringGenerator = new DeterministicStringGenerator(Alphabets.BASE_58);
|
||||
command.retrier =
|
||||
new Retrier(new FakeSleeper(new FakeClock(DateTime.parse("2000-01-01TZ"))), 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -91,21 +80,6 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
assertInStdout("123456789ABCDEFG");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_retry() throws Exception {
|
||||
command = spy(command);
|
||||
RemoteApiException fakeException = new RemoteApiException("foo", "foo", "foo", new Exception());
|
||||
doThrow(fakeException)
|
||||
.doThrow(fakeException)
|
||||
.doCallRealMethod()
|
||||
.when(command)
|
||||
.saveTokens(ArgumentMatchers.any());
|
||||
runCommand("--number", "1");
|
||||
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||
assertInStdout("123456789ABCDEFG");
|
||||
verify(command, times(3)).saveTokens(ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_tokenCollision() throws Exception {
|
||||
AllocationToken existingToken =
|
||||
|
|
|
@ -38,8 +38,6 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.appengine.api.datastore.DatastoreFailureException;
|
||||
import com.google.appengine.api.datastore.DatastoreTimeoutException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import google.registry.model.contact.Contact;
|
||||
|
@ -642,29 +640,4 @@ public class WhoisActionTest {
|
|||
verify(action.whoisMetrics).recordWhoisMetric(eq(expected));
|
||||
assertThat(response.getPayload()).isEqualTo("Internal Server Error");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRun_retryOnTransientFailure() throws Exception {
|
||||
persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build());
|
||||
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4"));
|
||||
WhoisAction action = newWhoisAction("ns1.cat.lol");
|
||||
WhoisResponse expectedResponse =
|
||||
action
|
||||
.whoisReader
|
||||
.readCommand(action.input, false, clock.nowUtc())
|
||||
.executeQuery(clock.nowUtc());
|
||||
|
||||
WhoisReader mockReader = mock(WhoisReader.class);
|
||||
WhoisCommand mockCommand = mock(WhoisCommand.class);
|
||||
when(mockReader.readCommand(any(Reader.class), eq(false), any(DateTime.class)))
|
||||
.thenReturn(mockCommand);
|
||||
when(mockCommand.executeQuery(any(DateTime.class)))
|
||||
.thenThrow(new DatastoreFailureException("Expected transient exception #1"))
|
||||
.thenThrow(new DatastoreTimeoutException("Expected transient exception #2"))
|
||||
.thenReturn(expectedResponse);
|
||||
|
||||
action.whoisReader = mockReader;
|
||||
action.run();
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue