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

NIFI-8478; i18n test issues; CI supplies locale to surefire #5040

Closed
wants to merge 4 commits into from

Conversation

greyp9
Copy link
Contributor

@greyp9 greyp9 commented Apr 28, 2021

Thank you for submitting a contribution to Apache NiFi.

Please provide a short description of the PR here:

Description of PR

Addresses a few i18n issues in project test suite. Github CI will supply desired test locale to surefire. Archive test results.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not squash or use --force when pushing to allow for clean monitoring of changes.

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • Have you verified that the full build is successful on JDK 8?
  • Have you verified that the full build is successful on JDK 11?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.

@@ -91,9 +91,16 @@ jobs:
df -h
- name: Build with Maven
env:
MAVEN_OPTS: -Xmx2g -XX:ReservedCodeCacheSize=1g -XX:+UseG1GC -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Dmaven.surefire.arguments="-Duser.language=en -Duser.region=AU -Duser.timezone=Australia/Melbourne" -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
MAVEN_OPTS: -Xmx2g -XX:ReservedCodeCacheSize=1g -XX:+UseG1GC -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Duser.language=en -Duser.country=AU -Duser.region=AU -Duser.timezone=Australia/Melbourne -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use of "maven.surefire.arguments" should work, but I verified that the CI was running on each node in the default locale (en-US). This change sets the system properties for locale, and a corresponding change in project root POM propagates these settings to surefire.

if: always()
with:
name: surefire-reports-en
path: "**/surefire-reports/TEST-*.xml"
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 archival of surefire XML output. Used this to initially verify that surefire was running in the context of the incorrect locale.

Copy link
Contributor

Choose a reason for hiding this comment

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

This archival stuff is super helpful! Great add

with:
name: surefire-reports-en
path: "**/surefire-reports/TEST-*.xml"
retention-days: 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The surefire outputs are on the order of ~30M each. So we choose the minimum retention period (1-90 days available) to minimize storage requirement.

run: |
mvn -V -T 0.7C package -B -Ddir-only -ntp -ff -pl -nifi-assembly -pl -nifi-system-tests -nsu
- name: Upload artifact
uses: actions/upload-artifact@v2
if: ${{ false }}
Copy link
Contributor Author

@greyp9 greyp9 Apr 28, 2021

Choose a reason for hiding this comment

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

There is a problem with artifact upload on Windows. The upload succeeded when run against a small subset of the project, but failed 100% of time against full project.

Example:
https://github.com/greyp9/nifi/runs/2459360376?check_suite_focus=true

ENOENT: no such file or directory, realpath 'D:\a\nifi\nifi\nifi-nar-bundles\nifi-standard-bundle\nifi-jolt-transform-json-ui\target\frontend-working-directory\node\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\cliui\node_modules\string-width\node_modules\is-fullwidth-code-point\node_modules'

It seems that nifi-nar-bundles\nifi-standard-bundle\nifi-jolt-transform-json-ui is creating paths that exceed the 256 character limit for Windows paths, and that this new job cannot handle them. It is possible that this issue contributes to the instability of the Github CI Windows job.

It would be nice to have these logs for Windows, but for now, this plugin is disabled on this platform.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep lets just punt on that archival on windows for now then - makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nifi % find . -type d -name node_modules

path: |
'**/surefire-reports/TEST-*.xml'
'!**/node_modules/**'
'!**/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/**'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/greyp9/nifi/actions/runs/793436719

Windows Zulu JDK8 FRNo files were found with the provided path: '**/surefire-reports/TEST-*.xml' '!**/node_modules/**' '!**/nifi-jolt-transform-json-ui/**'. No artifacts will be uploaded.

This output suggests that use of exclusion patterns may be a viable workaround.

