Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix jdkDate parser #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions TestResultSummaryService/parsers/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class Parser {

exactJavaVersion(output) {
const javaVersionRegex = /=JAVA VERSION OUTPUT BEGIN=[\r\n]+([\s\S]*?)[\r\n]+.*=JAVA VERSION OUTPUT END=/;
const javaBuildDateRegex = /\s([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01])/;
const javaBuildDateRegex = /build.*?(([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01]))/;
const javaOpenJDKVersionRegex = /openjdk version.*?(([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01]))/;
const sdkResourceRegex = /.*?SDK_RESOURCE\=(.*)[\r\n]+/;
let curRegexResult = null;
let javaVersion, jdkDate, sdkResource;
let javaVersion, jdkDateOriginal, jdkDate, sdkResource;
if ( ( curRegexResult = javaVersionRegex.exec( output ) ) !== null ) {
javaVersion = removeTimestamp(curRegexResult[1]);
}
Expand All @@ -23,7 +24,20 @@ class Parser {
curRegexResult = null;
// parse jdk date from javaVersion
if ( ( curRegexResult = javaBuildDateRegex.exec( javaVersion ) ) !== null ) {
jdkDate = curRegexResult[0];
jdkDateOriginal = curRegexResult[1];
} else {
curRegexResult = null;
if ( ( curRegexResult = javaOpenJDKVersionRegex.exec( javaVersion) ) != null) {
jdkDateOriginal = curRegexResult[1];
}
}
if (jdkDateOriginal) {
jdkDateOriginal = jdkDateOriginal.replace(/\-/g, '');
const year = jdkDateOriginal.slice(0, 4);
const month = jdkDateOriginal.slice(4, 6);
const day = jdkDateOriginal.slice(6, 8);
const date = year + "-" + month + "-" + day;
jdkDate = new Date(date);
}
return { javaVersion, jdkDate, sdkResource };
}
Expand Down
6 changes: 3 additions & 3 deletions TestResultSummaryService/routes/getTabularData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { TestResultsDB, ObjectID } = require( '../Database' );

function exceedDate(jdkDate) {
return function(element) {
return parseInt(element.jdkDate) <= parseInt(jdkDate);
return new Date(element.jdkDate).getTime() <= new Date(jdkDate).getTime();
}
}

Expand Down Expand Up @@ -55,9 +55,9 @@ module.exports = async ( req, res ) => {
// Remove all entries whose build date exceeds the chosen date
const exceedFilter = result.filter(exceedDate(req.query.jdkDate));
// Setting the latest build date from the available dates
const latestDate = Math.max.apply(Math, exceedFilter.map(function(o) { return parseInt(o.jdkDate); }));
const latestDate = Math.max.apply(Math, exceedFilter.map(function(o) { return new Date(o.jdkDate); }));
// Remove all runs that are not the latest
const dateFilter = exceedFilter.filter(entry => parseInt(entry.jdkDate) === latestDate);
const dateFilter = exceedFilter.filter(entry => new Date(entry.jdkDate).getTime() === latestDate);
const latest = Math.max.apply(Math, dateFilter.map(function(o) { return o.timestamp; }));
// Keep the latest build with the latest timestamp
const latestRun = dateFilter.find(function(o){ return o.timestamp == latest; })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';
import Settings from '../Settings';
import StockChart from './ChartComponent/StockChart';
import { getStatisticValues, handlePointClick } from './utils';
import { fetchData } from '../../../utils/Utils';
import { getStatisticValues, handlePointClick, formatDate } from './utils';

const builds = ["Test_openjdk8_j9_sanity.perf_x86-64_linux",
"Test_openjdk11_j9_sanity.perf_x86-64_linux",
Expand Down Expand Up @@ -55,7 +55,7 @@ export default class Dacapo extends Component {
results.forEach((t, i) => {
let jdkDate = t.jdkDate;
if (t.buildResult !== "SUCCESS" || !jdkDate) return;
jdkDate = jdkDate.replaceAll('-', '');
jdkDate = formatDate(jdkDate.trim());
resultsByJDKBuild[jdkDate] = resultsByJDKBuild[jdkDate] || [];
t.tests.forEach((test, i) => {
let eclipse = null;
Expand Down
47 changes: 33 additions & 14 deletions test-result-summary-client/src/Dashboard/Widgets/Graph/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,34 @@ export const parseSha = (str, sha) => {
return null;
}

// this method should be deleted after total cleanup of Renaissance.jsx
export const getEpochTime = (str) => {
// str has the form "\syyyymmdd"
if (str.length === 9) {
let year = parseInt(str.slice(0, 5));
// UTC format has month 0 - 11
let month = parseInt(str.slice(5, 7)) - 1;
let day = parseInt(str.slice(7, 9));
return Date.UTC(year, month, day);
} else {
return null;
}
// str has the form "yyyymmdd" or "\syyyymmdd"
str = str.trim();
if (str.length === 8) {
let year = parseInt(str.slice(0, 4));
// UTC format has month 0 - 11
let month = parseInt(str.slice(4, 6)) - 1;
let day = parseInt(str.slice(6, 8));
return Date.UTC(year, month, day);
} else {
return null;
}
}

// TODO: delete this function after a few months when all jdkDate are in the date format
export const formatDate = (str) => {
const oldFormatRegex = /\d{8}/;
let curRegexResult = null;
if ( ( curRegexResult = oldFormatRegex.exec(str) ) != null) {
let year = parseInt(str.slice(0, 4));
let month = parseInt(str.slice(4, 6));
let day = parseInt(str.slice(6, 8));
let date = year + "-" + month + "-" + day;
return date;
} else {
return str;
}
}

export const getStatisticValues = (resultsByJDKBuild, key) => {
Expand All @@ -41,8 +58,10 @@ export const getStatisticValues = (resultsByJDKBuild, key) => {
let mean = [];
let median = [];

math.sort(Object.keys(resultsByJDKBuild)).forEach((k, i) => {
const date = getEpochTime(k);
Object.keys(resultsByJDKBuild).sort( function (a,b)
{ return new Date(a).getTime() - new Date(b).getTime(); })
.forEach((k, i) => {
const date = new Date(k);

let group = resultsByJDKBuild[k].map(x => x[key]).filter(function (el) {
return el != null;
Expand All @@ -54,13 +73,13 @@ export const getStatisticValues = (resultsByJDKBuild, key) => {
mean.push([date, math.mean(values)]);
median.push([date, math.median(values)]);
}

});
return [data, std, mean, median];
}

export const handlePointClick = (event) => {
const { buildName, buildNum, javaVersion, jdkDate, testId } = event.point.additionalData[0];
const { buildName, buildNum, jdkDate, testId } = event.point.additionalData[0];
let { javaVersion } = event.point.additionalData[0];

const buildLinks = ` <a href="/output/test?id=${testId}">${buildName} #${buildNum}</a>`;
const CIstr = (typeof event.point.CI === 'undefined') ? `` : `CI = ${event.point.CI}`;
Expand Down
4 changes: 2 additions & 2 deletions test-result-summary-client/src/TabularView/TabularView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class TabularView extends Component {
const month = (new Date().getMonth() + 1).toString(); //Current Month
const year = (new Date().getFullYear()).toString(); //Current Year
// Assumption: JDK date is in the format of YYYYMMDD in database, example: 20190814
const jdkDate = year + ((month.length < 2) ? "0" + month : month) + ((date.length < 2) ? "0" + date : date)
const jdkDate = year + '-' + ((month.length < 2) ? "0" + month : month) + '-' + ((date.length < 2) ? "0" + date : date)

/*
Each database entry should contain a pipeline name (buildName) which contains the JDK Version and JVM Type.
Expand Down Expand Up @@ -325,7 +325,7 @@ export default class TabularView extends Component {
dateTransform(date, type) {
const dateSplit = date.split('/');
// Database date format: YYYYMMDD
const jdkDate = dateSplit[2] + ((dateSplit[0].length < 2) ? "0" + dateSplit[0] : dateSplit[0]) + ((dateSplit[1].length < 2) ? "0" + dateSplit[1] : dateSplit[1]);
const jdkDate = dateSplit[2] + '-' + ((dateSplit[0].length < 2) ? "0" + dateSplit[0] : dateSplit[0]) + '-' + ((dateSplit[1].length < 2) ? "0" + dateSplit[1] : dateSplit[1]);

if (type === 'test') {
this.setState({testJdkDate: jdkDate});
Expand Down