Skip to content

Output test log path (optionally contents) post-install, include post-install times#35315

Closed
tldahlgren wants to merge 6 commits intospack:developfrom
tldahlgren:print_test_log_path
Closed

Output test log path (optionally contents) post-install, include post-install times#35315
tldahlgren wants to merge 6 commits intospack:developfrom
tldahlgren:print_test_log_path

Conversation

@tldahlgren
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren commented Feb 3, 2023

(UPDATED) This PR provides more post-install test information:

  1. prints the test log path IF a test failure occurs;
  2. prints the contents of the test log IF -v option is passed to spack install; and
  3. times and prints post-install operations (e.g., post-install tests).

For example, with -v --test=root for a package with a (fake) test failure:

$ spack install -v --test=root [email protected]
...
==> Installing py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d
==> No binary for py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d found: installing from source
==> Using cached archive: $spack/var/spack/cache/_source-cache/archive/e4/e46598e5696f770cbff4cb90507b52867faad5654f1b80de35405a95228c909f.tar.gz
==> No patches needed for py-libensemble
==> py-libensemble: Executing phase: 'install'
...
Successfully built libensemble
Installing collected packages: libensemble

Successfully installed libensemble-0.9.2
...
==> Testing package py-libensemble-0.9.2-lr5qi7b
==> [2023-02-24-16:08:32.534705] Running install-time tests
==> [2023-02-24-16:08:32.536319] Installing $/spack/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d/.spack/test to /var/tmp/dahlgren/spack-stage/spack-stage-py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d/py-libensemble-0.9.2-lr5qi7b/cache/py-libensemble
==> [2023-02-24-16:08:32.811530] RUN-TESTS: install-time tests [test]
==> [2023-02-24-16:08:32.876125] Detected the following modules: ['libensemble', 'libensemble.alloc_funcs', 'libensemble.comms', 'libensemble.executors', 'libensemble.executors.balsam_executors', 'libensemble.gen_funcs', 'libensemble.resources', 'libensemble.sim_funcs', 'libensemble.sim_funcs.branin', 'libensemble.tests', 'libensemble.tests.regression_tests', 'libensemble.tests.unit_tests', 'libensemble.tools', 'libensemble.utils']
==> [2023-02-24-16:08:32.877048] checking import of libensemble
==> [2023-02-24-16:08:32.877751] '/usr/tce/bin/python3.7' '-c' 'import libensemble'
PASSED
...
==> [2023-02-24-16:08:45.706608] test: run test_1d_sampling.py example
==> [2023-02-24-16:08:45.707351] '/usr/tce/bin/python3.7' 'test_1d_sampling.py' '--comms' 'local' '--nworkers' '2'

libEnsemble with random sampling has generated enough points
libensemble.tools.tools: ------------------ Run completed -------------------
Saving results to file: 1d_sampling_history_length=1000_evals=502_workers=2
PASSED
==> [2023-02-24-16:08:47.117321] test: fail
==> [2023-02-24-16:08:47.118023] '/usr/tce/bin/python3.7' '-c' 'raise RuntimeError("fail")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: fail
FAILED: Command exited with status 1:
    '/usr/tce/bin/python3.7' '-c' 'raise RuntimeError("fail")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: fail
...
  File "$spack/var/spack/repos/builtin/packages/py-libensemble/package.py", line 100, in test
    purpose="test: fail",
==> [2023-02-24-16:08:47.450596] Completed testing
==> Error: TestFailure: 1 tests failed.

Command exited with status 1:
    '/usr/tce/bin/python3.7' '-c' 'raise RuntimeError("fail")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: fail

1 error found in test log:
...
See build log for details:
  $TMPDIR/spack-stage/spack-stage-py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d/spack-build-out.txt

See test log for details:
  $TMPDIR/spack-stage/spack-stage-py-libensemble-0.9.2-lr5qi7bfilbfm7ci5jvwno5kccjavc7d/install-time-test-log.txt

193.295u 23.579s 3:59.98 90.3%	0+0k 1816+6256io 1pf+0w

While running tests without -v for the same package results in:

$ spack install --test=root [email protected]
...
==> Installing py-libensemble-0.9.3-5prbuneeootut5fplscnx7mv2ews3xin
==> No binary for py-libensemble-0.9.3-5prbuneeootut5fplscnx7mv2ews3xin found: installing from source
==> Using cached archive: /usr/WS1/dahlgren/releases/spack/var/spack/cache/_source-cache/archive/00/00e5a65d6891feee6a686c048d8de72097b8bff164431f163be96ec130a9c390.tar.gz
==> No patches needed for py-libensemble
==> py-libensemble: Executing phase: 'install'
==> Error: TestFailure: 1 tests failed.

