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

feat: filter out acceptance tests from validator usage report #1683

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public class Arguments {
description = "Export notices schema")
private boolean exportNoticeSchema = false;

@Parameter(
names = {"-svu", "--skip_validator_update"},
description = "Skips check for new validator version")
private boolean skipValidatorUpdate = false;

ValidationRunnerConfig toConfig() throws URISyntaxException {
ValidationRunnerConfig.Builder builder = ValidationRunnerConfig.builder();
if (input != null) {
Expand Down Expand Up @@ -135,6 +140,7 @@ ValidationRunnerConfig toConfig() throws URISyntaxException {
}
builder.setNumThreads(numThreads);
builder.setPrettyJson(pretty);
builder.setSkipValidatorUpdate(skipValidatorUpdate);
return builder.build();
}

Expand Down
1 change: 1 addition & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
| `-n` | `--export_notices_schema` | Optional | Export notice schema as a json file. |
| `-p` | `--pretty` | Optional | Pretty JSON validation report. If specified, the JSON validation report will be printed using JSON Pretty print. This does not impact data parsing. |
| `-d` | `--date` | Optional | The date used to validate the feed for time-based rules, e.g feed_expiration_30_days, in ISO_LOCAL_DATE format like '2001-01-30'. By default, the current date is used. |
| `-svu` | `--skip_validator_update` | Optional | Skip GTFS version validation update check. If specified, the GTFS version validation will be skipped. |
cka-y marked this conversation as resolved.
Show resolved Hide resolved

⚠️ Note that exactly one of the following options must be provided: `--url` or `--input`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public ValidationRunner(VersionResolver versionResolver) {
}

public Status run(ValidationRunnerConfig config) {
VersionInfo versionInfo = versionResolver.getVersionInfoWithTimeout(Duration.ofSeconds(5));
VersionInfo versionInfo =
versionResolver.getVersionInfoWithTimeout(
Duration.ofSeconds(5), config.skipValidatorUpdate());
logger.atInfo().log("VersionInfo: %s", versionInfo);
if (versionInfo.updateAvailable()) {
logger.atInfo().log("A new version of the validator is available!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public Path systemErrorsReportPath() {
// If true, any output json will be pretty-printed.
public abstract boolean prettyJson();

// If true, the validator will not validate the latest version.
cka-y marked this conversation as resolved.
Show resolved Hide resolved
public abstract boolean skipValidatorUpdate();

public static Builder builder() {
// Set reasonable defaults where appropriate.
return new AutoValue_ValidationRunnerConfig.Builder()
Expand All @@ -72,7 +75,8 @@ public static Builder builder() {
.setNumThreads(1)
.setPrettyJson(false)
.setCountryCode(CountryCode.forStringOrUnknown(CountryCode.ZZ))
.setDateForValidation(LocalDate.now());
.setDateForValidation(LocalDate.now())
.setSkipValidatorUpdate(false);
}

@AutoValue.Builder
Expand All @@ -97,6 +101,8 @@ public abstract static class Builder {

public abstract Builder setPrettyJson(boolean prettyJson);

public abstract Builder setSkipValidatorUpdate(boolean skipValidatorUpdate);

public abstract ValidationRunnerConfig build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public VersionResolver(ApplicationType applicationType) {
* Attempts to resolve the application {@link VersionInfo} within the specified timeout. If the
* version info can't be resolved in the specified timeout, an empty info will be returned.
*/
public VersionInfo getVersionInfoWithTimeout(Duration timeout) {
public VersionInfo getVersionInfoWithTimeout(Duration timeout, boolean skipValidatorUpdate) {
try {
resolve();
resolve(skipValidatorUpdate);
return resolvedVersionInfo.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
} catch (Throwable ex) {
return VersionInfo.empty();
Expand All @@ -65,7 +65,7 @@ public VersionInfo getVersionInfoWithTimeout(Duration timeout) {
* becomes available.
*/
public void addCallback(Consumer<VersionInfo> callback) {
resolve();
resolve(false);
Futures.addCallback(
resolvedVersionInfo,
new FutureCallback<>() {
Expand All @@ -83,7 +83,7 @@ public void onFailure(Throwable t) {
}

/** Starts version resolution on a background thread. */
public synchronized void resolve() {
public synchronized void resolve(boolean skipValidatorUpdate) {
if (resolutionStarted) {
return;
}
Expand All @@ -93,7 +93,10 @@ public synchronized void resolve() {
() -> {
try {
Optional<String> currentVersion = resolveCurrentVersion();
Optional<String> latestReleaseVersion = resolveLatestReleaseVersion(currentVersion);
Optional<String> latestReleaseVersion = Optional.empty();
if (!skipValidatorUpdate) {
latestReleaseVersion = resolveLatestReleaseVersion(currentVersion);
}
VersionInfo info = VersionInfo.create(currentVersion, latestReleaseVersion);
resolvedVersionInfo.set(info);
return info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testResolveLatestReleaseVersion() throws IOException {
mockStreamHandler.setContent("{\"version\":\"10.0.5\"}");

VersionResolver checker = new VersionResolver(ApplicationType.CLI);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT, false);

assertThat(versionInfo.latestReleaseVersion()).hasValue("10.0.5");
}
Expand All @@ -53,7 +53,7 @@ public void testLatestReleaseVersionNotFound() throws IOException {
mockStreamHandler.setContent("Page not found");

VersionResolver checker = new VersionResolver(ApplicationType.CLI);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT, false);

assertThat(versionInfo.latestReleaseVersion()).isEmpty();
}
Expand All @@ -67,7 +67,7 @@ public void testReleaseVersionUrlParams() throws IOException {
mockStreamHandler.setContent("{\"version\":\"10.0.5\"}");

VersionResolver checker = new VersionResolver(ApplicationType.WEB);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT, false);

assertThat(mockStreamHandler.url).isNotNull();
assertThat(mockStreamHandler.url.getQuery())
Expand All @@ -81,7 +81,7 @@ public void testLocalVersion() {
assertThat(expectedVersion).isNotEmpty();

VersionResolver checker = new VersionResolver(ApplicationType.CLI);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT);
VersionInfo versionInfo = checker.getVersionInfoWithTimeout(TIMEOUT, false);

assertThat(versionInfo.currentVersion()).hasValue(expectedVersion);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/queue_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ do
ID=$(jq '.id' <<< "$item")
URL=$(jq '.url' <<< "$item")
path_name=${ID//\"/}
java -Xmx10G -Xms8G -jar gtfs-validator-snapshot/gtfs-validator*.jar --url $URL --output_base $OUTPUT_BASE/output/$path_name --validation_report_name latest.json --system_errors_report_name latest_errors.json
java -Xmx10G -Xms8G -jar gtfs-validator-snapshot/gtfs-validator*.jar --url $URL --output_base $OUTPUT_BASE/output/$path_name --validation_report_name latest.json --system_errors_report_name latest_errors.json --skip_validator_update
if [ "$master" = "--include-master" ];
then
java -Xmx10G -Xms8G -jar gtfs-validator-master/gtfs-validator*.jar --url $URL --output_base $OUTPUT_BASE/output/$path_name --validation_report_name reference.json --system_errors_report_name reference_errors.json
Expand Down
Loading