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

Install test requirements on startup #115

Closed

Conversation

lubosmj
Copy link
Member

@lubosmj lubosmj commented Apr 21, 2023

closes #56

@lubosmj
Copy link
Member Author

lubosmj commented Apr 21, 2023

It works for me locally. I am not sure why the checks are red.

@lubosmj
Copy link
Member Author

lubosmj commented Apr 24, 2023

I can also make this feature optional. Would it be more favourable to do so?

@decko decko closed this Jun 13, 2023
@decko decko reopened this Jun 13, 2023
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from 6a09e7e to 3e77dc3 Compare June 13, 2023 12:47
Copy link
Member

@MichalPysik MichalPysik left a comment

Choose a reason for hiding this comment

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

I tested multiple scenarios and everything seems to work as far as I'm concerned, except that all the individual test types have to be iterated through no matter whether any of them doesn't exist.

if self.args.test != "all":
self.run_test_command(self.args.plugin, [f"run_{self.args.test}_tests.sh"])
else:
self.run_test_command(self.args.plugin, self.test_run_scripts)
Copy link
Member

Choose a reason for hiding this comment

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

There has to be a manual check on which types of tests the given plugin implements. For example, running all types of tests on pulpcore only runs functional tests and fails on performance tests (since there are none to be run), without a chance to start the remaining (unit, lint) tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! 🐶

Copy link
Member Author

Choose a reason for hiding this comment

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

I will adjust the scripts to assert the presence of the tests before running them.

function check_test() {
   if ![ -d "/path/dir/" ] ...
}

check_test

@lubosmj lubosmj marked this pull request as draft July 11, 2023 17:02
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from 3e77dc3 to d5a868f Compare July 12, 2023 13:37
@lubosmj lubosmj marked this pull request as ready for review July 12, 2023 13:38
@lubosmj lubosmj requested a review from MichalPysik July 12, 2023 13:38
@lubosmj
Copy link
Member Author

lubosmj commented Jul 17, 2023

@decko, @newswangerd, are we going to merge this PR? It installs all test requirements on boot-up, which could slow the instantiation a bit (not a dealbreaker for me). I find it still useful because we can just run oci-env generate-client -i and then run tests as needed without more calls. If not, feel free to close this PR and its corresponding issue.

@newswangerd newswangerd self-requested a review July 18, 2023 19:23
Copy link
Collaborator

@newswangerd newswangerd left a comment

Choose a reason for hiding this comment

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

I intentionally left this out of the initialization sequence because it adds a lot of startup time and it's not something that we use very often for galaxy_ng development.

I'd be okay with this as some kind of configuration option or if it could be built into the base image, but this has to be disabled by default.

@lubosmj lubosmj marked this pull request as draft July 18, 2023 20:05
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from d5a868f to b771618 Compare August 8, 2023 12:56
@lubosmj lubosmj marked this pull request as ready for review August 8, 2023 12:56
@lubosmj
Copy link
Member Author

lubosmj commented Aug 8, 2023

Now, the installation is optional. A user can decide whether she wants to install the test requirements or not via the compose file where other settings like "DEV_SOURCE_PATH" are defined.

@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch 7 times, most recently from 2e9ae38 to 928c2c5 Compare August 11, 2023 12:18
@lubosmj lubosmj marked this pull request as draft August 11, 2023 13:02
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch 3 times, most recently from 6bfa474 to 6562d0a Compare August 11, 2023 14:00
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch 11 times, most recently from 36e1403 to 978b34a Compare August 15, 2023 17:17
@lubosmj
Copy link
Member Author

lubosmj commented Aug 15, 2023

I really cannot make this PR to pass through the CI checks. This is the error I am experiencing:

2023-08-15 16:29:40,395 - INFO - utils.py:450 - Running [non-interactive] command in container: docker exec oci_env_pulp_1 bash /opt/oci_env/base/container_scripts/install_client.sh pulpcore
Obtaining file:///src/pulp-openapi-generator/pulpcore-client
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      Traceback (most recent call last):
        File "/usr/local/lib/python3.8/site-packages/setuptools/_normalization.py", line 59, in safe_version
          return str(packaging.version.Version(v))
        File "/usr/local/lib/python3.8/site-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
          raise InvalidVersion(f"Invalid version: '{version}'")
      setuptools.extern.packaging.version.InvalidVersion: Invalid version: ''
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/src/pulp-openapi-generator/pulpcore-client/setup.py", line 26, in <module>
          setup(
        File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 481, in __init__
          self.patch_missing_pkg_info(attrs)
        File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 470, in patch_missing_pkg_info
          dist._version = _normalization.safe_version(str(attrs['version']))
        File "/usr/local/lib/python3.8/site-packages/setuptools/_normalization.py", line 62, in safe_version
          return str(packaging.version.Version(attempt))
        File "/usr/local/lib/python3.8/site-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
          raise InvalidVersion(f"Invalid version: '{version}'")
      setuptools.extern.packaging.version.InvalidVersion: Invalid version: ''
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Running local command: bash /home/runner/work/oci_env/oci_env/oci_env/base/local_scripts/generate_client.sh pulpcore python

This error is raised when I place the "install_test_deps" inside the init_container function in base/utils.sh. Initially, the python script for installing test requirements was placed inside base/init.sh. However, the tests could not be successfully installed because of the missing DEV_SOURCE_PATH environment variable.

If there is no way to resolve this issue, I would rather eliminate the requirement for testing the automatic installation in the CI. Everything works locally for me.

@lubosmj lubosmj marked this pull request as ready for review August 15, 2023 17:21
base/utils.sh Outdated
@@ -36,6 +37,12 @@ install_local_deps() {
done
}

install_test_deps() {
if [ "$INSTALL_TESTS" = "True" ]; then
python3 /opt/oci_env/base/container_scripts/install_test_requirements.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using a python script I would just copy-paste the for loop above and change the pip command to install from test_requirements.txt.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this, but it did not help:

install_test_deps() {
    if [ "$INSTALL_TESTS" = "True" ]; then
        local src_path_list
        IFS=':' read -ra src_path_list <<< "$DEV_SOURCE_PATH"

        for item in "${src_path_list[@]}"; do
            src_path="/src/${item}"
            if [[ -d "$src_path" ]]; then
                log_message "Installing requirements for ${item}."
                pip3 install -r "${src_path}"/lint_requirements.txt || true
                pip3 install -r "${src_path}"/unittest_requirements.txt || true
                pip3 install -r "${src_path}"/functest_requirements.txt || true
                pip3 install -r "${src_path}"/perftest_requirements.txt || true
            fi
        done
        # python3 /opt/oci_env/base/container_scripts/install_test_requirements.py
    fi
}

I am getting the same error. And, I know the error is related to my changes because when I removed the install_test_deps call from init_container, it worked.

@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from 978b34a to d089210 Compare August 16, 2023 10:46
@lubosmj lubosmj marked this pull request as draft August 16, 2023 10:46
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from d089210 to 060bd4f Compare August 16, 2023 10:59
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch 2 times, most recently from 9bf2c95 to 2c6fd99 Compare August 31, 2023 15:47
@lubosmj lubosmj force-pushed the install-test-requirements-by-default branch from 2c6fd99 to 9f3fca7 Compare August 31, 2023 16:05
@lubosmj
Copy link
Member Author

lubosmj commented Sep 14, 2023

Closing because of the unresolved failures that root in lack of knowledge around the CI.

@lubosmj lubosmj closed this Sep 14, 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
5 participants