@Test(dataProvider = "createOperationExecutorProvider") public void testCreateOperationExecutor(boolean hasPriorProgress) { Operation operation = new Operation(); operation.setType("sample"); doReturn(operation).when(mockOperationWrapper).getOperation(); doReturn(hasPriorProgress ? new OperationProgress() : null ) .when(mockOperationWrapper).getPriorExecutionOperationProgress(); KubernetesOperationExecutor kubernetesExecutor = callCreateOperationExecutor(mockExecutorContext, mockOperationWrapper); Assert.assertEquals(kubernetesExecutor.getPodConfig().getEnvVars().containsKey(HandlerField.LAST_PROGRESS.name()), hasPriorProgress); }
@Override public BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper) { Operation operation = operationWrapper.getOperation(); logger.info("Creating kube config with no proxies"); KubeConfig kubeConfig = kubeConfigFactory.createKubeConfig(); PodConfig podConfig = null; try { podConfig = podConfigRegistryClient.getPodConfig(operation.getType()); } catch (PodConfigRegistryClientException e) { logger.error("There was a problem trying to retrieve the PodConfig {} from PodConfigRegistryClient.", operation == null ? "unknown" : operation.getType()); } if(podConfig == null) { logger.error("Could not retrieve PodConfig from Registry.."); throw new AgendaExecutorException( String.format("Unknown operation type found: %1$s on operation: %2$s", operation.getType(), operation.getName())); } if(operationWrapper.getPriorExecutionOperationProgress() != null) { logger.info("Found prior operationProgress for op: {}", operationWrapper.getOperation().getName()); podConfig.addEnvVars(HandlerField.LAST_PROGRESS.name(), executorContext.getJsonHelper().getJSONString(operationWrapper.getPriorExecutionOperationProgress())); } return buildOperationExecutor(podConfig, operation, kubeConfig, executorContext); }
KubernetesOperationExecutorFactory extends OperationExecutorFactory { @Override public BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper) { Operation operation = operationWrapper.getOperation(); logger.info("Creating kube config with no proxies"); KubeConfig kubeConfig = kubeConfigFactory.createKubeConfig(); PodConfig podConfig = null; try { podConfig = podConfigRegistryClient.getPodConfig(operation.getType()); } catch (PodConfigRegistryClientException e) { logger.error("There was a problem trying to retrieve the PodConfig {} from PodConfigRegistryClient.", operation == null ? "unknown" : operation.getType()); } if(podConfig == null) { logger.error("Could not retrieve PodConfig from Registry.."); throw new AgendaExecutorException( String.format("Unknown operation type found: %1$s on operation: %2$s", operation.getType(), operation.getName())); } if(operationWrapper.getPriorExecutionOperationProgress() != null) { logger.info("Found prior operationProgress for op: {}", operationWrapper.getOperation().getName()); podConfig.addEnvVars(HandlerField.LAST_PROGRESS.name(), executorContext.getJsonHelper().getJSONString(operationWrapper.getPriorExecutionOperationProgress())); } return buildOperationExecutor(podConfig, operation, kubeConfig, executorContext); } }
KubernetesOperationExecutorFactory extends OperationExecutorFactory { @Override public BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper) { Operation operation = operationWrapper.getOperation(); logger.info("Creating kube config with no proxies"); KubeConfig kubeConfig = kubeConfigFactory.createKubeConfig(); PodConfig podConfig = null; try { podConfig = podConfigRegistryClient.getPodConfig(operation.getType()); } catch (PodConfigRegistryClientException e) { logger.error("There was a problem trying to retrieve the PodConfig {} from PodConfigRegistryClient.", operation == null ? "unknown" : operation.getType()); } if(podConfig == null) { logger.error("Could not retrieve PodConfig from Registry.."); throw new AgendaExecutorException( String.format("Unknown operation type found: %1$s on operation: %2$s", operation.getType(), operation.getName())); } if(operationWrapper.getPriorExecutionOperationProgress() != null) { logger.info("Found prior operationProgress for op: {}", operationWrapper.getOperation().getName()); podConfig.addEnvVars(HandlerField.LAST_PROGRESS.name(), executorContext.getJsonHelper().getJSONString(operationWrapper.getPriorExecutionOperationProgress())); } return buildOperationExecutor(podConfig, operation, kubeConfig, executorContext); } KubernetesOperationExecutorFactory(LaunchDataWrapper launchDataWrapper); }
KubernetesOperationExecutorFactory extends OperationExecutorFactory { @Override public BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper) { Operation operation = operationWrapper.getOperation(); logger.info("Creating kube config with no proxies"); KubeConfig kubeConfig = kubeConfigFactory.createKubeConfig(); PodConfig podConfig = null; try { podConfig = podConfigRegistryClient.getPodConfig(operation.getType()); } catch (PodConfigRegistryClientException e) { logger.error("There was a problem trying to retrieve the PodConfig {} from PodConfigRegistryClient.", operation == null ? "unknown" : operation.getType()); } if(podConfig == null) { logger.error("Could not retrieve PodConfig from Registry.."); throw new AgendaExecutorException( String.format("Unknown operation type found: %1$s on operation: %2$s", operation.getType(), operation.getName())); } if(operationWrapper.getPriorExecutionOperationProgress() != null) { logger.info("Found prior operationProgress for op: {}", operationWrapper.getOperation().getName()); podConfig.addEnvVars(HandlerField.LAST_PROGRESS.name(), executorContext.getJsonHelper().getJSONString(operationWrapper.getPriorExecutionOperationProgress())); } return buildOperationExecutor(podConfig, operation, kubeConfig, executorContext); } KubernetesOperationExecutorFactory(LaunchDataWrapper launchDataWrapper); @Override BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper); KubernetesOperationExecutorFactory setPodConfigRegistryClient(PodConfigRegistryClient podConfigRegistryClient); KubeConfigFactory getKubeConfigFactory(); KubernetesOperationExecutorFactory setKubeConfigFactory(KubeConfigFactory kubeConfigFactory); PodFollowerFactory getPodFollowerFactory(); void setPodFollowerFactory(PodFollowerFactory podFollowerFactory); }
KubernetesOperationExecutorFactory extends OperationExecutorFactory { @Override public BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper) { Operation operation = operationWrapper.getOperation(); logger.info("Creating kube config with no proxies"); KubeConfig kubeConfig = kubeConfigFactory.createKubeConfig(); PodConfig podConfig = null; try { podConfig = podConfigRegistryClient.getPodConfig(operation.getType()); } catch (PodConfigRegistryClientException e) { logger.error("There was a problem trying to retrieve the PodConfig {} from PodConfigRegistryClient.", operation == null ? "unknown" : operation.getType()); } if(podConfig == null) { logger.error("Could not retrieve PodConfig from Registry.."); throw new AgendaExecutorException( String.format("Unknown operation type found: %1$s on operation: %2$s", operation.getType(), operation.getName())); } if(operationWrapper.getPriorExecutionOperationProgress() != null) { logger.info("Found prior operationProgress for op: {}", operationWrapper.getOperation().getName()); podConfig.addEnvVars(HandlerField.LAST_PROGRESS.name(), executorContext.getJsonHelper().getJSONString(operationWrapper.getPriorExecutionOperationProgress())); } return buildOperationExecutor(podConfig, operation, kubeConfig, executorContext); } KubernetesOperationExecutorFactory(LaunchDataWrapper launchDataWrapper); @Override BaseOperationExecutor createOperationExecutor(ExecutorContext executorContext, OperationWrapper operationWrapper); KubernetesOperationExecutorFactory setPodConfigRegistryClient(PodConfigRegistryClient podConfigRegistryClient); KubeConfigFactory getKubeConfigFactory(); KubernetesOperationExecutorFactory setKubeConfigFactory(KubeConfigFactory kubeConfigFactory); PodFollowerFactory getPodFollowerFactory(); void setPodFollowerFactory(PodFollowerFactory podFollowerFactory);  }