code
stringlengths 23
201k
| docstring
stringlengths 17
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
72
| path
stringlengths 11
317
| url
stringlengths 57
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
private ExecutableFlow createFlowWithMultipleJobtypes() throws Exception {
return TestUtils.createTestExecutableFlowFromYaml("embedded4", "valid_dag_2");
}
|
Test get execution id set from pod list
@throws Exception
|
createFlowWithMultipleJobtypes
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private static void setupImageTables() {
imageTypeDao = new ImageTypeDaoImpl(dbOperator);
imageVersionDao = new ImageVersionDaoImpl(dbOperator, imageTypeDao);
imageRampupDao = new ImageRampupDaoImpl(dbOperator, imageTypeDao, imageVersionDao);
// Create a mock of ImageRampupManager to get the image type and version map. This mock is
// required as the completed flow of getting image type and version can't be tested by
// populating image management table due non supported "UNSIGNED" integer in HSQL.
imageRampupManager = mock(ImageRampupManagerImpl.class);
imageTypeConverter = new ImageTypeConverter();
imageVersionConverter = new ImageVersionConverter();
imageRampupPlanConverter = new ImageRampupPlanConverter();
final ObjectMapper objectMapper = new ObjectMapper();
// Insert into all the below image tables is commented as in memory HSQL database does not
// support "UNSIGNED" data type. Some of the queries in ImageVersionDaoImpl.java uses
//"UNSIGNED" integer, all the insert entries are commented out and ImageRampupManager mock is
//create above to get the image type and version map.
/*addImageTypeTableEntry("image_type_hadoopJava.json", objectMapper);
addImageTypeTableEntry("image_type_command.json", objectMapper);
addImageTypeTableEntry("image_type_spark.json", objectMapper);
addImageVersions("image_types_active_versions.json", objectMapper);
addImageRampupEntries("create_image_rampup.json", objectMapper);*/
}
|
Test get execution id set from pod list
@throws Exception
|
setupImageTables
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private static void addImageTypeTableEntry(final String jsonFile,
final ObjectMapper objectMapper) {
final String jsonPayload = JSONUtils.readJsonFileAsString(TEST_JSON_DIR + "/" + jsonFile);
try {
final ImageTypeDTO imageType = objectMapper.readValue(jsonPayload, ImageTypeDTO.class);
imageType.setCreatedBy("azkaban");
imageType.setModifiedBy("azkaban");
imageTypeDao.createImageType(imageTypeConverter.convertToDataModel(imageType));
} catch (final Exception e) {
log.error("Failed to read from json file: " + jsonPayload);
assert (false);
}
}
|
Test get execution id set from pod list
@throws Exception
|
addImageTypeTableEntry
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private static void addImageVersions(final String jsonFile, final ObjectMapper objectMapper) {
final String jsonPayload = JSONUtils.readJsonFileAsString(TEST_JSON_DIR + "/" + jsonFile);
List<ImageVersionDTO> imageVersions = null;
try {
imageVersions = objectMapper.readValue(jsonPayload,
new TypeReference<List<ImageVersionDTO>>() {
});
log.info(String.valueOf(imageVersions));
for (final ImageVersionDTO imageVersion : imageVersions) {
imageVersion.setCreatedBy("azkaban");
imageVersion.setModifiedBy("azkaban");
imageVersionDao.createImageVersion(imageVersionConverter.convertToDataModel(imageVersion));
}
} catch (final IOException e) {
log.error("Exception while converting input json: ", e);
assert (false);
}
}
|
Test get execution id set from pod list
@throws Exception
|
addImageVersions
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private static void addImageRampupEntries(final String jsonFile,
final ObjectMapper objectMapper) {
final String jsonPayload = JSONUtils.readJsonFileAsString(TEST_JSON_DIR + "/" + jsonFile);
List<ImageRampupPlanRequestDTO> imageRampupPlanRequests = null;
try {
imageRampupPlanRequests = objectMapper.readValue(jsonPayload,
new TypeReference<List<ImageRampupPlanRequestDTO>>() {
});
for (final ImageRampupPlanRequestDTO imageRampupPlanRequest : imageRampupPlanRequests) {
imageRampupPlanRequest.setCreatedBy("azkaban");
imageRampupPlanRequest.setModifiedBy("azkaban");
imageRampupDao.createImageRampupPlan(
imageRampupPlanConverter.convertToDataModel(imageRampupPlanRequest));
}
} catch (final IOException e) {
log.error("Exception while converting input json: ", e);
assert (false);
}
}
|
Test get execution id set from pod list
@throws Exception
|
addImageRampupEntries
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private Map<String, VersionInfo> getVersionMap() {
final Map<String, VersionInfo> versionMap = new TreeMap<>();
versionMap.put(KubernetesContainerizedImpl.DEFAULT_AZKABAN_BASE_IMAGE_NAME,
new VersionInfo("7.0.4", "path1", State.ACTIVE));
versionMap.put(KubernetesContainerizedImpl.DEFAULT_AZKABAN_CONFIG_IMAGE_NAME,
new VersionInfo("9.1.1", "path2", State.ACTIVE));
versionMap.put("spark", new VersionInfo("8.0", "path3", State.ACTIVE));
versionMap.put("kafkaPush", new VersionInfo("7.1", "path4", State.ACTIVE));
versionMap.put(DEPENDENCY1, new VersionInfo("6.4", "path5", State.ACTIVE));
return versionMap;
}
|
Creates a version map, which contains key value pairs of image name and corresponding version
number
@return a version set map
|
getVersionMap
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
private Injector getInjector(final Props props) {
props.put(AZKABAN_EVENT_REPORTING_ENABLED, "true");
props.put(AZKABAN_EVENT_REPORTING_CLASS_PARAM,
"azkaban.project.AzkabanEventReporterTest");
props.put("database.type", "h2");
props.put("h2.path", "h2");
return Guice.createInjector(new AzkabanCommonModule(props));
}
|
Creates a Guice injector for Azkaban event reporter instantiation
@param props
@return
|
getInjector
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/KubernetesContainerizedImplTest.java
|
Apache-2.0
|
@Before
public void setUp() throws Exception {
this.defaultApiClient = Config.defaultClient();
ExecutionControllerUtils.onExecutionEventListener = onExecutionEventListener;
final FlowResourceRecommendation flowResourceRecommendation = new FlowResourceRecommendation(1, project.getId(),
DEFAULT_FLOW_NAME, "1", DEFAULT_FLOW_MEMORY_RECOMMENDATION, "20Gi");
final ConcurrentHashMap<String, FlowResourceRecommendation> flowResourceRecommendationMap =
new ConcurrentHashMap<>();
flowResourceRecommendationMap.put(flowResourceRecommendation.getFlowId(),
flowResourceRecommendation);
when(project.getFlowResourceRecommendationMap()).thenReturn(flowResourceRecommendationMap);
when(project.getFlow(any())).thenReturn(flow);
when(projectManager.getProject(anyInt())).thenReturn(project);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
setUp
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private KubernetesWatch kubernetesWatchWithMockListener() {
Props azkProps = localProperties();
ApiClient localApiClient = WatchUtils.createApiClient(azkProps);
return new KubernetesWatch(azkProps, localApiClient, new AzPodStausExtractingListener(),
WatchUtils.createPodWatchParams(azkProps)
);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
kubernetesWatchWithMockListener
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private Props localProperties() {
Props props = new Props();
props.put(ContainerizedDispatchManagerProperties.KUBERNETES_NAMESPACE, DEFAULT_NAMESPACE);
props.put(ConfigurationKeys.AZKABAN_CLUSTER_NAME, DEFAULT_CLUSTER);
props.put(ContainerizedDispatchManagerProperties.KUBERNETES_KUBE_CONFIG_PATH,
LOCAL_KUBE_CONFIG_PATH);
return props;
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
localProperties
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private StatusLoggingListener statusLoggingListener() {
return new StatusLoggingListener();
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
statusLoggingListener
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private ExecutorLoader mockedExecutorLoader() {
return mock(ExecutorLoader.class);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
mockedExecutorLoader
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private ContainerizedImpl mockedContainerizedImpl() {
return mock(ContainerizedImpl.class);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
mockedContainerizedImpl
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private ExecutableFlow createExecutableFlow(int executionId,
azkaban.executor.Status flowStatus,
String flowName,
String projectName) throws Exception {
ExecutableFlow flow = TestUtils.createTestExecutableFlow(projectName, flowName,
DispatchMethod.CONTAINERIZED);
flow.setExecutionId(executionId);
flow.setStatus(flowStatus);
return flow;
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
createExecutableFlow
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private ExecutableFlow createExecutableFlow(int executionId,
azkaban.executor.Status flowStatus) throws Exception {
return createExecutableFlow(executionId, flowStatus, DEFAULT_FLOW_FILE_NAME, DEFAULT_PROJECT_NAME);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
createExecutableFlow
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private FlowStatusManagerListener flowStatusUpdatingListener(Props azkProps) {
return new FlowStatusManagerListener(azkProps, projectManager, mockedContainerizedImpl(),
mockedExecutorLoader(), mock(AlerterHolder.class), containerizationMetrics, eventListener);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
flowStatusUpdatingListener
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private AzPodStatusDrivingListener statusDriverWithListener(AzPodStatusListener listener) {
AzPodStatusDrivingListener azPodStatusDriver = new AzPodStatusDrivingListener(new Props());
azPodStatusDriver.registerAzPodStatusListener(listener);
return azPodStatusDriver;
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
statusDriverWithListener
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private Watch<V1Pod> fileBackedWatch(ApiClient apiClient) throws IOException {
FileBackedWatch<V1Pod> fileBackedWatch = new FileBackedWatch<>(
apiClient.getJSON(),
new TypeToken<Response<V1Pod>>() {}.getType(),
Paths.get(JSON_EVENTS_FILE_PATH));
return fileBackedWatch;
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
fileBackedWatch
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private PreInitializedWatch defaultPreInitializedWatch(RawPodWatchEventListener driver,
Watch<V1Pod> podWatch,
int maxInitCount) throws IOException {
return new PreInitializedWatch(this.defaultApiClient,
driver,
podWatch,
new PodWatchParams(null, null, DEFAULT_WATCH_RESET_DELAY_MILLIS),
maxInitCount);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
defaultPreInitializedWatch
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Ignore("Flaky Test Blocking deployment, succeeds locally")
@Test
public void testWatchShutdownAndResetAfterFailure() throws Exception {
AzPodStatusDrivingListener statusDriver = statusDriverWithListener(statusLoggingListener());
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
// FileBackedWatch with throw an IOException at read once the end of file has been reached.
// PreInitWatch will auto-shutdown after the max_init_count resets.
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Max watch init count should be less than or equal to the actual init count. Actual init
// count can be larger by 1 as it may take upto 1 reset cycle for the shutdown request to be
// evaluated.
Assert.assertTrue(DEFAULT_MAX_INIT_COUNT <= kubernetesWatch.getInitWatchCount());
Assert.assertTrue(DEFAULT_MAX_INIT_COUNT <= kubernetesWatch.getStartWatchCount());
statusDriver.shutdown();
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testWatchShutdownAndResetAfterFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private void assertPodEventSequence(String podName,
StatusLoggingListener loggingListener,
List<AzPodStatus> transitionSequence) {
// Record any information from the in-memory log of events.
ConcurrentMap<String, Queue<AzPodStatus>> statusLogMap = loggingListener.getStatusLogMap();
StatusLoggingListener.logDebugStatusMap(statusLogMap);
// Verify the sequence of events received for the flow-pod {@link POD_WITH_LIFECYCLE_SUCCESS}
// matches the expected sequence of statuses.
List<AzPodStatus> actualLifecycleStates =
statusLogMap.get(podName).stream()
.distinct().collect(Collectors.toList());
Assert.assertEquals(transitionSequence, actualLifecycleStates);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
assertPodEventSequence
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testPodEventSequenceSuccess() throws Exception {
StatusLoggingListener loggingListener = statusLoggingListener();
AzPodStatusDrivingListener statusDriver = statusDriverWithListener(loggingListener);
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
assertPodEventSequence(PODNAME_WITH_SUCCESS, loggingListener, TRANSITION_SEQUENCE_WITH_SUCCESS);
statusDriver.shutdown();
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testPodEventSequenceSuccess
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFlowStatusManagerListenerTransitionCompleted() throws Exception {
// Setup a FlowUpdatingListener
Props azkProps = new Props();
FlowStatusManagerListener updatingListener = flowStatusUpdatingListener(azkProps);
// Add a StatusLoggingListener for sanity check the events sequence. This also validates
// support for registering multiple listeners.
StatusLoggingListener loggingListener = statusLoggingListener();
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(loggingListener);
statusDriver.registerAzPodStatusListener(updatingListener);
// Mocked flow in RUNNING state. Pod completion event will be processed for this execution.
ExecutableFlow flow1 = createExecutableFlow(EXECUTION_ID_WITH_SUCCEESS, Status.RUNNING);
when(updatingListener.getExecutorLoader().fetchExecutableFlow(EXECUTION_ID_WITH_SUCCEESS))
.thenReturn(flow1);
// Run all the events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify that the previously RUNNING flow has been finalized to a failure state.
verify(updatingListener.getExecutorLoader()).updateExecutableFlow(flow1);
assertFlowExecutionStopped(flow1);
// Verify the Pod deletion API is invoked.
verify(updatingListener.getContainerizedImpl()).deleteContainer(EXECUTION_ID_WITH_SUCCEESS);
// Sanity check for asserting the sequence in which events were received.
assertPodEventSequence(PODNAME_WITH_SUCCESS, loggingListener, TRANSITION_SEQUENCE_WITH_SUCCESS);
// Verify that flow resource recommendation is not doubled
Assert.assertEquals(project.getFlowResourceRecommendationMap().get(DEFAULT_FLOW_NAME).getMemoryRecommendation(), DEFAULT_FLOW_MEMORY_RECOMMENDATION);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testFlowStatusManagerListenerTransitionCompleted
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFlowManagerListenerInitContainerFailure() throws Exception {
// Setup a FlowUpdatingListener
Props azkProps = new Props();
FlowStatusManagerListener updatingListener = flowStatusUpdatingListener(azkProps);
// Verify EXECUTION_STOPPED flow life cycle event is emitted
assertExecutionStoppedFlowEvent(updatingListener);
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(updatingListener);
// Mocked flow in RUNNING state. Init failure event will be processed for this execution.
ExecutableFlow flow1 = createExecutableFlow(EXECUTION_ID_WITH_INIT_FAILURE, Status.PREPARING);
// set flow parameter to allow restart from EXECUTION_STOPPED
final ExecutionOptions options = flow1.getExecutionOptions();
options.addAllFlowParameters(flowParam);
flow1.setExecutionOptions(options);
when(updatingListener.getExecutorLoader().fetchExecutableFlow(EXECUTION_ID_WITH_INIT_FAILURE))
.thenReturn(flow1);
// Run events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify that the previously RUNNING flow has been finalized to a failure state.
verify(updatingListener.getExecutorLoader()).updateExecutableFlow(flow1);
assertFlowExecutionStopped(flow1);
// Verify the Pod deletion API is invoked.
verify(updatingListener.getContainerizedImpl()).deleteContainer(EXECUTION_ID_WITH_INIT_FAILURE);
// Verify that the flow is restarted.
verify(onExecutionEventListener).onExecutionEvent(flow1, Constants.RESTART_FLOW);
// Verify that flow resource recommendation is not doubled
Assert.assertEquals(project.getFlowResourceRecommendationMap().get(DEFAULT_FLOW_NAME).getMemoryRecommendation(), DEFAULT_FLOW_MEMORY_RECOMMENDATION);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testFlowManagerListenerInitContainerFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFlowManagerListenerCreateContainerError() throws Exception {
// Setup a FlowUpdatingListener
Props azkProps = new Props();
FlowStatusManagerListener updatingListener = flowStatusUpdatingListener(azkProps);
// Verify EXECUTION_STOPPED flow life cycle event is emitted
assertExecutionStoppedFlowEvent(updatingListener);
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(updatingListener);
// Mocked flow in DISPATCHING state. CreateContainerError event will be processed for this
// execution. The extracted AzPodStatus will be AZ_POD_APP_FAILURE.
ExecutableFlow flow1 = createExecutableFlow(EXECUTION_ID_WITH_CREATE_CONTAINER_ERROR,
Status.DISPATCHING);
// set flow parameter to allow restart from EXECUTION_STOPPED
final ExecutionOptions options = flow1.getExecutionOptions();
options.addAllFlowParameters(flowParam);
flow1.setExecutionOptions(options);
when(updatingListener.getExecutorLoader()
.fetchExecutableFlow(EXECUTION_ID_WITH_CREATE_CONTAINER_ERROR))
.thenReturn(flow1);
// Run events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify that the previously DISPATCHING flow has been finalized to a failure state.
verify(updatingListener.getExecutorLoader()).updateExecutableFlow(flow1);
assertFlowExecutionStopped(flow1);
// Verify the Pod deletion API is invoked.
verify(updatingListener.getContainerizedImpl())
.deleteContainer(EXECUTION_ID_WITH_CREATE_CONTAINER_ERROR);
// Verify that the flow is restarted.
verify(onExecutionEventListener).onExecutionEvent(flow1, Constants.RESTART_FLOW);
// Verify that flow resource recommendation is not doubled
Assert.assertEquals(project.getFlowResourceRecommendationMap().get(DEFAULT_FLOW_NAME).getMemoryRecommendation(), DEFAULT_FLOW_MEMORY_RECOMMENDATION);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testFlowManagerListenerCreateContainerError
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFlowManagerListenerOOMKilled() throws Exception {
// Setup a FlowUpdatingListener
Props azkProps = new Props();
FlowStatusManagerListener updatingListener = flowStatusUpdatingListener(azkProps);
// Verify EXECUTION_STOPPED flow life cycle event is emitted
assertExecutionStoppedFlowEvent(updatingListener);
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(updatingListener);
// Mocked flow in RUNNING state. OOMKilled event will be processed for this
// execution. The extracted AzPodStatus will be AZ_POD_APP_FAILURE.
ExecutableFlow flow1 = createExecutableFlow(EXECUTION_ID_WITH_OOM_KILLED,
Status.RUNNING);
// set flow parameter to allow restart from EXECUTION_STOPPED
final ExecutionOptions options = flow1.getExecutionOptions();
options.addAllFlowParameters(flowParam);
flow1.setExecutionOptions(options);
when(updatingListener.getExecutorLoader()
.fetchExecutableFlow(EXECUTION_ID_WITH_OOM_KILLED))
.thenReturn(flow1);
// Run events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify that the previously DISPATCHING flow has been finalized to a failure state.
verify(updatingListener.getExecutorLoader()).updateExecutableFlow(flow1);
assertFlowExecutionStopped(flow1);
// Verify the Pod deletion API is invoked.
verify(updatingListener.getContainerizedImpl())
.deleteContainer(EXECUTION_ID_WITH_OOM_KILLED);
// Verify that the flow is restarted.
verify(onExecutionEventListener).onExecutionEvent(flow1, Constants.RESTART_FLOW);
// Verify that flow resource recommendation is doubled
Assert.assertEquals(project.getFlowResourceRecommendationMap().get(DEFAULT_FLOW_NAME).getMemoryRecommendation(), EXPECTED_DOUBLED_FLOW_MEMORY_RECOMMENDATION);
verify(projectManager, Mockito.times(1)).updateFlowResourceRecommendation(any());
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testFlowManagerListenerOOMKilled
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testContainerStatusMetricsListener() throws Exception {
// Setup a ContainerStatusMetricsHandlerListener
Props azkProps = new Props();
AzPodStatusMetricsListener recordHandlerListener =
new AzPodStatusMetricsListener(new DummyContainerizationMetricsImpl());
// Register ContainerStatusMetricsHandlerListener
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(recordHandlerListener);
// Run all the events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify pod statuses are handled by ContainerStatusMetricsHandlerListener to emit status
//metrics. In total there are 15 events, of which some Scheduled and InitContainersRunning are
//duplicated event statuses.
assertThat(recordHandlerListener.getPodRequestedCounter()).isEqualTo(2);
assertThat(recordHandlerListener.getPodScheduledCounter()).isEqualTo(3);
assertThat(recordHandlerListener.getPodInitContainersRunningCounter()).isEqualTo(2);
assertThat(recordHandlerListener.getPodAppContainersStartingCounter()).isEqualTo(2);
assertThat(recordHandlerListener.getPodReadyCounter()).isEqualTo(1);
assertThat(recordHandlerListener.getPodCompletedCounter()).isEqualTo(1);
assertThat(recordHandlerListener.getPodInitFailureCounter()).isEqualTo(1);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testContainerStatusMetricsListener
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFlowManagerListenerInvalidTransition() throws Exception {
// Setup a FlowUpdatingListener
Props azkProps = new Props();
FlowStatusManagerListener updatingListener = flowStatusUpdatingListener(azkProps);
// Verify EXECUTION_STOPPED flow life cycle event is emitted
assertExecutionStoppedFlowEvent(updatingListener);
AzPodStatusDrivingListener statusDriver = new AzPodStatusDrivingListener(azkProps);
statusDriver.registerAzPodStatusListener(updatingListener);
// Mocked flow in RUNNING state.
ExecutableFlow flow1 = TestUtils.createTestExecutableFlowFromYaml("embeddedflowyamltest",
"embedded_flow");
flow1.setExecutionId(EXECUTION_ID_WITH_INVALID_TRANSITIONS);
flow1.setStatus(Status.RUNNING);
// set flow parameter to allow restart from EXECUTION_STOPPED
final ExecutionOptions options = flow1.getExecutionOptions();
options.addAllFlowParameters(flowParam);
flow1.setExecutionOptions(options);
when(updatingListener.getExecutorLoader().fetchExecutableFlow(EXECUTION_ID_WITH_INVALID_TRANSITIONS))
.thenReturn(flow1);
// Process events through the registered listeners.
Watch<V1Pod> fileBackedWatch = fileBackedWatch(Config.defaultClient());
PreInitializedWatch kubernetesWatch = defaultPreInitializedWatch(statusDriver, fileBackedWatch,
DEFAULT_MAX_INIT_COUNT);
kubernetesWatch.launchPodWatch().join(DEFAULT_WATCH_COMPLETION_TIMEOUT_MILLIS);
// Verify that the previously RUNNING flow has been finalized to a terminal state, and sub
// nodes set to terminal state, too.
verify(updatingListener.getExecutorLoader()).updateExecutableFlow(flow1);
assertFlowExecutionStopped(flow1);
// Verify the Pod deletion API is invoked.
verify(updatingListener.getContainerizedImpl()).deleteContainer(EXECUTION_ID_WITH_INVALID_TRANSITIONS);
// Verify that the flow is restarted.
verify(onExecutionEventListener).onExecutionEvent(flow1, Constants.RESTART_FLOW);
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testFlowManagerListenerInvalidTransition
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private void assertExecutionStoppedFlowEvent(final FlowStatusManagerListener updatingListener) {
updatingListener.addListener((event) -> {
Event flowEvent = (Event) event;
if (flowEvent.getType().isFlowEventType()) {
Assert.assertEquals(EventType.FLOW_FINISHED, flowEvent.getType());
Assert.assertEquals(Status.EXECUTION_STOPPED, flowEvent.getData().getStatus());
}
});
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
assertExecutionStoppedFlowEvent
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private void assertFlowExecutionStopped(final ExecutableFlow flow) {
final Queue<ExecutableNode> queue = new LinkedList<>();
queue.add(flow);
// traverse through every node in flow1
while(!queue.isEmpty()) {
ExecutableNode node = queue.poll();
if (node==flow) {
assertThat(node.getStatus()).isEqualTo(Status.EXECUTION_STOPPED);
} else {
assertThat(node.getStatus()).isEqualTo(Status.KILLED);
}
if (node instanceof ExecutableFlowBase) {
final ExecutableFlowBase base = (ExecutableFlowBase) node;
for (final ExecutableNode subNode : base.getExecutableNodes()) {
queue.add(subNode);
}
}
}
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
assertFlowExecutionStopped
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
@Ignore("Blocking watch execution, useful only for development")
public void testBlockingPodWatch() throws Exception {
// Runs an unmodified instance of the watch that logs Raw watch events with debug verbosity.
KubernetesWatch kubernetesWatch = kubernetesWatchWithMockListener();
kubernetesWatch.launchPodWatch().join();
}
|
These constants refer to kubernetes objects with the mock events file at
{@code JSON_EVENTS_FILEP_PATH}.
|
testBlockingPodWatch
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
protected void initializePodWatch() {
this.setPodWatch(this.preInitPodWatch);
if (this.initWatchCount >= this.maxInitCount) {
logger.debug("Requesting shutdowns as max init count was reached, init-count: " + this.initWatchCount);
this.requestShutdown();
}
this.initWatchCount++;
}
|
An extension to {@link KubernetesWatch} which requires the underlying {@link Watch<V1Pod>}
provider to be pre-initialized. This is the case for the {@link FileBackedWatch}, for
example. This also disables watch initialization in the parent class and additionally maintains
counters for how may times the watch initialization and startup routines were invoked.
|
initializePodWatch
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
protected void startPodWatch() throws IOException {
this.startWatchCount++;
super.startPodWatch();
}
|
An extension to {@link KubernetesWatch} which requires the underlying {@link Watch<V1Pod>}
provider to be pre-initialized. This is the case for the {@link FileBackedWatch}, for
example. This also disables watch initialization in the parent class and additionally maintains
counters for how may times the watch initialization and startup routines were invoked.
|
startPodWatch
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getMaxInitCount() {
return this.maxInitCount;
}
|
An extension to {@link KubernetesWatch} which requires the underlying {@link Watch<V1Pod>}
provider to be pre-initialized. This is the case for the {@link FileBackedWatch}, for
example. This also disables watch initialization in the parent class and additionally maintains
counters for how may times the watch initialization and startup routines were invoked.
|
getMaxInitCount
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getInitWatchCount() {
return this.initWatchCount;
}
|
An extension to {@link KubernetesWatch} which requires the underlying {@link Watch<V1Pod>}
provider to be pre-initialized. This is the case for the {@link FileBackedWatch}, for
example. This also disables watch initialization in the parent class and additionally maintains
counters for how may times the watch initialization and startup routines were invoked.
|
getInitWatchCount
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getStartWatchCount() {
return this.startWatchCount;
}
|
An extension to {@link KubernetesWatch} which requires the underlying {@link Watch<V1Pod>}
provider to be pre-initialized. This is the case for the {@link FileBackedWatch}, for
example. This also disables watch initialization in the parent class and additionally maintains
counters for how may times the watch initialization and startup routines were invoked.
|
getStartWatchCount
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public Response<T> next() {
try {
String line = this.reader.readLine();
if (line == null) {
throw new RuntimeException("Line is null");
}
return parseLine(line);
} catch (IOException e) {
throw new RuntimeException("IO Exception during next method.", e);
}
}
|
For providing watch events from a file, instead of the kubernetes API server.
This serves 2 main purposes:
(1) Extension of {@link Watch<T>} and can be used as a drop-in replacement within
{@link KubernetesWatch}
(2) Has the ability to parse JSON objects and convert them to {@link Watch<T>} events
which are identical to the events received directly from the ApiServer.
@param <T>
|
next
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public boolean hasNext() {
try {
return this.reader.ready();
} catch (IOException e) {
throw new RuntimeException("Exception in hasNext.", e);
}
}
|
For providing watch events from a file, instead of the kubernetes API server.
This serves 2 main purposes:
(1) Extension of {@link Watch<T>} and can be used as a drop-in replacement within
{@link KubernetesWatch}
(2) Has the ability to parse JSON objects and convert them to {@link Watch<T>} events
which are identical to the events received directly from the ApiServer.
@param <T>
|
hasNext
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void close() throws IOException {
if (this.reader != null) {
this.reader.close();
}
}
|
For providing watch events from a file, instead of the kubernetes API server.
This serves 2 main purposes:
(1) Extension of {@link Watch<T>} and can be used as a drop-in replacement within
{@link KubernetesWatch}
(2) Has the ability to parse JSON objects and convert them to {@link Watch<T>} events
which are identical to the events received directly from the ApiServer.
@param <T>
|
close
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public static void logDebugStatusMap(ConcurrentMap<String, Queue<AzPodStatus>> statusLogMap) {
requireNonNull(statusLogMap, "status log map must not be null");
statusLogMap.forEach((podname, queue) -> {
StringBuilder sb = new StringBuilder(podname + ": ");
queue.forEach(status -> sb.append(status.toString() + ", "));
logger.debug(sb.toString());
});
}
|
Print the event log at debug verbosity.
@param statusLogMap
|
logDebugStatusMap
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
private void logStatusForPod(AzPodStatusMetadata event) {
requireNonNull(event, "event must not be null");
AzPodStatus podStatus = event.getAzPodStatus();
String podName = event.getPodName();
Queue<AzPodStatus> statusLog = this.statusLogMap.computeIfAbsent(
podName, k -> new ConcurrentLinkedQueue<>());
statusLog.add(podStatus);
}
|
Log status for the given event.
@param event
|
logStatusForPod
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public ConcurrentMap<String, Queue<AzPodStatus>> getStatusLogMap() {
return this.statusLogMap;
}
|
Log status for the given event.
@param event
|
getStatusLogMap
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodRequested(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodRequested
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodScheduled(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodScheduled
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodInitContainersRunning(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodInitContainersRunning
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodAppContainersStarting(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodAppContainersStarting
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodReady(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodReady
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodCompleted(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodCompleted
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodInitFailure(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodInitFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodAppFailure(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodAppFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodUnexpected(AzPodStatusMetadata event) {
logStatusForPod(event);
}
|
Log status for the given event.
@param event
|
onPodUnexpected
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onEvent(Response<V1Pod> watchEvent) {
logger.debug(String.format("%s : %s, %s, %s", watchEvent.type, watchEvent.object.getMetadata().getName(),
watchEvent.object.getStatus().getMessage(), watchEvent.object.getStatus().getPhase()));
AzPodStatus azPodStatus = AzPodStatusExtractor.getAzPodStatusFromEvent(watchEvent).getAzPodStatus();
logger.debug("AZ_POD_STATUS: " + azPodStatus);
}
|
An implementation of {@link @RawPodWatchListener} that extracts the {@link AzPodStatus} for
each pod watch event.
|
onEvent
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodRequested(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podRequestedCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodRequested
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodScheduled(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podScheduledCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodScheduled
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodInitContainersRunning(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podInitContainersRunningCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodInitContainersRunning
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodAppContainersStarting(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
PodAppContainersStartingCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodAppContainersStarting
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodReady(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podReadyCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodReady
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodCompleted(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podCompletedCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodCompleted
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodInitFailure(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podInitFailureCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodInitFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public synchronized void onPodAppFailure(final AzPodStatusMetadata event) {
if (!event.getFlowPodMetadata().isPresent() || isUpdatedPodStatusDistinct(event)) {
podAppFailureCounter++;
updatePodStatus(event);
}
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodAppFailure
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Override
public void onPodUnexpected(AzPodStatusMetadata event) {
super.onPodUnexpected(event);
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
onPodUnexpected
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodRequestedCounter() {
return podRequestedCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodRequestedCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodInitContainersRunningCounter() {
return podInitContainersRunningCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodInitContainersRunningCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodAppContainersStartingCounter() {
return PodAppContainersStartingCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodAppContainersStartingCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodReadyCounter() {
return podReadyCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodReadyCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodCompletedCounter() {
return podCompletedCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodCompletedCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodInitFailureCounter() {
return podInitFailureCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodInitFailureCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
public int getPodAppFailureCounter() {
return podAppFailureCounter;
}
|
A class extends {@link ContainerStatusMetricsListener} that can be tested for metrics
updating
|
getPodAppFailureCounter
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/executor/container/watch/KubernetesWatchTest.java
|
Apache-2.0
|
@Test
public void testFetchVersionByImageTypesCase1() throws Exception {
final String jsonInput = JSONUtils.readJsonFileAsString("image_management/image_type_rampups"
+ ".json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonInput);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management"
+ "/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
final Set<String> imageTypes = new TreeSet<>();
imageTypes.add("spark_job");
imageTypes.add("hive_job");
imageTypes.add("azkaban_core");
imageTypes.add("azkaban_config");
imageTypes.add("azkaban_exec");
when(this.imageRampupDao.getRampupByImageTypes(any(Set.class))).thenReturn(imageTypeRampups);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
// Assert the for a flow, versions are always deterministic and remain the same
final ExecutableFlow flow = TestUtils
.createTestExecutableFlow("exectest1", "exec1", DispatchMethod.CONTAINERIZED);
Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionByImageTypes(flow, imageTypes, new HashSet<>());
Assert.assertEquals("3.6.5", imageTypeVersionMap.get("azkaban_config").getVersion());
Assert.assertEquals("3.6.2", imageTypeVersionMap.get("azkaban_core").getVersion());
Assert.assertEquals("1.8.2", imageTypeVersionMap.get("azkaban_exec").getVersion());
Assert.assertEquals("2.1.3", imageTypeVersionMap.get("hive_job").getVersion());
Assert.assertEquals("1.1.2", imageTypeVersionMap.get("spark_job").getVersion());
}
|
The test is for getting the specified image type version from the the active rampups.
@throws Exception
|
testFetchVersionByImageTypesCase1
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test
public void testFetchVersionByImageTypesCase2() throws Exception {
final String jsonImageTypeRampups = JSONUtils.readJsonFileAsString("image_management/"
+ "image_type_rampups.json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonImageTypeRampups);
final Set<String> imageTypes = new TreeSet<>();
imageTypes.add("spark_job");
imageTypes.add("hive_job");
imageTypes.add("azkaban_core");
imageTypes.add("azkaban_config");
imageTypes.add("azkaban_exec");
imageTypes.add("pig_job");
imageTypes.add("hadoop_job");
final String jsonImageTypeActiveVersion = JSONUtils.readJsonFileAsString("image_management"
+ "/all_image_types_active_version.json");
final List<ImageVersionDTO> activeImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeActiveVersion, ImageVersionDTO.class);
final List<ImageVersion> activeImageVersions =
this.imageVersionConverter.convertToDataModels(activeImageVersionDTOs);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management"
+ "/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
when(this.imageRampupDao.getRampupByImageTypes(any(Set.class))).thenReturn(imageTypeRampups);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
when(this.imageVersionDao.getActiveVersionByImageTypes(any(Set.class)))
.thenReturn(activeImageVersions);
final Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionByImageTypes(null, imageTypes, new HashSet<>());
Assert.assertNotNull(imageTypeVersionMap);
// Below image type versions are obtained from active ramp up. Version is selected randomly
// based on rampup percentage.
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_config"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_core"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_exec"));
Assert.assertNotNull(imageTypeVersionMap.get("hive_job"));
Assert.assertNotNull(imageTypeVersionMap.get("spark_job"));
// Below two image types are from based on active image version
Assert.assertNotNull(imageTypeVersionMap.get("pig_job"));
Assert.assertEquals("4.1.2", imageTypeVersionMap.get("pig_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("hadoop_job"));
Assert.assertEquals("5.1.5", imageTypeVersionMap.get("hadoop_job").getVersion());
}
|
This test is for getting the specified image types version from rampup as well as based on
active image version. The image types for which active rampup is present get the version from
rampups. For the remaining images it get the latest active version from image versions.
@throws Exception
|
testFetchVersionByImageTypesCase2
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test(expected = ImageMgmtException.class)
public void testFetchVersionByImageTypesFailureCase() throws Exception {
final String jsonImageTypeRampups = JSONUtils.readJsonFileAsString("image_management/"
+ "image_type_rampups.json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonImageTypeRampups);
final Set<String> imageTypes = new TreeSet<>();
imageTypes.add("spark_job");
imageTypes.add("hive_job");
imageTypes.add("azkaban_core");
imageTypes.add("azkaban_config");
imageTypes.add("azkaban_exec");
imageTypes.add("pig_job");
imageTypes.add("hadoop_job");
imageTypes.add("kabootar_job");
imageTypes.add("wormhole_job");
final String jsonImageTypeActiveVersion = JSONUtils.readJsonFileAsString("image_management"
+ "/image_type_active_version.json");
final List<ImageVersionDTO> activeImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeActiveVersion, ImageVersionDTO.class);
final List<ImageVersion> activeImageVersions =
this.imageVersionConverter.convertToDataModels(activeImageVersionDTOs);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management"
+ "/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
when(this.imageRampupDao.getRampupByImageTypes(any(Set.class))).thenReturn(imageTypeRampups);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
when(this.imageVersionDao.getActiveVersionByImageTypes(any(Set.class)))
.thenReturn(activeImageVersions);
final Set<String> overlaySet = new HashSet<>();
overlaySet.add("kabootar_job");
final Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionByImageTypes(null, imageTypes, new HashSet<>());
Assert.assertNotNull(imageTypeVersionMap);
// Below image type versions are obtained from active ramp up. Version is selected randomly
// based on rampup percentage.
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_config"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_core"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_exec"));
Assert.assertNotNull(imageTypeVersionMap.get("hive_job"));
Assert.assertNotNull(imageTypeVersionMap.get("spark_job"));
Assert.assertNotNull(imageTypeVersionMap.get("pig_job"));
// Below two image types are from based on active image version
Assert.assertEquals("4.1.2", imageTypeVersionMap.get("pig_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("hadoop_job"));
Assert.assertEquals("5.1.5", imageTypeVersionMap.get("hadoop_job").getVersion());
}
|
For the given image types some of the versions are from active rampups, some of the versions
are based on active image version. But there are some image types for which there is neither
active rampups nor active image version, hence throws exception.
@throws Exception
|
testFetchVersionByImageTypesFailureCase
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test
public void testFetchAllImageTypesVersion() throws Exception {
final String jsonImageTypeRampups = JSONUtils.readJsonFileAsString("image_management/"
+ "image_type_rampups.json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonImageTypeRampups);
final String jsonAllImageTypes = JSONUtils.readJsonFileAsString("image_management/"
+ "all_image_types.json");
final List<ImageTypeDTO> allImageTypeDTOs = converterUtils.convertToDTOs(jsonAllImageTypes,
ImageTypeDTO.class);
final List<ImageType> allImageTypes =
this.imageTypeConverter.convertToDataModels(allImageTypeDTOs);
final String jsonImageTypeActiveVersion = JSONUtils.readJsonFileAsString("image_management"
+ "/all_image_types_active_version.json");
final List<ImageVersionDTO> activeImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeActiveVersion, ImageVersionDTO.class);
final List<ImageVersion> activeImageVersions =
this.imageVersionConverter.convertToDataModels(activeImageVersionDTOs);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management"
+ "/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
when(this.imageRampupDao.getRampupForAllImageTypes()).thenReturn(imageTypeRampups);
when(this.imageTypeDao.getAllImageTypes()).thenReturn(allImageTypes);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
when(this.imageVersionDao.getActiveVersionByImageTypes(any(Set.class)))
.thenReturn(activeImageVersions);
final Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionForAllImageTypes(null);
Assert.assertNotNull(imageTypeVersionMap);
// Below image type versions are obtained from latest active version.
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_config"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_core"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_exec"));
Assert.assertNotNull(imageTypeVersionMap.get("hive_job"));
Assert.assertNotNull(imageTypeVersionMap.get("spark_job"));
Assert.assertEquals("3.6.7", imageTypeVersionMap.get("azkaban_config").getVersion());
Assert.assertEquals("3.6.3", imageTypeVersionMap.get("azkaban_core").getVersion());
Assert.assertEquals("1.8.3", imageTypeVersionMap.get("azkaban_exec").getVersion());
Assert.assertEquals("2.1.4", imageTypeVersionMap.get("hive_job").getVersion());
Assert.assertEquals("1.1.3", imageTypeVersionMap.get("spark_job").getVersion());
// Below two image types are from based on active image version
Assert.assertNotNull(imageTypeVersionMap.get("pig_job"));
Assert.assertEquals("4.1.2", imageTypeVersionMap.get("pig_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("hadoop_job"));
Assert.assertEquals("5.1.5", imageTypeVersionMap.get("hadoop_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("kafka_push_job"));
Assert.assertEquals("3.1.2", imageTypeVersionMap.get("kafka_push_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("wormhole_job"));
Assert.assertEquals("1.1.8", imageTypeVersionMap.get("wormhole_job").getVersion());
Assert.assertNotNull(imageTypeVersionMap.get("kabootar_job"));
Assert.assertEquals("1.1.4", imageTypeVersionMap.get("kabootar_job").getVersion());
}
|
This test is a success test for getting version for all the available image types. The versions
are from active image version.
@throws Exception
|
testFetchAllImageTypesVersion
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test(expected = ImageMgmtException.class)
public void testFetchAllImageTypesVersionFailureCase() throws Exception {
final String jsonImageTypeRampups = JSONUtils.readJsonFileAsString("image_management/"
+ "image_type_rampups.json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonImageTypeRampups);
final String jsonAllImageTypes = JSONUtils.readJsonFileAsString("image_management/"
+ "all_image_types.json");
final List<ImageTypeDTO> allImageTypeDTOs = converterUtils.convertToDTOs(jsonAllImageTypes,
ImageTypeDTO.class);
final List<ImageType> allImageTypes =
this.imageTypeConverter.convertToDataModels(allImageTypeDTOs);
final String jsonImageTypeActiveVersion = JSONUtils.readJsonFileAsString("image_management"
+ "/image_type_active_version.json");
final List<ImageVersionDTO> activeImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeActiveVersion, ImageVersionDTO.class);
final List<ImageVersion> activeImageVersions =
this.imageVersionConverter.convertToDataModels(activeImageVersionDTOs);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management"
+ "/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
when(this.imageRampupDao.getRampupForAllImageTypes()).thenReturn(imageTypeRampups);
when(this.imageTypeDao.getAllImageTypes()).thenReturn(allImageTypes);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
when(this.imageVersionDao.getActiveVersionByImageTypes(any(Set.class)))
.thenReturn(activeImageVersions);
final ExecutableFlow flow = TestUtils
.createTestExecutableFlow("exectest1", "exec1", DispatchMethod.CONTAINERIZED);
final Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionForAllImageTypes(flow);
Assert.assertNotNull(imageTypeVersionMap);
// Below image type versions are obtained from active ramp up. Version is selected randomly
// based on rampup percentage.
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_config"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_core"));
Assert.assertNotNull(imageTypeVersionMap.get("azkaban_exec"));
Assert.assertNotNull(imageTypeVersionMap.get("hive_job"));
Assert.assertNotNull(imageTypeVersionMap.get("spark_job"));
Assert.assertNotNull(imageTypeVersionMap.get("pig_job"));
// Below two image types are from based on active image version
Assert.assertEquals("4.1.2", imageTypeVersionMap.get("pig_job"));
Assert.assertNotNull(imageTypeVersionMap.get("hadoop_job"));
Assert.assertEquals("5.1.5", imageTypeVersionMap.get("hadoop_job"));
}
|
This test is a failure test for getting version for all the available image types. For some of
the image types there is neighter active image rampups nor active image versions. Hence the
test throws exception.
@throws Exception
|
testFetchAllImageTypesVersionFailureCase
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test
public void testFetchVersionByImageTypesWithRampRule() throws Exception {
final String jsonInput = JSONUtils.readJsonFileAsString("image_management/image_type_rampups2.json");
final Map<String, List<ImageRampup>> imageTypeRampups = convertToRampupMap(jsonInput);
final Set<String> imageTypes = new TreeSet<>();
String imageTypeName1 = "az-platform-image";
imageTypes.add(imageTypeName1);
imageTypes.add("azkaban_core");
when(this.imageRampupDao.getRampupByImageTypes(any(Set.class))).thenReturn(imageTypeRampups);
final String jsonImageTypeActiveVersion = JSONUtils.readJsonFileAsString(
"image_management/test_image_type_active_version.json");
final List<ImageVersionDTO> activeImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeActiveVersion, ImageVersionDTO.class);
final List<ImageVersion> activeImageVersions =
this.imageVersionConverter.convertToDataModels(activeImageVersionDTOs);
final String jsonImageTypeNewAndRampupVersion = JSONUtils.readJsonFileAsString(
"image_management/all_image_types_new_and_rampup_version.json");
final List<ImageVersionDTO> newAndRampupImageVersionDTOs = converterUtils.convertToDTOs(
jsonImageTypeNewAndRampupVersion, ImageVersionDTO.class);
final List<ImageVersion> newAndRampupImageVersions =
this.imageVersionConverter.convertToDataModels(newAndRampupImageVersionDTOs);
when(this.imageVersionDao.findImageVersions(any(ImageMetadataRequest.class))).thenReturn(newAndRampupImageVersions);
// test only imageTypeName1 is rule out by a ramp rule, while others (azkaban-core) remain uneffected
String testProject = "exectest1";
String testFlow = "exec1";
final ExecutableFlow flow = TestUtils
.createTestExecutableFlow(testProject, testFlow, DispatchMethod.CONTAINERIZED);
when(rampRuleDao.isExcludedByRampRule(flow.getFlowName(), imageTypeName1,
imageTypeRampups.get(imageTypeName1).get(0).getImageVersion())).thenReturn(true);
ImageVersion activeImageVersion1 = activeImageVersions.get(0);
when(imageVersionDao.getActiveVersionByImageTypes(any(Set.class))).thenReturn(Collections.singletonList(activeImageVersion1));
Map<String, VersionInfo> imageTypeVersionMap = this.imageRampupManger
.getVersionByImageTypes(flow, imageTypes, new HashSet<>());
Assert.assertEquals("0.1.199", imageTypeVersionMap.get(imageTypeName1).getVersion());
Assert.assertEquals("3.6.2", imageTypeRampups.get("azkaban_core").get(0).getImageVersion());
}
|
This test is a failure test for getting version for all the available image types. For some of
the image types there is neighter active image rampups nor active image versions. Hence the
test throws exception.
@throws Exception
|
testFetchVersionByImageTypesWithRampRule
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
private Map<String, List<ImageRampup>> convertToRampupMap(final String input) {
Map<String, List<ImageRampup>> imageTypeRampups = null;
try {
imageTypeRampups = this.objectMapper.readValue(input,
new TypeReference<Map<String,
List<ImageRampup>>>() {
});
} catch (final IOException e) {
log.error("Exception while converting input json ", e);
}
return imageTypeRampups;
}
|
This test is a failure test for getting version for all the available image types. For some of
the image types there is neighter active image rampups nor active image versions. Hence the
test throws exception.
@throws Exception
|
convertToRampupMap
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/rampup/ImageRampupManagerImplTest.java
|
Apache-2.0
|
@Test
public void test() throws IOException {
VersionSetLoader loaderSpy = Mockito.spy(this.loader);
String testJsonString1 = "{\"key1\":{\"version\":\"value1\",\"path\":\"path1\","
+ "\"state\":\"ACTIVE\"},\"key2\":{\"version\":\"value2\",\"path\":\"path2\","
+ "\"state\":\"ACTIVE\"},\"key3\":{\"version\":\"value3\",\"path\":\"path3\","
+ "\"state\":\"ACTIVE\"}}";
String testMd5Hex1 = "43966138aebfdc4438520cc5cd2aefa8";
// Assert that it doesn't exist before
Optional<VersionSet> versionSet = loaderSpy.getVersionSet("43966138aebfdc4438520cc5cd2aefa8");
Assert.assertFalse(versionSet.isPresent());
// Assert that it doesn't exist before
versionSet = loaderSpy.getVersionSetById(1);
Assert.assertFalse(versionSet.isPresent());
// Try to get versionSetId which internally inserts if it doesn't exist
int versionSetId = loaderSpy.getVersionSet(testMd5Hex1, testJsonString1).get().getVersionSetId();
Assert.assertEquals(1, versionSetId);
Mockito.verify(loaderSpy, Mockito.times(1))
.insertAndGetVersionSet(Mockito.anyString(), Mockito.anyString());
// Try to get versionSetId again which will return from the local copy
versionSetId = loaderSpy.getVersionSet(testMd5Hex1, testJsonString1).get().getVersionSetId();
Assert.assertEquals(1, versionSetId);
Mockito.verify(loaderSpy, Mockito.times(1))
.insertAndGetVersionSet(Mockito.anyString(), Mockito.anyString());
// Try getting it again using md5
versionSet = loaderSpy.getVersionSet("43966138aebfdc4438520cc5cd2aefa8");
Assert.assertTrue(versionSet.isPresent());
Assert.assertEquals(1, versionSet.get().getVersionSetId());
// Try getting it again using Id
versionSet = loaderSpy.getVersionSetById(1);
Assert.assertTrue(versionSet.isPresent());
Assert.assertEquals(1, versionSet.get().getVersionSetId());
// Try to remove
boolean removed = loaderSpy.deleteVersionSet("43966138aebfdc4438520cc5cd2aefa8");
Assert.assertTrue(removed);
// Assert that it doesn't exist now
versionSet = loaderSpy.getVersionSet("43966138aebfdc4438520cc5cd2aefa8");
Assert.assertFalse(versionSet.isPresent());
// Verify that fetch doesn't return anything
List<VersionSet> versionSets = loaderSpy.fetchAllVersionSets();
Assert.assertTrue(versionSets.isEmpty());
// Try to get versionSetId which internally inserts if it doesn't exist
versionSetId = loaderSpy.getVersionSet(testMd5Hex1, testJsonString1).get().getVersionSetId();
// This time Id will be 2 due to autoincrement field
Assert.assertEquals(2, versionSetId);
// Twice total number of invocations of insertAndGetVersionSetId method
Mockito.verify(loaderSpy, Mockito.times(2))
.insertAndGetVersionSet(Mockito.anyString(), Mockito.anyString());
// Verify that fetch returns one record
versionSets = loaderSpy.fetchAllVersionSets();
Assert.assertEquals(1, versionSets.size());
}
|
This test executes various methods and verify various cases.
|
test
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/imagemgmt/version/JdbcVersionSetLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/imagemgmt/version/JdbcVersionSetLoaderTest.java
|
Apache-2.0
|
@Test
public void testGetResource() throws IOException {
final URL testJar = makeTestJar().toURI().toURL();
final ClassLoader currentClassLoader = getClass().getClassLoader();
final ClassLoader jobClassLoader = new JobClassLoader(
new URL[]{testJar}, currentClassLoader, "testJob");
Assert.assertNull("Resource should not be found in the parent classloader",
currentClassLoader.getResource(RESOURCE_FILE));
Assert.assertNotNull("Resource should be found in JobClassLoader",
jobClassLoader.getResource(RESOURCE_FILE));
}
|
Test the case where a resource file exists in the Job's classloader.
|
testGetResource
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
private File makeTestJar() throws IOException {
final File jarFile = this.testDir.newFile("test.jar");
try (final JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile))) {
final ZipEntry entry = new ZipEntry(RESOURCE_FILE);
out.putNextEntry(entry);
out.write("hello".getBytes(UTF_8));
out.closeEntry();
}
return jarFile;
}
|
Test the case where a resource file exists in the Job's classloader.
|
makeTestJar
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
@Test(expected = ClassNotFoundException.class)
public void testNonexistClass() throws ClassNotFoundException {
final ClassLoader currentClassLoader = getClass().getClassLoader();
final ClassLoader jobClassLoader = new JobClassLoader(
new URL[]{}, currentClassLoader, "testJob");
Assert.assertNull("This class does not exist",
jobClassLoader.loadClass("nonexistent.class.name"));
}
|
Test the case where the define job class does not exist.
|
testNonexistClass
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
@Test
public void testClassAvailableInParentClassLoader() throws ClassNotFoundException {
final ClassLoader currentClassLoader = getClass().getClassLoader();
final ClassLoader jobClassLoader = new JobClassLoader(
new URL[]{}, currentClassLoader, "testJob");
final Class clazz = jobClassLoader.loadClass(JobClassLoaderTest.class.getName());
Assert.assertEquals(currentClassLoader, clazz.getClassLoader());
}
|
Test class loading of a class that is available only in the parent classloader.
|
testClassAvailableInParentClassLoader
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
@Test
public void testClassAvailableInJobClassLoader()
throws MalformedURLException, ClassNotFoundException {
final ClassLoader currentClassLoader = getClass().getClassLoader();
final File helloworldJar = new File(currentClassLoader.getResource(SAMPLE_JAR).getFile());
final URL helloworlURL = helloworldJar.toURI().toURL();
final ClassLoader jobClassLoader = new JobClassLoader(
new URL[]{helloworlURL}, currentClassLoader, "testJob");
final Class clazz = jobClassLoader.loadClass("org.hello.world.HelloWorld");
Assert.assertEquals(jobClassLoader, clazz.getClassLoader());
}
|
Test class loading of a class that is available only in the JobClassloader. The class is
provided in 'helloworld.jar'.
|
testClassAvailableInJobClassLoader
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
@Test
public void testPropsClass() throws ClassNotFoundException {
ClassLoader currentClassLoader = getClass().getClassLoader();
JobClassLoader jobClassLoader = new JobClassLoader(
new URL[] {}, currentClassLoader, "testJob");
// make azkaban.utils.Props class available to the JobClassLoader
jobClassLoader.addURL(Props.class);
Class clazz = jobClassLoader.loadClass(Props.class.getName());
Assert.assertEquals(currentClassLoader, clazz.getClassLoader());
}
|
Check {@link azkaban.utils.Props} is already loaded by its parent classloader.
|
testPropsClass
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/JobClassLoaderTest.java
|
Apache-2.0
|
@Test
public void testOneUnixCommandWithProxyUserInsteadOfSubmitUser() throws Exception {
// Initialize the Props
this.props.removeLocal(CommonJobProperties.SUBMIT_USER);
this.props.put(JobProperties.USER_TO_PROXY, "test_user");
this.props.put(ProcessJob.COMMAND, "ls -al");
this.job.run();
}
|
this job should run fine if the props contain user.to.proxy
|
testOneUnixCommandWithProxyUserInsteadOfSubmitUser
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test(expected = RuntimeException.class)
public void testOneUnixCommandWithRootUser() throws Exception {
// Initialize the Props
this.props.removeLocal(CommonJobProperties.SUBMIT_USER);
this.props.put(JobProperties.USER_TO_PROXY, "root");
this.props.put("execute.as.user", "true");
this.props.put(ProcessJob.COMMAND, "ls -al");
this.job.run();
}
|
this job should fail because it sets user.to.proxy = root which is black listed
|
testOneUnixCommandWithRootUser
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test(expected = RuntimeException.class)
public void testOneUnixCommandWithAzkabanUser() throws Exception {
// Initialize the Props
this.props.removeLocal(CommonJobProperties.SUBMIT_USER);
this.props.put(JobProperties.USER_TO_PROXY, "azkaban");
this.props.put("execute.as.user", "true");
this.props.put(ProcessJob.COMMAND, "ls -al");
this.job.run();
}
|
this job should fail because it sets user.to.proxy = azkaban which is black listed
|
testOneUnixCommandWithAzkabanUser
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test
public void testFailedUnixCommand() throws Exception {
// Initialize the Props
this.props.put(ProcessJob.COMMAND, "xls -al");
try {
this.job.run();
} catch (final RuntimeException e) {
Assert.assertTrue(true);
e.printStackTrace();
}
}
|
this job should fail because it sets user.to.proxy = azkaban which is black listed
|
testFailedUnixCommand
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test
public void testMultipleUnixCommands() throws Exception {
// Initialize the Props
this.props.put(ProcessJob.COMMAND, "pwd");
this.props.put("command.1", "date");
this.props.put("command.2", "whoami");
this.job.run();
}
|
this job should fail because it sets user.to.proxy = azkaban which is black listed
|
testMultipleUnixCommands
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test
public void testPartitionCommand() throws Exception {
final String test1 = "a b c";
Assert.assertArrayEquals(new String[]{"a", "b", "c"},
ProcessJob.partitionCommandLine(test1));
final String test2 = "a 'b c'";
Assert.assertArrayEquals(new String[]{"a", "b c"},
ProcessJob.partitionCommandLine(test2));
final String test3 = "a e='b c'";
Assert.assertArrayEquals(new String[]{"a", "e=b c"},
ProcessJob.partitionCommandLine(test3));
}
|
this job should fail because it sets user.to.proxy = azkaban which is black listed
|
testPartitionCommand
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test
public void testCancelDuringPreparation() throws InterruptedException, ExecutionException {
final Props jobProps = new Props();
jobProps.put("command", "echo hello");
jobProps.put("working.dir", "/tmp");
jobProps.put(JobProperties.USER_TO_PROXY, "test");
jobProps.put("azkaban.flow.projectname", "test");
jobProps.put("azkaban.flow.flowid", "test");
jobProps.put("azkaban.job.id", "test");
jobProps.put("azkaban.flow.execid", "1");
final Props sysProps = new Props();
sysProps.put("execute.as.user", "false");
final SleepBeforeRunJob sleepBeforeRunJob = new SleepBeforeRunJob("test", sysProps, jobProps,
this.log);
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final Future future = executorService.submit(sleepBeforeRunJob);
sleepBeforeRunJob.cancel();
future.get();
assertThat(sleepBeforeRunJob.getProgress()).isEqualTo(0.0);
}
|
test cancellation of the job before associated process is constructed expect job will be
cancelled successfully
|
testCancelDuringPreparation
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Test
public void testCancelAfterJobProcessCreation() throws InterruptedException, ExecutionException {
this.props.put(ProcessJob.COMMAND, "sleep 5");
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final Future future = executorService.submit(() -> {
try {
this.job.run();
} catch (final Exception e) {
}
});
// Wait for the AzkabanProcess object to be created before calling job.cancel so that the job
// process is created.
while (this.job.getProcess() == null) {
Thread.sleep(1);
}
this.job.cancel();
// Wait for the job to finish before testing its state.
future.get();
assertThat(this.job.isSuccess()).isFalse();
}
|
test cancellation of the job before associated process is constructed expect job will be
cancelled successfully
|
testCancelAfterJobProcessCreation
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Override
public void run() {
try {
info("sleep for some time before actually running the job");
Thread.sleep(10);
super.run();
} catch (final Exception ex) {
this.getLog().error(ex);
}
}
|
test cancellation of the job before associated process is constructed expect job will be
cancelled successfully
|
run
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobExecutor/ProcessJobTest.java
|
Apache-2.0
|
@Before
public void setUp() throws Exception {
// TODO: reallocf Remove initServiceProvider when ProcessJob fully guiced
initServiceProvider();
final File jobTypeDir = this.temp.newFolder(TEST_PLUGIN_DIR);
this.testPluginDirPath = jobTypeDir.getCanonicalPath();
final URL resourceUrl = Resources.getResource("plugins/jobtypes");
assertNotNull(resourceUrl);
FileUtils.copyDirectory(new File(resourceUrl.toURI()), jobTypeDir);
this.manager = new JobTypeManager(this.testPluginDirPath, null,
this.getClass().getClassLoader());
}
|
Test the flow run, especially with embedded flows. Files are in unit/plugins/jobtypes
|
setUp
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
Apache-2.0
|
@After
public void tearDown() throws IOException {
this.temp.delete();
}
|
Test the flow run, especially with embedded flows. Files are in unit/plugins/jobtypes
|
tearDown
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
Apache-2.0
|
@Test
public void testCommonPluginProps() throws Exception {
final JobTypePluginSet pluginSet = this.manager.getJobTypePluginSet();
final Props props = pluginSet.getCommonPluginJobProps();
System.out.println(props.toString());
assertEquals("commonprop1", props.getString("commonprop1"));
assertEquals("commonprop2", props.getString("commonprop2"));
assertEquals("commonprop3", props.getString("commonprop3"));
final Props priv = pluginSet.getCommonPluginLoadProps();
assertEquals("commonprivate1", priv.getString("commonprivate1"));
assertEquals("commonprivate2", priv.getString("commonprivate2"));
assertEquals("commonprivate3", priv.getString("commonprivate3"));
assertEquals("azkaban.jobtype.FakeJavaJob2",
priv.getString("default.proxyusers.jobtype.classes"));
}
|
Tests that the common and common private properties are loaded correctly
|
testCommonPluginProps
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
Apache-2.0
|
@Test
public void testLoadedClasses() throws Exception {
final JobTypePluginSet pluginSet = this.manager.getJobTypePluginSet();
final Props props = pluginSet.getCommonPluginJobProps();
System.out.println(props.toString());
assertEquals("commonprop1", props.getString("commonprop1"));
assertEquals("commonprop2", props.getString("commonprop2"));
assertEquals("commonprop3", props.getString("commonprop3"));
assertNull(props.get("commonprivate1"));
final Props priv = pluginSet.getCommonPluginLoadProps();
assertEquals("commonprivate1", priv.getString("commonprivate1"));
assertEquals("commonprivate2", priv.getString("commonprivate2"));
assertEquals("commonprivate3", priv.getString("commonprivate3"));
// Testing the anothertestjobtype
assertEquals("azkaban.jobtype.FakeJavaJob",
pluginSet.getPluginClassName("anothertestjob"));
final Props ajobProps = pluginSet.getPluginJobProps("anothertestjob");
final Props aloadProps = pluginSet.getPluginLoaderProps("anothertestjob");
// Loader props
assertEquals("lib/*", aloadProps.get("jobtype.classpath"));
assertEquals("azkaban.jobtype.FakeJavaJob",
aloadProps.get("jobtype.class"));
assertEquals("commonprivate1", aloadProps.get("commonprivate1"));
assertEquals("commonprivate2", aloadProps.get("commonprivate2"));
assertEquals("commonprivate3", aloadProps.get("commonprivate3"));
// Job props
assertEquals("commonprop1", ajobProps.get("commonprop1"));
assertEquals("commonprop2", ajobProps.get("commonprop2"));
assertEquals("commonprop3", ajobProps.get("commonprop3"));
assertNull(ajobProps.get("commonprivate1"));
assertEquals("azkaban.jobtype.FakeJavaJob2",
pluginSet.getPluginClassName("testjob"));
final Props tjobProps = pluginSet.getPluginJobProps("testjob");
final Props tloadProps = pluginSet.getPluginLoaderProps("testjob");
// Loader props
assertNull(tloadProps.get("jobtype.classpath"));
assertEquals("azkaban.jobtype.FakeJavaJob2",
tloadProps.get("jobtype.class"));
assertEquals("commonprivate1", tloadProps.get("commonprivate1"));
assertEquals("commonprivate2", tloadProps.get("commonprivate2"));
assertEquals("private3", tloadProps.get("commonprivate3"));
assertEquals("0", tloadProps.get("testprivate"));
// Job props
assertEquals("commonprop1", tjobProps.get("commonprop1"));
assertEquals("commonprop2", tjobProps.get("commonprop2"));
assertEquals("1", tjobProps.get("pluginprops1"));
assertEquals("2", tjobProps.get("pluginprops2"));
assertEquals("3", tjobProps.get("pluginprops3"));
assertEquals("pluginprops", tjobProps.get("commonprop3"));
// Testing that the private properties aren't shared with the public ones
assertNull(tjobProps.get("commonprivate1"));
assertNull(tjobProps.get("testprivate"));
}
|
Tests that the proper classes were loaded and that the common and the load properties are
properly loaded.
|
testLoadedClasses
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
Apache-2.0
|
@Test
public void testJobPropsProcessor() throws Exception {
final Props jobProps = new Props();
jobProps.put("type", "testjobwithpropsprocessor");
final Job job = this.manager.buildJobExecutor("testjobwithpropsprocessor", jobProps, this.logger);
assertTrue(job instanceof FakeJavaJob);
final FakeJavaJob fjj = (FakeJavaJob) job;
final Props props = fjj.getJobProps();
assertEquals("commonprop1", props.get("commonprop1"));
assertEquals("commonprop2", props.get("commonprop2"));
assertEquals("commonprop3", props.get("commonprop3"));
assertNull(props.get("commonprivate1"));
assertEquals(TestJobPropsProcessor.INJECTED_ADDITION_PROP,
props.get(TestJobPropsProcessor.INJECTED_ADDITION_PROP));
}
|
Configure a {@link JobPropsProcessor} for a jobtype plugin and verify the JobPropsProcessor
are invoked correctly for jobs of that type.
|
testJobPropsProcessor
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerTest.java
|
Apache-2.0
|
private Cluster createDefaultCluster() throws IOException {
final Props clusterProps = new Props();
final File hadoopJar = makeTestJar("hadoop", "hadoop.jar");
clusterProps.put(Cluster.LIBRARY_PATH_PREFIX + "hadoop", hadoopJar.getParentFile().getPath());
clusterProps.put(Cluster.NATIVE_LIBRARY_PATH_PREFIX + "hadoop", "hadoop-native-lib");
final File hiveJar = makeTestJar("hive", "hive.jar");
clusterProps.put(Cluster.LIBRARY_PATH_PREFIX + "hive", hiveJar.getParentFile().getPath());
clusterProps.put(Cluster.NATIVE_LIBRARY_PATH_PREFIX + "hive", "hive-native-lib");
clusterProps.put(Cluster.HADOOP_SECURITY_MANAGER_CLASS_PROP, HADOOP_SECURITY_MANAGER_CLASS);
clusterProps.put(PIG_HOME, "/cluster/pig/path");
clusterProps.put("PropA", "${PropB}");
clusterProps.put("PropB", "valB");
clusterProps.put("PropC", "valC");
return new Cluster("default", clusterProps);
}
|
Unit tests for {@link JobTypeManager} when clusters are configured.
|
createDefaultCluster
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
Apache-2.0
|
private File makeTestJar(final String folderName, final String jarName)
throws IOException {
final File folder = new File(this.testDirectory, folderName);
folder.mkdirs();
final File jarFile = new File(folder, jarName);
try (final JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile))) {
final ZipEntry entry = new ZipEntry("resource.txt");
out.putNextEntry(entry);
out.write("hello".getBytes(UTF_8));
out.closeEntry();
}
return jarFile;
}
|
Unit tests for {@link JobTypeManager} when clusters are configured.
|
makeTestJar
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
Apache-2.0
|
@Before
public void setUp() throws Exception {
initServiceProvider();
}
|
Unit tests for {@link JobTypeManager} when clusters are configured.
|
setUp
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
Apache-2.0
|
@Test
public void testJobTypeManagerJobSetupWithoutJobComponentDependency() {
final JobTypeManager manager = new JobTypeManager(this.testPluginDirPath, null,
this.getClass().getClassLoader(), this.clusterRouter, null);
Props jobProps = new Props();
jobProps.put("type", "anothertestjob");
jobProps.put("propB", "b");
final JobParams jobParams = manager.createJobParams("anothertestjob", jobProps, LOG);
Assert.assertTrue(
jobParams.contextClassLoader instanceof HadoopSecurityManagerClassLoader);
final Job job = JobTypeManager.createJob("anothertestjob", jobParams, LOG);
jobProps = ((FakeJavaJob) job).getJobProps();
final String clusterClassPath = jobProps
.getString(CommonJobProperties.TARGET_CLUSTER_CLASSPATH);
Assert.assertFalse(clusterClassPath.contains("hive"));
Assert.assertTrue(clusterClassPath.contains("hadoop"));
final String jvmArgs = jobProps.getString(CommonJobProperties.TARGET_CLUSTER_NATIVE_LIB);
Assert.assertFalse(jvmArgs.contains("hive"));
Assert.assertTrue(jvmArgs.contains("hadoop"));
}
|
Unit test of JobTypeManager's setup for jobs without 'job.dependency.components' specified.
|
testJobTypeManagerJobSetupWithoutJobComponentDependency
|
java
|
azkaban/azkaban
|
azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/test/java/azkaban/jobtype/JobTypeManagerWithDynamicClusterTest.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.