Command exited with status 1:
    '/usr/tce/bin/python3.7' '-c' 'raise RuntimeError("fail")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: fail
...
See build log for details:
  /var/tmp/dahlgren/spack-stage/spack-stage-py-libensemble-0.9.3-5prbuneeootut5fplscnx7mv2ews3xin/spack-build-out.txt

See test log for details:
  /var/tmp/dahlgren/spack-stage/spack-stage-py-libensemble-0.9.3-5prbuneeootut5fplscnx7mv2ews3xin/install-time-test-log.txt

199.725u 30.088s 4:00.49 95.5%	0+0k 1024+5688io 0pf+0w

Note:

$ spack  -v test run [email protected]  # shows tests and, if a failure, log path
$ spack test run [email protected]  # does not show details or the log path

TODO

- [x] add/update unit tests

@spackbot-app spackbot-app bot added the core PR affects Spack core functionality label Feb 3, 2023
@spackbot-app spackbot-app bot added the tests General test capability(ies) label Feb 7, 2023
@spackbot-app spackbot-app bot added new-version stand-alone-tests Stand-alone (or smoke) tests for installed packages commands labels Feb 13, 2023
@tldahlgren
Copy link
Copy Markdown
Contributor Author

@adamjstewart @alalazo Resolved conflicts. The patch coverage is reported at 100% and project coverage up +.13%. Also re-confirmed the example output shown in the description.

Copy link
Copy Markdown
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

Tested with py-six and works as expected! A few comments related to the output and when/where we print it. Also, the build output uses green for the ==>, but the test output uses no color. Probably simple to fix.

@adamjstewart adamjstewart self-assigned this Feb 22, 2023
- added typing for _print_install_test_log arg(s);
- added timing of post-install (to capture testing timing data);
- changed to output test log path only on failures; and
- colorized test log markers green.

Also:
- Added "Completed testing" log message for post-install tests; and
- colorized test log messages.
@adamjstewart
Copy link
Copy Markdown
Member

This is looking much better now. A few final things I noticed:

  1. The install-time-test-log.txt file that gets installed is executable and prob shouldn't be
  2. The font used for ==> during testing is bold, but the font used for ==> during build isn't
  3. The test start/complete messages are printed twice:
    ==> Testing package py-six-1.15.0-6ev665z
    ==> [2023-02-23-21:12:48.859872] Running install-time tests
    ==> [2023-02-23-21:12:48.861115] RUN-TESTS: install-time tests [test]
    ==> [2023-02-23-21:12:48.911128] Completed testing
    ==> Testing package py-six-1.15.0-6ev665z
    ==> [2023-02-23-21:12:48.859872] Running install-time tests
    ==> [2023-02-23-21:12:48.861115] RUN-TESTS: install-time tests [test]
    ==> [2023-02-23-21:12:48.863071] Detected the following modules: ['six']
    ==> [2023-02-23-21:12:48.864000] checking import of six
    ==> [2023-02-23-21:12:48.864307] '/Users/Adam/spack/opt/spack/darwin-catalina-ivybridge/apple-clang-12.0.0/python-3.10.8-vtplktw577cpgtkbjew4bjbetrxjttbu/bin/python3.10' '-c' 'import six'
    PASSED
    ==> [2023-02-23-21:12:48.911128] Completed testing
    

@tldahlgren tldahlgren changed the title Output test log path (optionally contents) post-install Output test log path (optionally contents) post-install, include post-install times Feb 24, 2023
@adamjstewart
Copy link
Copy Markdown
Member

With the latest commit, spack install -v --test=root no longer prints the test output.

@tldahlgren
Copy link
Copy Markdown
Contributor Author

With the latest commit, spack install -v --test=root no longer prints the test output.

Can you try spack -v install --test=root? I will revisit getting the option passed the other way as well.

@adamjstewart
Copy link
Copy Markdown
Member

Still didn't display the tests even with:

$ spack -v install -v --test=root py-six

@tldahlgren
Copy link
Copy Markdown
Contributor Author

Closing this PR since the changes originated in #34236, which has refactoring that causes redundant work iterating on this and the other PR.

@tldahlgren tldahlgren closed this May 8, 2023
@tldahlgren tldahlgren deleted the print_test_log_path branch August 27, 2024 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-environment commands core PR affects Spack core functionality new-version stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants