Skip to content

Commit

Permalink
improved dummy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Blazer-007 committed Jan 21, 2025
1 parent 089e2e0 commit e69a77e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
Expand Down Expand Up @@ -134,7 +133,6 @@ class YarnService extends AbstractIdleService {
private final Optional<GobblinMetrics> gobblinMetrics;
private final Optional<EventSubmitter> eventSubmitter;

@VisibleForTesting
@Getter(AccessLevel.PROTECTED)
private final AMRMClientAsync<AMRMClient.ContainerRequest> amrmClientAsync;
private final NMClientAsync nmClientAsync;
Expand Down Expand Up @@ -490,8 +488,7 @@ protected ByteBuffer getSecurityTokens() throws IOException {
}
}

@VisibleForTesting
protected String buildContainerCommand(Container container, String workerProfileName, WorkerProfile workerProfile) {
private String buildContainerCommand(Container container, String workerProfileName, WorkerProfile workerProfile) {
Config workerProfileConfig = workerProfile.getConfig();

double workerJvmMemoryXmxRatio = ConfigUtils.getDouble(workerProfileConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public List<ScalingDirective> getScalingDirectives() {
new ScalingDirective("firstProfile", 5, currentTime),
new ScalingDirective("secondProfile", 3, currentTime + 1)
);
} else if (currNumInvocations == 3) {
// changing set point to 0 for both profiles so that all containers should be released
return Arrays.asList(
new ScalingDirective("firstProfile", 0, currentTime),
new ScalingDirective("secondProfile", 0, currentTime + 1)
);
} else if (currNumInvocations == 4) {
// increasing containers count for both profiles so that new containers should be launched
return Arrays.asList(
new ScalingDirective("firstProfile", 5, currentTime),
new ScalingDirective("secondProfile", 5, currentTime + 1)
);
}
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public void testWhenScalingDirectivesIsNulOrEmpty() throws IOException, Interrup
/** Note : this test uses {@link DummyScalingDirectiveSource}*/
@Test
public void testWithDummyScalingDirectiveSource() throws IOException, InterruptedException {
// DummyScalingDirectiveSource returns 2 scaling directives in first 3 invocations and after that it returns empty list
// so the total number of invocations after three invocations should always be 3
// DummyScalingDirectiveSource returns 2 scaling directives in first 5 invocations and after that it returns empty list
// so the total number of invocations after three invocations should always be 5
TestDynamicScalingYarnServiceManager testDynamicScalingYarnServiceManager = new TestDynamicScalingYarnServiceManager(
mockGobblinTemporalApplicationMaster, new DummyScalingDirectiveSource());
testDynamicScalingYarnServiceManager.startUp();
Thread.sleep(5000); // 5 seconds sleep so that GetScalingDirectivesRunnable.run() is called for 5 times
Thread.sleep(7000); // 5 seconds sleep so that GetScalingDirectivesRunnable.run() is called for 7 times
testDynamicScalingYarnServiceManager.shutDown();
Mockito.verify(mockDynamicScalingYarnService, Mockito.times(3)).reviseWorkforcePlanAndRequestNewContainers(Mockito.anyList());
Mockito.verify(mockDynamicScalingYarnService, Mockito.times(5)).reviseWorkforcePlanAndRequestNewContainers(Mockito.anyList());
}

@Test
Expand Down

0 comments on commit e69a77e

Please sign in to comment.