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

Fix the way locale information is passed to Surefire #315

Merged
merged 1 commit into from
May 31, 2022

Conversation

ksobolew
Copy link
Contributor

@ksobolew ksobolew commented May 25, 2022

This moves primarily the user.language and user.region from systemPropertyVariables to explicit property setting on the JVM. These two methods to set them are supposed to be the same, but passing via system properties does not actually work. Which is annoying, because when the are set in both ways, Surefire complains about it:

[WARN] The system property user.language is configured twice! The property appears in <argLine/> and any of <systemPropertyVariables/>, <systemProperties/> or user property.
[WARN] The system property user.region is configured twice! The property appears in <argLine/> and any of <systemPropertyVariables/>, <systemProperties/> or user property.

It seems that the user.timezone actually works as expected, but is moved along with the other two for consistency.

@ksobolew
Copy link
Contributor Author

cc: @findepi

airbase/pom.xml Outdated Show resolved Hide resolved
@findepi
Copy link
Contributor

findepi commented May 25, 2022

These two are supposed to be the same, but passing via system properties does not actually work.

See #98 (comment)

Does this mean #98 never actually worked?
@findepi reported prestodb/presto#9313 (comment) it did work.

@ksobolew how do you test these changes?

@ksobolew
Copy link
Contributor Author

ksobolew commented May 26, 2022

@ksobolew how do you test these changes?

I just run ./mvnw verify -pl :trino-main -Dtest=TestRealOperators in Trino. My locale is pl_PL, so I get test failures of the sort: java.lang.AssertionError: expected [7.541985E2] but found [7,541985E2], which clearly indicates that the system default locale was used instead of the one specified in the Surefire config.

@findepi reported prestodb/presto#9313 (comment) it did work.

Maybe it broke in the meantime? That configuration was added 4 years ago... I did some googling and found problem reports about that, but no fix in Surefire was ever mentioned.

@findepi
Copy link
Contributor

findepi commented May 26, 2022

Thanks for testing this out.
Do we also need to move the time zone?
Perhaps not, for the timezone we have https://github.com/findepi/trino/blob/7fd62db50aec490907e93412441fe65dbfea6052/testing/trino-tests/src/test/java/io/trino/tests/TestVerifyTrinoTestsTestSetup.java#L28.

Does this test pass for you locally?

(even if it does, i would somewhat prefer to set timezone region and lang same way)

cc @electrum

@ksobolew
Copy link
Contributor Author

Thanks for testing this out. Do we also need to move the time zone? Perhaps not, for the timezone we have https://github.com/findepi/trino/blob/7fd62db50aec490907e93412441fe65dbfea6052/testing/trino-tests/src/test/java/io/trino/tests/TestVerifyTrinoTestsTestSetup.java#L28.

Maybe we need similar test for the locale?

Does this test pass for you locally?

Yes, this makes the tests pass for me.

@ksobolew
Copy link
Contributor Author

@ksobolew ksobolew force-pushed the kudi/fix-locale-setting branch from f099204 to 4634826 Compare May 26, 2022 09:26
@ksobolew
Copy link
Contributor Author

Addressed comments. One interesting thing to note is that this is actually broken in Maven, but IntelliJ correctly passes these parameters so these test work fine in the IDE.

@ksobolew ksobolew force-pushed the kudi/fix-locale-setting branch from 4634826 to 5e4e918 Compare May 27, 2022 08:44
@@ -440,6 +437,9 @@
<!-- ${argLine} is for Jacoco: https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html -->
<argLine>
${argLine}
-Duser.timezone=${air.test.timezone}
Copy link
Contributor

Choose a reason for hiding this comment

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

add a code comment why this goes in argsLine and not systemPropertyVariables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added :)

This moves primarily the `user.language` and `user.region` from
`systemPropertyVariables` to explicit property setting on the JVM. These
two methods to set them are supposed to be the same, but passing via
system properties does not actually work. Which is annoying, because
when the are set in both ways, Surefire complains about it:

