mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Add SetNumInstancesCommand in Nomulus tool to adjust the number of instances
for a given service and version at runtime. Note that this CL only supports the adjustment for a given service and version. I will add another functionality to let this command be able to detect all non-live versions automatically and apply the adjustment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=221092001
This commit is contained in:
parent
557984bb75
commit
66d98c8d66
7 changed files with 216 additions and 0 deletions
|
@ -19,6 +19,8 @@ import static google.registry.testing.JUnitBackports.assertThrows;
|
|||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.appengine.api.modules.ModulesService;
|
||||
|
@ -75,4 +77,37 @@ public class AppEngineServiceUtilsImplTest {
|
|||
() -> appEngineServiceUtils.getVersionHostname("servicename", null));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Must specify the version");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_setNumInstances_worksWithValidParameters() {
|
||||
appEngineServiceUtils.setNumInstances("service", "version", 10L);
|
||||
verify(modulesService, times(1)).setNumInstances("service", "version", 10L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_setNumInstances_throwsWhenServiceIsNull() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> appEngineServiceUtils.setNumInstances(null, "version", 10L));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Must specify the service");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_setNumInstances_throwsWhenVersionIsNull() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> appEngineServiceUtils.setNumInstances("service", null, 10L));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Must specify the version");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_setNumInstances_throwsWhenNumInstancesIsInvalid() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> appEngineServiceUtils.setNumInstances("service", "version", -10L));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Number of instances must be greater than 0");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue