Skip to content

Make pastDateExpression test more stable#836

Merged
snuyanzin merged 1 commit into
datafaker-net:mainfrom
snuyanzin:date2
May 16, 2023
Merged

Make pastDateExpression test more stable#836
snuyanzin merged 1 commit into
datafaker-net:mainfrom
snuyanzin:date2

Conversation

@snuyanzin

Copy link
Copy Markdown
Collaborator

No description provided.

@kingthorin

Copy link
Copy Markdown
Collaborator

Is this a timezone issue?

@snuyanzin

Copy link
Copy Markdown
Collaborator Author

i suspect kind of NTP...
there are 3 times when new Date() is called via datafaker's api and then a check that second is between first and last...

@bodiam

bodiam commented May 15, 2023

Copy link
Copy Markdown
Contributor

You triggered a new build?

Seems the code isn't completely repeatable:

  ["name.nameWithMiddle"="Gavin Durgan Bauch Jr."]
but the following map entries had different values:
  ["name.nameWithMiddle"="Gavin Durgan Bauch and Sons" (expected: "Gavin Durgan Bauch Jr.")]

@snuyanzin

Copy link
Copy Markdown
Collaborator Author

yes, somehow it appeared today not only for this PR

@bodiam

bodiam commented May 15, 2023

Copy link
Copy Markdown
Contributor

Well, at least it's nice that it's consistently failing...

@bodiam

bodiam commented May 15, 2023

Copy link
Copy Markdown
Contributor

I just tried it locally, with Java 20 on a Mac, and it seems to work fine.

@bodiam

bodiam commented May 15, 2023

Copy link
Copy Markdown
Contributor

Correction: I can reproduce this quite often.

This never fails though:

    @RepeatedTest(10000)
    void name() {
        Faker faker1 = new Faker(new Random(0));
        Faker faker2 = new Faker(new Random(0));

        assertThat(faker1.name().nameWithMiddle()).isEqualTo(faker2.name().nameWithMiddle());
    }

But having a RepeatedTest(100) on the shouldCreateRepeatableValues makes it fail (in)consistently: around 30-60% of the tests fail.

Could it somehow be a caching or concurrency issue?

@snuyanzin

Copy link
Copy Markdown
Collaborator Author

looks like the issue is with concurrent tests
#837 should improve it

@bodiam

bodiam commented May 15, 2023

Copy link
Copy Markdown
Contributor

I just went through the git history, and git d9c2cc262d29deb3552c9f49ab71edf0b3f6dc30 caused it. Before this, the tests worked fine, but after this one, the test started breaking (ironically called: "Make FakeValuesService thread safe")

@snuyanzin snuyanzin merged commit 9cd1d73 into datafaker-net:main May 16, 2023
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.

3 participants