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

AMBARI-25865: Fix an unit test failure on ambari-metrics-host-monitoring #103

Merged
merged 1 commit into from Feb 24, 2023

Conversation

sekikn
Copy link
Contributor

@sekikn sekikn commented Feb 24, 2023

What changes were proposed in this pull request?

Currently, we have a unit test failure in ambari-metrics-host-monitoring, as follows:

$ mvn clean test -f ambari-metrics-host-monitoring/pom.xml

...

[INFO] --- exec-maven-plugin:1.2.1:exec (python-test) @ ambari-metrics-host-monitoring ---
Running tests
Traceback (most recent call last):
  File "unitTests.py", line 137, in <module>
    sys.exit(main())
  File "unitTests.py", line 106, in main
    modules]
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/sekikn/repos/ambari-metrics/ambari-metrics-host-monitoring/src/test/python/core/TestHostInfo.py", line 24, in <module>
    from host_info import HostInfo
  File "/home/sekikn/repos/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py", line 25, in <module>
    import psutil
ImportError: No module named psutil
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.402 s
[INFO] Finished at: 2023-02-24T14:47:38+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (python-test) on project ambari-metrics-host-monitoring: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

This is because src/main/python/core/__init__.py assumes the psutil package is under src/main/python/psutil/build, but pom.xml uses another directory to build it.

In addition, the core package of ambari-metrics-host-monitoring should be loaded before TestHostInfo.py so that the psutil package is loaded in advance.

How was this patch tested?

Ran mvn clean test -f ambari-metrics-host-monitoring/pom.xml with this PR locally, as follows:

$ mvn clean test -f ambari-metrics-host-monitoring/pom.xml

...

Ran 19 tests in 1.022s

OK
----------------------------------------------------------------------
Total run:19
Total errors:0
Total failures:0
OK

...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.675 s
[INFO] Finished at: 2023-02-24T15:02:03+09:00
[INFO] ------------------------------------------------------------------------

@sekikn sekikn requested a review from kevinw66 February 24, 2023 07:31
Copy link
Contributor

@kevinw66 kevinw66 left a comment

Choose a reason for hiding this comment

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

+1 lGTM, thanks @sekikn

@kevinw66 kevinw66 merged commit c015cf9 into apache:master Feb 24, 2023
kevinw66 pushed a commit to kevinw66/ambari-metrics that referenced this pull request Feb 24, 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
2 participants