private static Pair<ExecutionReference, ExecutableFlow> getExecutableFlowMetadataHelper( final ResultSet rs) throws SQLException { final Flow flow = new Flow(rs.getString("flow_id")); final Project project = new Project(rs.getInt("project_id"), null); project.setVersion(rs.getInt("version")); final ExecutableFlow exFlow = new ExecutableFlow(project, flow); exFlow.setExecutionId(rs.getInt("exec_id")); exFlow.setStatus(Status.fromInteger(rs.getInt("status"))); exFlow.setSubmitTime(rs.getLong("submit_time")); exFlow.setStartTime(rs.getLong("start_time")); exFlow.setEndTime(rs.getLong("end_time")); exFlow.setSubmitUser(rs.getString("submit_user")); return getPairWithExecutorInfo(rs, exFlow); }
flow1.setStartTime(dateUtil.dateStrToLong("2018-09-01 10:00:00")); this.executionFlowDao.uploadExecutableFlow(flow1); flow2.setStartTime(dateUtil.dateStrToLong("2018-09-01 09:00:00")); this.executionFlowDao.uploadExecutableFlow(flow2); flow3.setStartTime(dateUtil.dateStrToLong("2018-09-01 09:00:00")); this.executionFlowDao.uploadExecutableFlow(flow3); flow4.setStartTime(dateUtil.dateStrToLong("2018-09-01 08:00:00")); this.executionFlowDao.uploadExecutableFlow(flow4);
private List<ExecutableFlow> createExecutions() throws Exception { final Executor executor = this.executorDao.addExecutor("test", 1); final ExecutableFlow flow1 = createExecutionAndAssign(Status.PREPARING, executor); // flow2 is not assigned final ExecutableFlow flow2 = createExecution(Status.PREPARING); final ExecutableFlow flow3 = createExecutionAndAssign(Status.RUNNING, executor); flow3.setStartTime(System.currentTimeMillis() + 1); this.executionFlowDao.updateExecutableFlow(flow3); final ExecutableFlow flow4 = createExecutionAndAssign(Status.SUCCEEDED, executor); flow4.setStartTime(System.currentTimeMillis() - 2); flow4.setEndTime(System.currentTimeMillis() - 1); this.executionFlowDao.updateExecutableFlow(flow4); final Executor executor2 = this.executorDao.addExecutor("test2", 2); // flow5 is assigned to an executor that is then removed final ExecutableFlow flow5 = createExecutionAndAssign(Status.RUNNING, executor2); flow5.setStartTime(System.currentTimeMillis() + 1); this.executionFlowDao.updateExecutableFlow(flow5); this.executorDao.removeExecutor(executor2.getHost(), executor2.getPort()); return ImmutableList.of(flow1, flow2, flow3, flow4, flow5); }
@Test public void createErrorEmail() throws Exception { setJobStatus(Status.FAILED); this.executableFlow.setEndTime(END_TIME_MILLIS); this.executableFlow.setStatus(Status.FAILED); final List<ExecutableFlow> executableFlows = new ArrayList<>(); final ExecutableFlow executableFlow1 = new ExecutableFlow(this.project, this.flow); executableFlow1.setExecutionId(1); executableFlow1.setStartTime(START_TIME_MILLIS); executableFlow1.setEndTime(END_TIME_MILLIS); executableFlow1.setStatus(Status.FAILED); executableFlows.add(executableFlow1); final ExecutableFlow executableFlow2 = new ExecutableFlow(this.project, this.flow); executableFlow2.setExecutionId(2); executableFlow2.setStartTime(START_TIME_MILLIS); executableFlow2.setEndTime(END_TIME_MILLIS); executableFlow2.setStatus(Status.SUCCEEDED); executableFlows.add(executableFlow2); assertTrue(this.mailCreator.createErrorEmail( this.executableFlow, executableFlows, this.message, this.azkabanName, this.scheme, this .clientHostname, this.clientPortNumber)); assertEquals("Flow 'mail-creator-test' has failed on unit-tests", this.message.getSubject()); assertThat(TestUtils.readResource("errorEmail.html", this)) .isEqualToIgnoringWhitespace(this.message.getBody()); }
@Before public void setUp() throws Exception { this.defaultTz = TimeZone.getDefault(); assertNotNull(this.defaultTz); // EEST TimeZone.setDefault(TimeZone.getTimeZone("Europe/Helsinki")); DateTimeUtils.setCurrentMillisFixed(FIXED_CURRENT_TIME_MILLIS); this.mailCreator = new DefaultMailCreator(); this.executor = new Executor(1, "executor1-host", 1234, true); this.flow = new Flow("mail-creator-test"); this.project = new Project(1, "test-project"); this.options = new ExecutionOptions(); this.message = new EmailMessage("localhost", EmailMessageCreator.DEFAULT_SMTP_PORT, "", "", null); this.azkabanName = "unit-tests"; this.scheme = "http"; this.clientHostname = "localhost"; this.clientPortNumber = "8081"; final Node failedNode = new Node("test-job"); failedNode.setType("noop"); this.flow.addNode(failedNode); this.executableFlow = new ExecutableFlow(this.project, this.flow); this.executableFlow.setExecutionOptions(this.options); this.executableFlow.setStartTime(START_TIME_MILLIS); this.options.setFailureEmails(ImmutableList.of("test@example.com")); this.options.setSuccessEmails(ImmutableList.of("test@example.com")); }
exFlow.setStartTime(500); exFlow.setStatus(Status.RUNNING); exFlow.setUpdateTime(133);
private ExecutableFlow getExecutableFlowMetadata( ExecutableFlow fullExFlow) { final Flow flow = new Flow(fullExFlow.getId()); final Project project = new Project(fullExFlow.getProjectId(), null); project.setVersion(fullExFlow.getVersion()); flow.setVersion(fullExFlow.getVersion()); final ExecutableFlow metadata = new ExecutableFlow(project, flow); metadata.setExecutionId(fullExFlow.getExecutionId()); metadata.setStatus(fullExFlow.getStatus()); metadata.setSubmitTime(fullExFlow.getSubmitTime()); metadata.setStartTime(fullExFlow.getStartTime()); metadata.setEndTime(fullExFlow.getEndTime()); metadata.setSubmitUser(fullExFlow.getSubmitUser()); return metadata; }
flow.setStartTime(System.currentTimeMillis());