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

Update dependencies20230123 #110

Merged
merged 9 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
634 changes: 383 additions & 251 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ path = "src/bin/test_server.rs"

[dependencies]
atty = "0.2"
base64 = "0.13"
base64 = "0.21"
body_reader = { path = "./lib/body_reader" }
bytes = "1"
channel = { path = "./lib/channel" }
clap = { version = "3", features = ["cargo"] }
clap = { version = "4", features = ["cargo", "std", "help", "usage", "error-context", "wrap_help"], default-features = false }
config = { path = "./lib/config" }
csv = "1"
ctrlc = "3"
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
large-error-threshold = 256
5,728 changes: 3,182 additions & 2,546 deletions guide/results-viewer-react/package-lock.json

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions guide/results-viewer-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,48 @@
"homepage": "https://github.com/FamilySearch/pewpew/tree/master/lib/config-wasm#readme",
"dependencies": {
"@fs/hdr-histogram-wasm": "file:./lib/hdr-histogram-wasm",
"chart.js": "^3.9.1",
"chartjs-adapter-date-fns": "^2.0.0",
"chart.js": "~4.2.0",
"chartjs-adapter-date-fns": "^3.0.0",
"date-fns": "^2.29.3",
"file-saver": "^2.0.5",
"immutability-helper": "^3.1.1",
"js-yaml": "^4.1.0",
"react": "^18.2.0",
"react-accessible-accordion": "^5.0.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.2",
"react-dropzone": "^14.2.3",
"react-transition-group": "^4.4.5",
"styled-components": "^5.3.5"
"styled-components": "^5.3.6"
},
"devDependencies": {
"@babel/core": "^7.19.1",
"@storybook/addon-actions": "^6.5.12",
"@storybook/addon-essentials": "^6.5.12",
"@storybook/addon-interactions": "^6.5.12",
"@storybook/addon-links": "^6.5.12",
"@storybook/builder-webpack5": "^6.5.12",
"@storybook/manager-webpack5": "^6.5.12",
"@storybook/react": "^6.5.12",
"@babel/core": "^7.20.12",
"@storybook/addon-actions": "^6.5.16",
"@storybook/addon-essentials": "^6.5.16",
"@storybook/addon-interactions": "^6.5.16",
"@storybook/addon-links": "^6.5.16",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/testing-library": "0.0.13",
"@types/chart.js": "^2.9.37",
"@types/file-saver": "^2.0.5",
"@types/har-format": "^1.2.8",
"@types/har-format": "^1.2.10",
"@types/js-yaml": "^4.0.5",
"@types/react": "^18.0.20",
"@types/react-dom": "^18.0.6",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react-transition-group": "^4.4.5",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"babel-loader": "^8.2.5",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"babel-loader": "^8.3.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"html-webpack-plugin": "^5.5.0",
"ts-loader": "^9.3.1",
"typescript": "^4.8.3",
"webpack": "^5.74.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.0"
"webpack-dev-server": "^4.11.1"
}
}
2 changes: 2 additions & 0 deletions guide/results-viewer-react/src/chartjs-adapter-date-fns.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://stackoverflow.com/questions/72374653/typescript-types-for-chartjs-adapter-date-fns
declare module "chartjs-adapter-date-fns";
19 changes: 8 additions & 11 deletions guide/results-viewer-react/src/components/TestResults/charts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "chartjs-adapter-date-fns";
import {
Chart,
ChartDataset,
Expand All @@ -12,6 +11,7 @@ import {
LinearScale,
LogarithmicScale,
PointElement,
ScatterDataPoint,
TimeScale,
Title,
Tooltip
Expand Down Expand Up @@ -69,44 +69,41 @@ export function RTT (el: HTMLCanvasElement, dataPoints: DataPoint[]): Chart {
const borderColor = colors[i % colors.length];
const backgroundColor = borderColor + "46";
let label: string;
let data: Chart.ChartPoint[];
// eslint-disable-next-line eqeqeq
if (type == "avg") {
// It's a ScatterDataPoint but thanks to chartjs-adapter-date-fns it will date Dates as well as numbers
let data: (Omit<ScatterDataPoint, "x"> & { x: Date | number })[];
if (type === "avg") {
label = "Avg";
data = dataPoints.map((dp) => ({
x: dp.time,
y: dp.rttHistogram.getTotalCount()
? Math.round(dp.rttHistogram.getMean()) / MICROS_TO_MS
: NaN
}));
// eslint-disable-next-line eqeqeq
} else if (type == "min") {
} else if (type === "min") {
label = "Min";
data = dataPoints.map((dp) => ({
x: dp.time,
y: dp.rttHistogram.getTotalCount()
? Number(dp.rttHistogram.getMinNonZeroValue()) / MICROS_TO_MS
: NaN
}));
// eslint-disable-next-line eqeqeq
} else if (type == "max") {
} else if (type === "max") {
label = "Max";
data = dataPoints.map((dp) => ({
x: dp.time,
y: dp.rttHistogram.getTotalCount()
? Number(dp.rttHistogram.getMaxValue()) / MICROS_TO_MS
: NaN
}));
// eslint-disable-next-line eqeqeq
} else if (type == "std") {
} else if (type === "std") {
label = "Std Dev";
data = dataPoints.map((dp) => ({
x: dp.time,
y: dp.rttHistogram.getTotalCount()
? Math.round(dp.rttHistogram.getStdDeviation()) / MICROS_TO_MS
: NaN
}));
} else if (typeof type == "number") {
} else if (typeof type === "number") {
label = type + "th PCTL";
data = dataPoints.map((dp) => ({
x: dp.time,
Expand Down
29 changes: 22 additions & 7 deletions guide/results-viewer-react/src/components/TestResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface TestResultProps {
}

export interface TestResultState {
defaultMessage: string;
/** Filters the results Data by a tag equalling this value. I.e. 'method', 'url', '_id' */
summaryTagFilter: string;
/** Filters the results Data by a summaryTagFilter's value containing this value */
Expand Down Expand Up @@ -155,8 +156,7 @@ const minMaxTime = (testResults: any) => {

const startTime3: Date = new Date(startTime2);
const endTime3: Date = new Date(endTime2);
// eslint-disable-next-line eqeqeq
const includeDateWithStart = startTime3.toLocaleDateString() == endTime3.toLocaleDateString();
const includeDateWithStart = startTime3.toLocaleDateString() === endTime3.toLocaleDateString();
testTimes.startTime = dateToString(startTime3, includeDateWithStart);
testTimes.endTime = dateToString(endTime3, false);

Expand Down Expand Up @@ -189,8 +189,12 @@ const freeHistograms = (resultsData: ParsedFileEntry[] | undefined, summaryData:
for (const [bucketId, dataPoints] of oldData) {
let counter = 0;
for (const dataPoint of dataPoints) {
log(`Freeing histogram ${JSON.stringify(bucketId)}: ${counter++}`, LogLevel.DEBUG);
dataPoint.rttHistogram.free();
try {
log(`Freeing histogram ${JSON.stringify(bucketId)}: ${counter++}`, LogLevel.DEBUG);
dataPoint.rttHistogram.free();
} catch (error) {
log(`Freeing histogram ${JSON.stringify(bucketId)} failed: ${counter}`, LogLevel.WARN, error);
}
}
}
};
Expand Down Expand Up @@ -280,7 +284,9 @@ const getSummaryData = ({
};

export const TestResults = ({ resultsText }: TestResultProps) => {
const defaultMessage = "Select Results File";
const defaultState: TestResultState = {
defaultMessage,
summaryTagFilter: "",
summaryTagValueFilter: "",
resultsData: undefined,
Expand All @@ -296,6 +302,9 @@ export const TestResults = ({ resultsText }: TestResultProps) => {
setState((oldState: TestResultState) => ({ ...oldState, ...newState }));

const updateResultsData = async (resultsText: string): Promise<void> => {
updateState({
defaultMessage: "Results Loading..."
});
try {
// if there are multiple jsons (new format), split them up and parse them separately
const results = resultsText.replace(/}{/g, "}\n{")
Expand Down Expand Up @@ -324,6 +333,7 @@ export const TestResults = ({ resultsText }: TestResultProps) => {

log("updateResultsData", LogLevel.DEBUG, { filteredData: filteredData?.length, resultsData: resultsData?.length, summaryData });
updateState({
defaultMessage,
resultsData,
filteredData,
summaryData,
Expand All @@ -333,6 +343,7 @@ export const TestResults = ({ resultsText }: TestResultProps) => {
} catch (error) {
log("Error parsing Data", LogLevel.ERROR, error);
updateState({
defaultMessage,
error: formatError(error)
});
}
Expand Down Expand Up @@ -376,6 +387,11 @@ export const TestResults = ({ resultsText }: TestResultProps) => {
});
};

useEffect(() => {
import("chartjs-adapter-date-fns")
.catch((error) => log("Could not load chartjs-adapter-date-fns import", LogLevel.ERROR, error));
}, []);

useEffect(() => {
updateResultsData(resultsText);
}, [resultsText]);
Expand Down Expand Up @@ -422,7 +438,7 @@ export const TestResults = ({ resultsText }: TestResultProps) => {
})}
</TIMETAKEN>
) : (
<p>No Results Found</p>
<p>{state.defaultMessage}</p>
)}
</React.Fragment>
);
Expand Down Expand Up @@ -562,8 +578,7 @@ const Endpoint = ({ bucketId, dataPoints }: EndpointProps) => {
</H3>
<UL>
{Object.entries(bucketId).map(([key, value], idx) => {
// eslint-disable-next-line eqeqeq
if (key != "method" && key != "url") {
if (key !== "method" && key !== "url") {
return (
<li key={idx}>
{key} - {value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type Check = [string, CheckType];

// eslint-disable-next-line @typescript-eslint/ban-types
function isObject (o: unknown): o is object {
return typeof o == "object" && !!o;
return typeof o === "object" && !!o;
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ function isStatusCounts (sc: unknown): sc is StatusCounts {
// check that the keys can be parsed as a number and the values are numbers
return Object.entries(sc).every(
([k, v]: [string, unknown]) =>
Number.parseInt(k, 10) > 0 && typeof v == "number"
Number.parseInt(k, 10) > 0 && typeof v === "number"
);
}

Expand All @@ -181,7 +181,7 @@ function isTestErrors (sc: unknown): sc is TestErrors {
return false;
}
// check that the values are all numbers
return Object.values(sc).every((v: unknown) => typeof v == "number");
return Object.values(sc).every((v: unknown) => typeof v === "number");
}

export interface DataPointPreProcessed {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export interface YamlWriterFormState {
}

const nameReg = new RegExp("^[A-Za-z_-].*$");
// eslint-disable-next-line no-useless-escape
const valueReg = new RegExp("^[A-Za-z0-9_-\{\}\$].*$");
const valueReg = new RegExp("^[A-Za-z0-9_-{}$].*$");

const defaults = "default";
type YamlWriterBooleanState = "default" | "filterHeaders" | "authenticated";
Expand Down
Loading