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

[BUG] Fixed some failing unit tests on Windows #968

Merged
merged 3 commits into from
Feb 1, 2022

Conversation

graytaylor0
Copy link
Member

@graytaylor0 graytaylor0 commented Feb 1, 2022

Description

There are a handful of unit tests that fail when running on Windows. This PR fixes some of them. The reasons for failing tests include:

  1. Instant comparison is too strict and varies based on CPU
  2. YAMLGenerator needs to enable USE_PLATFORM_LINE_BREAKS to not always default to Unix \n (Windows standard is \r\n
  3. Test paths are created with /, while windows uses \

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@graytaylor0 graytaylor0 requested a review from a team as a code owner February 1, 2022 16:46
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving our tests!

@@ -93,7 +93,7 @@ public void testBuild_withoutTimeReceived() {
final Instant timeReceived = result.getTimeReceived();
assertThat(timeReceived, notNullValue());
assertThat(timeReceived, is(greaterThan(before)));
assertThat(timeReceived, is(lessThan(Instant.now())));
assertThat(timeReceived, is(lessThan(Instant.now().plusSeconds(1))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you are adding second incase the times are the same. You be able to use lessThanOrEqualTo instead.

@@ -65,10 +67,12 @@ public void testGivenNullArgumentThenThrowException() {
public void testGivenLogstashConfigPathThenPipelineConfigCreated() {
final DataPrepperArgs args = new DataPrepperArgs(LOGSTASH_PIPELINE_FILE_PATH, DP_CONFIG_YAML_FILE_PATH);

final String configFileEnding = String.format("src%stest%sresources%slogstash-filter.yaml", File.separator, File.separator, File.separator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably write this as:

Paths.get("src", "test, "resources", "logstash-filter.yaml");

@@ -64,8 +64,8 @@ public void testWriteMetrics() throws TimeoutException {
Assert.assertTrue(
MetricsTestUtil.isBetween(
MetricsTestUtil.getMeasurementFromList(writeTimeMeasurements, Statistic.TOTAL_TIME).getValue(),
0.5,
0.6));
0.4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 0.45 and 0.65 work here? Similar to what you did in testWriteAllMetrics?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should still work yes. I can tighten it to that.

Signed-off-by: Taylor Gray <[email protected]>
@codecov-commenter
Copy link

Codecov Report

Merging #968 (2adcb07) into main (e5434f6) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #968   +/-   ##
=========================================
  Coverage     91.36%   91.36%           
  Complexity      683      683           
=========================================
  Files            84       84           
  Lines          1993     1993           
  Branches        168      168           
=========================================
  Hits           1821     1821           
  Misses          132      132           
  Partials         40       40           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5434f6...2adcb07. Read the comment docs.

Copy link
Contributor

@sshivanii sshivanii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@graytaylor0 graytaylor0 merged commit f78fa62 into opensearch-project:main Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants