2015-11-19 14:39:21 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2015 LinkedIn Corp. All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
*/
|
|
|
|
package metadata.etl.lineage;
|
|
|
|
|
2015-12-11 19:46:35 -08:00
|
|
|
import java.io.File;
|
2015-11-19 14:39:21 -08:00
|
|
|
import java.io.IOException;
|
2015-12-11 19:46:35 -08:00
|
|
|
import java.net.URISyntaxException;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Paths;
|
2015-11-19 14:39:21 -08:00
|
|
|
import java.util.Properties;
|
|
|
|
import org.testng.Assert;
|
|
|
|
import org.testng.annotations.BeforeTest;
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.List;
|
|
|
|
import wherehows.common.schemas.AzkabanJobExecRecord;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by zsun on 9/9/15.
|
|
|
|
*/
|
2017-02-24 11:17:08 -08:00
|
|
|
@Test(groups = {"needConfig"})
|
2015-11-19 14:39:21 -08:00
|
|
|
public class AzJobCheckerTest {
|
2015-12-11 19:46:35 -08:00
|
|
|
|
2015-11-19 14:39:21 -08:00
|
|
|
AzJobChecker ajc;
|
|
|
|
Properties prop;
|
|
|
|
|
|
|
|
@BeforeTest
|
|
|
|
public void setUp()
|
|
|
|
throws SQLException {
|
|
|
|
this.prop = new LineageTest().properties;
|
|
|
|
ajc = new AzJobChecker(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getRecentFinishedJobFromFlowTest()
|
|
|
|
throws SQLException, IOException {
|
|
|
|
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow();
|
|
|
|
for (AzkabanJobExecRecord a : results) {
|
|
|
|
System.out.print(a.getFlowExecId() + "\t");
|
|
|
|
System.out.print(a.getJobName() + "\t");
|
|
|
|
System.out.println(a.getJobExecId());
|
|
|
|
}
|
|
|
|
Assert.assertNotNull(results);
|
|
|
|
}
|
|
|
|
|
2015-12-11 19:46:35 -08:00
|
|
|
public void getRecentFinishedJobFromFlowTest2()
|
|
|
|
throws SQLException, IOException {
|
|
|
|
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow(2, 1448916456L);
|
|
|
|
for (AzkabanJobExecRecord a : results) {
|
|
|
|
System.out.print(a.getFlowExecId() + "\t");
|
|
|
|
System.out.print(a.getJobName() + "\t");
|
|
|
|
System.out.println(a.getJobExecId());
|
|
|
|
}
|
|
|
|
Assert.assertNotNull(results);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void parseNestedJsonTest()
|
|
|
|
throws IOException, URISyntaxException {
|
|
|
|
|
2015-12-15 17:15:43 -08:00
|
|
|
URL url = Thread.currentThread().getContextClassLoader().getResource("nestedFlowContent.json");
|
2015-12-11 19:46:35 -08:00
|
|
|
byte[] encoded = Files.readAllBytes(Paths.get(url.getPath()));
|
|
|
|
String nestedJson = new String(encoded, "UTF-8");
|
|
|
|
List<AzkabanJobExecRecord> result = ajc.parseJson(nestedJson, 11111);
|
|
|
|
for (int i = 0; i < result.size(); i++) {
|
|
|
|
AzkabanJobExecRecord aje = result.get(i);
|
|
|
|
System.out.println(aje.getJobExecId());
|
|
|
|
System.out.println(aje.getJobName());
|
|
|
|
System.out.println(aje.getStartTime());
|
|
|
|
System.out.println(aje.getEndTime());
|
|
|
|
System.out.println(aje.getFlowPath());
|
|
|
|
System.out.println();
|
|
|
|
Assert.assertEquals((long) aje.getJobExecId(), 11111 * 1000 + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-19 14:39:21 -08:00
|
|
|
}
|