```
[WARN] The system property user.language is configured twice! The property appears in <argLine/> and any of <systemPropertyVariables/>, <systemProperties/> or user property.
[WARN] The system property user.region is configured twice! The property appears in <argLine/> and any of <systemPropertyVariables/>, <systemProperties/> or user property.
```

It seems that the `user.timezone` actually works as expected, but is
moved along with the other two for consistency.
@ksobolew ksobolew force-pushed the kudi/fix-locale-setting branch from 5e4e918 to 70ca37d Compare May 27, 2022 12:21
@findepi findepi merged commit d4630aa into airlift:master May 31, 2022
@ksobolew ksobolew deleted the kudi/fix-locale-setting branch May 31, 2022 08:17
@findepi
Copy link
Contributor

findepi commented Jun 22, 2022

@ksobolew
Copy link
Contributor Author

Hm, I haven't encountered any problems 🤔

@ksobolew
Copy link
Contributor Author

Not yet, anyway

@findepi
Copy link
Contributor

findepi commented Jun 22, 2022

Hm, I haven't encountered any problems 🤔

Do Trino's TestPostgreSqlTypeMapping and TestHiveConnectorTest work for you?

@ksobolew
Copy link
Contributor Author

You're right, it's not working in IDEA 😞

@ksobolew
Copy link
Contributor Author

Looks like IDEA is confused by ${argLine} in Airbase's surefire configuration:

                        <argLine>
                            ${argLine}
                            ...
                        </argLine>

Once I removed it, it worked. Thing is, if there's no Jacoco, this does not get expanded and sits there as literal ${argLine}.

@nineinchnick
Copy link
Contributor

See #300 that should provide a default value when Jacoco is disabled

@nineinchnick
Copy link
Contributor

Would definining the properties twice, both in systemPropertyVariables and argLine work?

@findepi
Copy link
Contributor

findepi commented Jun 22, 2022

See #300 that should provide a default value when Jacoco is disabled

Seems like it was merged long ago, and IntelliJ doesn't pick the time zone ~today.

Would definining the properties twice, both in systemPropertyVariables and argLine work?

would prefer to avoid duplication, but maybe we need to do this

this will make surefire issue warnings, like mentioned in the PR description

These two methods to set them are supposed to be the same, but passing via system properties does not actually work. Which is annoying, because when the are set in both ways, Surefire complains about it: [...]

It seems that the user.timezone actually works as expected, but is moved along with the other two for consistency.

or maybe we move back the user.timezone (provided IntelliJ can pick the other to)

BTW @ksobolew is there a surefire bug report about this?

@ksobolew
Copy link
Contributor Author

See #300 that should provide a default value when Jacoco is disabled

It was then changed in #301 to activate on air.check.skip-all instead of air.check.skip-jacoco (for a valid reason that it didn't work). But in Trino we explicitly set <air.check.skip-jacoco>true</air.check.skip-jacoco> so the profile jacoco-check still gets activated. So jacoco-defaults does not and argLine is not set.

@ksobolew
Copy link
Contributor Author

BTW @ksobolew is there a surefire bug report about this?

Actually with Surefire it works just fine

@ksobolew
Copy link
Contributor Author

Would definining the properties twice, both in systemPropertyVariables and argLine work?

Not sure, probably yes. But there are two "but"s:

  • Specifying both is not an error, but the runner logs warnings about it (not fatal, so we can live with it)
  • This actually prevents passing all additional arguments to IDEA (though probably not all are useful when running in the IDE)

@nineinchnick
Copy link
Contributor

Can Trino define a default for argLine if it has Jacoco always disabled?

@ksobolew
Copy link
Contributor Author

Can Trino define a default for argLine if it has Jacoco always disabled?

I think it can. This will make enabling jacoco harder, though.

Can we activate the jacoco profiles explicitly?

@findepi
Copy link
Contributor

findepi commented Jun 22, 2022

BTW @ksobolew is there a surefire bug report about this?

Actually with Surefire it works just fine

This PR (#315) is a workaround for somre surefire's behavior.
Was that problematic behavior reported?

This actually prevents passing all additional arguments to IDEA (though probably not all are useful when running in the IDE)

Can you expand on this? What would be worse than it is today, or before this PR was merged?

Can Trino define a default for argLine if it has Jacoco always disabled?

The bug is in airbase. In trino we can workaround, sure, but can we fix this here?

@ksobolew
Copy link
Contributor Author

Was that problematic behavior reported?

Oh, right :) I guess not. The best I could find was https://stackoverflow.com/questions/8901880/set-surefire-plugin-locale-in-maven-pom-file

The bug is in airbase. In trino we can workaround, sure, but can we fix this here?

Fair question. I hope so!

@findepi
Copy link
Contributor

findepi commented Jun 22, 2022

Was that problematic behavior reported?

Oh, right :) I guess not. T

We should have reported this before/while working on this PR. Can you please follow-up accordingly?
(Also, maybe it's easy to fix in the surefire plugin.)

@ksobolew
Copy link
Contributor Author

Reported it as https://issues.apache.org/jira/browse/SUREFIRE-2104

@ksobolew
Copy link
Contributor Author

This actually prevents passing all additional arguments to IDEA (though probably not all are useful when running in the IDE)

Can you expand on this? What would be worse than it is today, or before this PR was merged?

The presence of the unexpanded ${argLine} causes IDEA to not include anything that's in the argLine configuration element. So this is a pre-existing issue, we only started to see it "thanks" to these two properties.

@findepi
Copy link
Contributor

findepi commented May 8, 2023

Can Trino define a default for argLine if it has Jacoco always disabled?

I was not successful in making this work.

IntelliJ no longer sets -Duser.timezone=${air.test.timezone} when running tests, so they fail to start because of checks like
https://github.com/trinodb/trino/blob/4aacac24cb2811970abaa5acfa47427206568562/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java#L238
or
https://github.com/trinodb/trino/blob/b2fb2b5a88e7452348e8f67d379fb555d3c49a59/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java#L153

is it only for me, or is this problem persistent?
@ksobolew how did you solve this on your side?

@ksobolew
Copy link
Contributor Author

Can Trino define a default for argLine if it has Jacoco always disabled?

I was not successful in making this work.

IntelliJ no longer sets -Duser.timezone=${air.test.timezone} when running tests, so they fail to start because of checks like
https://github.com/trinodb/trino/blob/4aacac24cb2811970abaa5acfa47427206568562/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java#L238
or
https://github.com/trinodb/trino/blob/b2fb2b5a88e7452348e8f67d379fb555d3c49a59/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java#L153

is it only for me, or is this problem persistent? @ksobolew how did you solve this on your side?

It was some time ago and I don't remember exactly what the problem was, but I checked now and indeed, it doesn't work. In fact, it seems that IDEA does not pick any of the arguments specified inside argLine. Reverting this commit at least makes the timezone to be passed correctly, which is the opposite of what seemingly was the original issue.

@findepi
Copy link
Contributor

findepi commented May 23, 2023

Reverting this commit at least makes the timezone to be passed correctly

awesome, let's do this, thanks!

which is the opposite of what seemingly was the original issue.

the PR title talks about locale

@ksobolew
Copy link
Contributor Author

which is the opposite of what seemingly was the original issue.

the PR title talks about locale

These are all system properties so they are handled the same way. We pin locale for the same reason we pin the time zone, and they have the same issues.

@ksobolew
Copy link
Contributor Author

and they have the same issues

I read the original commit message and it seems that it's wrong - they are not handled the same way.

@findepi
Copy link
Contributor

findepi commented May 24, 2023

Is there anything preventing us from restoring correct time zone handling for intellij?

@ksobolew
Copy link
Contributor Author

No, I don't think there is anything that prevents us, except for making sure that it works.

ksobolew added a commit to ksobolew/trino that referenced this pull request May 25, 2023
We want to see if anything breaks. There's a suspicion that this is not
an issue anymore, and causes issues of its own.
@ksobolew
Copy link
Contributor Author

@findepi did the partial revert in #358. Would be cool if you could verify locally if it fixes the issue for you (I did some tests and it seems it does for me).

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