Skip to content

Conversation

@tvernum
Copy link
Contributor

@tvernum tvernum commented Aug 19, 2025

This changes the random patterns that are generated inside GlobTests to not generate * characters when a literal string is intended

This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
@tvernum tvernum added the >test Issues or PRs that are addressing/adding tests label Aug 19, 2025
@tvernum tvernum requested a review from a team as a code owner August 19, 2025 06:45
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Aug 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

assertNonMatch("123*", "abc123def");

var prefix = randomAsciiString(randomIntBetween(2, 12));
var prefix = randomAsciiStringNoAsterisks(randomIntBetween(2, 12));
Copy link
Contributor

Choose a reason for hiding this comment

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

This was testing (potentially) things with multiple * before, like a "prefix" 123*45* (and I think the assertions were correct too?); are we sure this is not something we want to test?

Copy link
Contributor Author

@tvernum tvernum Aug 19, 2025

Choose a reason for hiding this comment

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

If prefix was *a then pattern would be *a*

That works (logically) for the matches

  • *a* matches *a
  • *a* matches *a + random

But it breaks the logic for the non-matches
For example:

assertNonMatch(pattern, prefix.substring(1));

That would test ("*a*" , "a") which would match, when it is not supposed to.
The intent of that test is that prefix is a literal (e.g. ab) so that ab* does not match b

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, there are randoms for which the test would fail.
Seems fair, if we feel the need for a test with multiple * we can add it explicitly, and be more precise in these prefix/suffix tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the range in these tests randomIntBetween(2, 12)? That seems an odd choice that explicitly avoids an important corner case: shouldn't 1 also work? And, what's the benefit from testing lengths greater than 2? I think we ought to use something more like randomIntBetween(1,2) here.

assertNonMatch("123*", "abc123def");

var prefix = randomAsciiString(randomIntBetween(2, 12));
var prefix = randomAsciiStringNoAsterisks(randomIntBetween(2, 12));
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, there are randoms for which the test would fail.
Seems fair, if we feel the need for a test with multiple * we can add it explicitly, and be more precise in these prefix/suffix tests.

@tvernum tvernum added the auto-backport Automatically create backport pull requests when merged label Aug 19, 2025
@tvernum tvernum merged commit 8ae8a10 into elastic:main Aug 19, 2025
34 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.18
9.0
9.1
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 133114

tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
elasticsearchmachine pushed a commit that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
elasticsearchmachine pushed a commit that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
elasticsearchmachine pushed a commit that referenced this pull request Aug 19, 2025
This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
@JVerwolf
Copy link
Contributor

tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 20, 2025
…lastic#133125)

This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 20, 2025
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Aug 20, 2025
elasticsearchmachine pushed a commit that referenced this pull request Aug 20, 2025
* Make Glob non-recursive (#132798)

This changes the implementation of `Glob` (used by `FilterPath`)
to use a non-recursive algorithm for improved efficiency and
stability

* [Test] Don't include '*' in glob pattern literals (#133114) (#133125)

This changes the random patterns that are generated inside `GlobTests`
to not generate `*` characters when a literal string is intended
tvernum added a commit that referenced this pull request Aug 20, 2025
@prdoyle
Copy link
Contributor

prdoyle commented Aug 20, 2025

@JVerwolf - confirmed, it does fix all those tests.

@prdoyle
Copy link
Contributor

prdoyle commented Aug 20, 2025

Looks like @tvernum took care of the failed 8.19 backport in #133110. I'll remove the backport-pending label.

tvernum added a commit that referenced this pull request Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Core/Infra/REST API REST infrastructure and utilities Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.18.6 v8.19.3 v9.0.6 v9.1.3 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants