use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class InspectorSerializer method main.
public static void main(String[] args) throws IOException, GeneralSecurityException {
GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
Sheets sheets = GoogleSpreadSheetFactory.getSheets();
List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "All data!A:L").execute().getValues();
MongoConnection mongoConnection = new MongoConnection(args[0], "repairnator");
if (!mongoConnection.isConnected()) {
throw new RuntimeException("Error when connection to mongodb");
}
MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
List<SerializedData> data = new ArrayList<>();
for (int i = 1; i < results.size(); i++) {
List<Object> value = results.get(i);
JsonObject result = new JsonObject();
result.addProperty("buildId", Utils.getValue(value, 0));
result.addProperty("repositoryName", Utils.getValue(value, 1));
result.addProperty("status", Utils.getValue(value, 2));
result.addProperty("prNumber", Utils.getValue(value, 3));
result.addProperty("buildFinishedDate", Utils.getValue(value, 4));
result.addProperty("buildFinishedDay", Utils.getValue(value, 5));
result.addProperty("realStatus", Utils.getValue(value, 6));
result.addProperty("hostname", Utils.getValue(value, 7));
result.addProperty("buildReproductionDate", Utils.getValue(value, 8));
result.addProperty("travisURL", Utils.getValue(value, 9));
result.addProperty("typeOfFailures", Utils.getValue(value, 10));
result.addProperty("runId", Utils.getValue(value, 11));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.INSPECTOR);
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class InspectorSerializer4Bears method main.
public static void main(String[] args) throws IOException, GeneralSecurityException {
GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
Sheets sheets = GoogleSpreadSheetFactory.getSheets();
List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "All data!A:Q").execute().getValues();
MongoConnection mongoConnection = new MongoConnection(args[0], "bears");
if (!mongoConnection.isConnected()) {
throw new RuntimeException("Error when connection to mongodb");
}
MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
List<SerializedData> data = new ArrayList<>();
for (int i = 1; i < results.size(); i++) {
List<Object> value = results.get(i);
JsonObject result = new JsonObject();
result.addProperty("buildId", Utils.getValue(value, 0));
result.addProperty("previousBuildId", Utils.getValue(value, 1));
result.addProperty("scannedBuildStatus", Utils.getValue(value, 2));
result.addProperty("status", Utils.getValue(value, 3));
result.addProperty("realStatus", Utils.getValue(value, 4));
result.addProperty("checkoutType", Utils.getValue(value, 5));
result.addProperty("typeOfFailures", Utils.getValue(value, 6));
result.addProperty("repositoryName", Utils.getValue(value, 7));
result.addProperty("prNumber", Utils.getValue(value, 8));
result.addProperty("buildFinishedDate", Utils.getValue(value, 9));
result.addProperty("buildFinishedDay", Utils.getValue(value, 10));
result.addProperty("hostname", Utils.getValue(value, 11));
result.addProperty("buildReproductionDate", Utils.getValue(value, 12));
result.addProperty("buildTravisUrl", Utils.getValue(value, 13));
result.addProperty("previousBuildTravisUrl", Utils.getValue(value, 14));
result.addProperty("committerEmail", Utils.getValue(value, 15));
result.addProperty("runId", Utils.getValue(value, 16));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.INSPECTOR4BEARS);
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class CleanProjectList method main.
public static void main(String[] args) throws IOException {
String projectPath = args[0];
String dbUrl = args[1];
String dbName = args[2];
String collectionName = args[3];
String destList = args[4];
List<String> allProjects = Files.readAllLines(new File(projectPath).toPath());
MongoConnection mongoConnection = new MongoConnection(dbUrl, dbName);
MongoDatabase database = mongoConnection.getMongoDatabase();
MongoCollection collection = database.getCollection(collectionName);
List<String> selectedProjects = new ArrayList<>();
for (String project : allProjects) {
Repository repo = RepositoryHelper.getRepositoryFromSlug(project);
if (repo != null) {
Build b = repo.getLastBuild(false);
if (b != null) {
if (b.getBuildTool() == BuildTool.MAVEN) {
long results = collection.count(and(eq("repositoryName", project), ne("typeOfFailures", null)));
if (results > 0) {
selectedProjects.add(project);
}
}
}
}
}
File outputFile = new File(destList);
BufferedWriter buffer = new BufferedWriter(new FileWriter(outputFile));
buffer.write(StringUtils.join(selectedProjects, "\n"));
buffer.close();
System.out.println("Read projects: " + allProjects.size() + " | Selected projects : " + selectedProjects.size());
System.out.println(StringUtils.join(selectedProjects, "\n"));
}
use of fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection in project repairnator by Spirals-Team.
the class ComputeTestFailingStats method main.
public static void main(String[] args) throws IOException {
if (args.length < 4) {
System.err.println("Usage: java ComputeTestFailingStats <url of mongodb with auth> <db name> <collection name> <path of the file to write>");
System.exit(-1);
}
Map<String, Integer> occurencesByFailure = new HashMap<>();
String dbCollectionUrl = args[0];
String dbName = args[1];
String collectionName = args[2];
String pathOutput = args[3];
File outputFile = new File(pathOutput);
MongoConnection mongoConnection = new MongoConnection(dbCollectionUrl, dbName);
MongoDatabase database = mongoConnection.getMongoDatabase();
MongoCollection<Document> collection = database.getCollection(collectionName);
Calendar limitDateFebruary2017 = Calendar.getInstance();
Calendar limitDateJanuary2018 = Calendar.getInstance();
limitDateFebruary2017.set(2017, Calendar.FEBRUARY, 1);
limitDateJanuary2018.set(2018, Calendar.JANUARY, 1);
Block<Document> block = new Block<Document>() {
@Override
public void apply(Document document) {
totalFailingBuild++;
String typeOfFailures = document.getString("typeOfFailures");
for (String failure : typeOfFailures.split(",")) {
if (failure.endsWith(":")) {
failure = failure.substring(0, failure.length() - 1);
}
if (failure.equals("skip") || failure.equals("skipped")) {
continue;
}
if (!occurencesByFailure.containsKey(failure)) {
occurencesByFailure.put(failure, 0);
}
int nbOcc = occurencesByFailure.get(failure);
nbOcc++;
occurencesByFailure.put(failure, nbOcc);
totalNumberOfFailures++;
}
}
};
collection.find(and(lt("buildFinishedDate", limitDateJanuary2018.getTime()), gt("buildFinishedDate", limitDateFebruary2017.getTime()), in("status", "PATCHED", "test errors", "test failure"))).forEach(block);
BufferedWriter buffer = new BufferedWriter(new FileWriter(outputFile));
buffer.write("failure\tNb Occurences\n");
buffer.flush();
for (Map.Entry<String, Integer> entry : occurencesByFailure.entrySet().stream().sorted(Map.Entry.comparingByValue(Collections.reverseOrder())).collect(Collectors.toList())) {
buffer.write(entry.getKey() + "\t" + entry.getValue() + "\n");
buffer.flush();
}
buffer.close();
System.out.println("Output written to " + pathOutput + " - " + totalFailingBuild + " failing build detected and " + totalNumberOfFailures + " failures counted.");
}
Aggregations