You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/04/19 22:59:25 UTC

[GitHub] [nifi] greyp9 opened a new pull request, #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

greyp9 opened a new pull request, #5980:
URL: https://github.com/apache/nifi/pull/5980

   #### Description of PR
   - Adjust CI build to supply locale for surefire via system environment variables.
   - Alter locale of fourth build node (updated locale coverage: en_AU, fr_FR, ja_JP, hi_IN).
   - Add module / unit test class to verify that CI surefire is running in the expected locale.  This should be activated only in context of CI build.
   - Remove locale specification from root POM (this is the cause of the JIRA).
   
   ### For all changes:
   - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [X] 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.
   
   - [X] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [X] 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:
   - [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [X] Have you written or updated unit tests to verify your changes?
   - [X] Have you verified that the full build is successful on JDK 8?
   - [X] 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](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853556651


##########
.github/workflows/ci-workflow.yml:
##########
@@ -147,12 +152,17 @@ jobs:
           java-version: '11'
       - name: Maven Build
         env:
+          NIFI_CI_LOCALE: >-

Review Comment:
   This environment variable will normally not be set, so the new unit test will be deactivated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853558383


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);
+                final String expected = String.format("%s=%s", key, value);
+                assertTrue(ciLocale.contains(expected), message);
+            }
+        }
+    }
+
+    @Test
+    @Disabled("Need this test to show up in CI output to verify that other test case is running")

Review Comment:
   ```
   Warning:  Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.052 s - in org.apache.nifi.build.VerifyBuildLocaleTest
   ```
   
   https://github.com/greyp9/nifi/runs/6086287528?check_suite_focus=true



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853558383


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);
+                final String expected = String.format("%s=%s", key, value);
+                assertTrue(ciLocale.contains(expected), message);
+            }
+        }
+    }
+
+    @Test
+    @Disabled("Need this test to show up in CI output to verify that other test case is running")

Review Comment:
   ```
   Warning:  Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.052 s - in org.apache.nifi.build.VerifyBuildLocaleTest
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853591760


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);

Review Comment:
   It looks like this could be changed to use the `EnabledIfEnvironmentVariable` JUnit 5 annotation.



##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);

Review Comment:
   This assertion is not really necessary as the next method tests the value of the property.



##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);
+                final String expected = String.format("%s=%s", key, value);
+                assertTrue(ciLocale.contains(expected), message);
+            }
+        }
+    }
+
+    @Test
+    @Disabled("Need this test to show up in CI output to verify that other test case is running")

Review Comment:
   Is the purpose of this disabled test for visual inspection? If so, a better approach would be to create a Logger and write a warning message in the running test method. That would allow removing this no-op method.
   
   We may want to consider adjusting the default log level for automated builds so that informational messages are included, but that would require a more thorough review of test output, and would be best addressed separately.



##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {

Review Comment:
   Perhaps making this a little more descriptive, it could be named `testEnvironmentLocaleMatchesSystemProperties`



##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {

Review Comment:
   Is this conditional necessary? The `NIFI_CI_LOCALE` variable seems specific enough that we should expect it to contain the System properties necessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r854261458


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {

Review Comment:
   I took another pass trying to simplify things, rather than trying to cover too many bases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r854260595


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);

Review Comment:
   Condensed these two down to a single assert. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853659405


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);

Review Comment:
   Nice, thanks!  Getting used to the JUnit 5 capabilities.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853659743


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {

Review Comment:
   Hmm.  I'll have another look.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory closed pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
exceptionfactory closed pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale
URL: https://github.com/apache/nifi/pull/5980


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on code in PR #5980:
URL: https://github.com/apache/nifi/pull/5980#discussion_r853659055


##########
nifi-commons/nifi-build/src/test/java/org/apache/nifi/build/VerifyBuildLocaleTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.build;
+
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class VerifyBuildLocaleTest {
+
+    /**
+     * Verify that the intended system locale is active for the surefire invocation.
+     *
+     * NiFi Surefire invocations may be executed in the context of a particular locale, in order to verify the locale
+     * independence of the code base.
+     */
+    @Test
+    public void testVerifyLocale() {
+        // NiFi CI build sets this environment variable; it will not normally be set
+        final String ciLocale = System.getenv("NIFI_CI_LOCALE");
+        Assumptions.assumeTrue(ciLocale != null);
+        // if the flag variable is set, verify the system locale of the surefire process against NIFI_CI_LOCALE
+        final String[] systemPropertyKeys = {
+                "user.language",
+                "user.country",
+        };
+        for (String key : systemPropertyKeys) {
+            // for any key specified in environment variable, verify that it is set correctly
+            if (ciLocale.contains(key)) {
+                final String value = System.getProperty(key);
+                final String message = String.format(
+                        "system property - CI_LOCALE:[%s] ACTUAL:[%s=%s]", ciLocale, key, value);
+                assertNotNull(value, message);
+                assertTrue((value.length() > 0), message);
+                final String expected = String.format("%s=%s", key, value);
+                assertTrue(ciLocale.contains(expected), message);
+            }
+        }
+    }
+
+    @Test
+    @Disabled("Need this test to show up in CI output to verify that other test case is running")

Review Comment:
   Yes, for visual inspection.
   
   It has taken a few iterations to get this right, and I'm looking for ways to confirm that things are working as they should.  But I'll remove the second method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
greyp9 commented on PR #5980:
URL: https://github.com/apache/nifi/pull/5980#issuecomment-1104061751

   Put this in the ticket; I'll also put it here.  Useful one-liner to test new module behavior:
   
   ```
   export NIFI_CI_LOCALE="-Duser.language=ja -Duser.country=JP" && export SUREFIRE_OPTS="-Duser.language=ja -Duser.country=JP -Duser.region=JP -Duser.timezone=Asia/Tokyo" && export MAVEN_OPTS="-DargLine=\${env.SUREFIRE_OPTS}" && mvn clean install -pl :nifi-build
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] szaszm commented on pull request #5980: NIFI-9826 - Test failure on Ubuntu when using C locale

Posted by GitBox <gi...@apache.org>.
szaszm commented on PR #5980:
URL: https://github.com/apache/nifi/pull/5980#issuecomment-1104130808

   I can confirm that nifi now builds on Ubuntu 20.04 LTS with Java 8 and `LANG=C.UTF-8`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org