@@ -94,7 +94,7 @@ class XmlUtilsTest {

// Assert
logger.expected(msg)
assert msg =~ "SAXParseException.* DOCTYPE is disallowed when the feature"
assert msg =~ "SAXParseException.* DOCTYPE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the initial problem surfaced by user on Slack channel and in ticket. The updated CI suggests that this change is sufficient to work in our test environments (EN, FR, JP).

https://issues.apache.org/jira/browse/NIFI-8478

/**
* Testing of the test suite environment {@link java.util.Locale}.
*/
public class TestLocaleOfTestSuite {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was useful to have a confined test bed to experiment with the issues as they presented.

Assume.assumeTrue(Arrays.asList("en", "fr", "ja").contains(userLanguage));
Assume.assumeTrue(Arrays.asList("US", "AU", "FR", "JP").contains(userCountry));
Assume.assumeTrue(Arrays.asList("en-US", "fr-FR").contains(languageTag));
Assume.assumeTrue("unconditionally force junit output to XML report",false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My observation here was that the CI/surefire test case output is discarded on success. So I needed an unconditional assume to get the output without failing the build.

*/
@Test
public void testLocaleExpectedOutputs() {
Assert.assertEquals("1\u00a0000", NumberFormat.getInstance(Locale.FRANCE).format(1000));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FR locale uses nbsp as the thousands separator character. TIL.

@@ -88,8 +90,7 @@ protected ThreadDetails captureThreadDetails() {
assertEquals("Long running task detected on processor [id=Processor-1-ID, name=Processor-1-Name, type=Processor-1-Type]. Task time: 60 seconds. Stack trace:\n" + STACKTRACE,
logMessages.getAllValues().get(0));
assertEquals("Long running task detected on processor [id=Processor-2-ID, name=Processor-2-Name, type=Processor-2-Type]. Task time: 1,000 seconds. Stack trace:\n" + STACKTRACE,
logMessages.getAllValues().get(1));

logMessages.getAllValues().get(1).replace(NumberFormat.getInstance(Locale.getDefault()).format(1000), NumberFormat.getInstance(Locale.US).format(1000)));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test verifies EN locale log output, which works if we fix up the locale-specific log output.

@@ -556,7 +557,8 @@
REL_SUCCESS_REQ, REL_RESPONSE, REL_RETRY, REL_NO_RETRY, REL_FAILURE)));

// RFC 2616 Date Time Formatter with hard-coded GMT Zone
private static final DateTimeFormatter RFC_2616_DATE_TIME = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'");
// https://tools.ietf.org/html/rfc2616#section-3.3 - date format header should not be localized
private static final DateTimeFormatter RFC_2616_DATE_TIME = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a unit test that verified a generated date (locale-specific) against the RFC 2616 pattern. In FR locale, the pattern did not match, so the test failed.

I interpret the rfc to require the unlocalized version of the formatted date, thus this change.

pom.xml Outdated
@@ -421,8 +421,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<systemPropertyVariables combine.children="append">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the bit that propagates the Maven / Java locale settings to surefire.

@@ -435,7 +439,6 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<argLine combine.children="append">-Xmx1G
-Djava.net.preferIPv4Stack=true
${maven.surefire.arguments}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There may be a tweak possible to make this line do the right thing, but I went down a different path.

Copy link
Contributor

@exceptionfactory exceptionfactory 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 tracking down these challenging issues @greyp9! Just about all of the changes look good after verification. However, the TestLocaleOfTestSuite includes some Assume.assumeTrue() statements that fail when running in locales other than the ones listed. The other other test methods in the class just verify Java behavior, so it does not seem worth including tests for standard JVM behavior, just for documentation purposes. It seems that the best approach would be to remove the TestLocaleOfTestSuite class, and keep the rest of the changes.

@greyp9
Copy link
Contributor Author

greyp9 commented May 3, 2021

I'd like to keep the test, but it could be refactored to reflect its intent better.

It is useful to understand the constraints of the locales in which ci-workflow is running. There are now test cases for each, where the particular fixed issues are better illuminated. An Assume guards a set of Assert for each expected locale.

Maybe this organization makes more sense.

Copy link
Contributor

@exceptionfactory exceptionfactory 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 the work on this @greyp9! +1 Merging.

@asfgit asfgit closed this in cc554a6 May 3, 2021
krisztina-zsihovszki pushed a commit to krisztina-zsihovszki/nifi that referenced this pull request Jun 28, 2022
This closes apache#5040

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants