/**
   * Test validates the happy path when an log viewer is configured with '${execid}' and '${jobid}
   * as the format in 'azkaban.properties'.
   */
  @Test
  public void testGetExternalLogViewerValidFormat() {
    azkProps.put(
        ServerProperties.AZKABAN_SERVER_EXTERNAL_LOGVIEWER_TOPIC, EXTERNAL_LOGVIEWER_TOPIC);
    azkProps.put(
        ServerProperties.AZKABAN_SERVER_EXTERNAL_TOPIC_URL.replace(
            "${topic}", EXTERNAL_LOGVIEWER_TOPIC),
        EXTERNAL_LOGVIEWER_URL_VALID_FORMAT);

    String externalURL = ExternalLinkUtils.getExternalLogViewer(azkProps, jobId, jobProps);
    assertTrue(externalURL.equals(EXTERNAL_LOGVIEWER_EXPECTED_URL));
  }
  /**
   * Test validates the happy path when an external analyzer is configured with '${url}' as the
   * format in 'azkaban.properties'.
   */
  @Test
  public void testGetExternalAnalyzerValidFormat() {
    azkProps.put(ServerProperties.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC, EXTERNAL_ANALYZER_TOPIC);
    azkProps.put(
        ServerProperties.AZKABAN_SERVER_EXTERNAL_TOPIC_URL.replace(
            "${topic}", EXTERNAL_ANALYZER_TOPIC),
        EXTERNAL_ANALYZER_URL_VALID_FORMAT);

    when(mockRequest.getRequestURL()).thenReturn(new StringBuffer(EXEC_URL));
    when(mockRequest.getQueryString()).thenReturn(EXEC_QUERY_STRING);

    String externalURL = ExternalLinkUtils.getExternalAnalyzerOnReq(azkProps, mockRequest);
    assertTrue(externalURL.equals(EXTERNAL_ANALYZER_EXPECTED_URL));
  }
 /**
  * Make sure that URLs for analyzers and logviewers are fetched correctly by setting it manually
  * and then fetching them
  */
 @Test
 public void testFetchURL() {
   azkProps.put(
       ServerProperties.AZKABAN_SERVER_EXTERNAL_TOPIC_URL.replace("${topic}", "someTopic"),
       "This is a link");
   assertTrue(ExternalLinkUtils.getURLForTopic("someTopic", azkProps).equals("This is a link"));
 }
  @Before
  public void setUp() {
    // Empty server configuration
    azkProps = new Props();

    // Job configuration consisting of only an exec id and job id
    jobProps = new Props();
    jobProps.put(FlowProperties.AZKABAN_FLOW_EXEC_ID, 1);
    jobId = "Some + job";

    mockRequest = mock(HttpServletRequest.class);
  }
示例#5
0
  public static Props resolveProps(Props props) {
    if (props == null) return null;

    Props resolvedProps = new Props();

    LinkedHashSet<String> visitedVariables = new LinkedHashSet<String>();
    for (String key : props.getKeySet()) {
      String value = props.get(key);

      visitedVariables.add(key);
      String replacedValue = resolveVariableReplacement(value, props, visitedVariables);
      visitedVariables.clear();

      resolvedProps.put(key, replacedValue);
    }

    for (String key : resolvedProps.getKeySet()) {
      String value = resolvedProps.get(key);
      String expressedValue = resolveVariableExpression(value);
      resolvedProps.put(key, expressedValue);
    }

    return resolvedProps;
  };
示例#6
0
  public static Props addCommonFlowProperties(Props parentProps, final ExecutableFlowBase flow) {
    Props props = new Props(parentProps);

    props.put(CommonJobProperties.FLOW_ID, flow.getFlowId());
    props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId());
    props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId());
    props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName());
    props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion());
    props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString());

    DateTime loadTime = new DateTime();

    props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString());
    props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy"));
    props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM"));
    props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd"));
    props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH"));
    props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm"));
    props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss"));
    props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS"));
    props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ"));
    return props;
  }