From ee7031c4a528b4a24c98ce4e61c04fb3cd90ae1c Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Fri, 20 Nov 2020 10:39:19 -0800 Subject: [PATCH] Fix permission denied errors on CI in unittests (#4664) Also remove usrstcp from the repos we do tests since they no longer work with usrstcp (repo history seems to have been rewritten). --- .github/workflows/infra_tests.yml | 12 ++++++------ infra/build_specified_commit_test.py | 9 ++------- infra/test_repos.py | 15 ++------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.github/workflows/infra_tests.yml b/.github/workflows/infra_tests.yml index 0641e6cb3..98a5b91fb 100644 --- a/.github/workflows/infra_tests.yml +++ b/.github/workflows/infra_tests.yml @@ -21,18 +21,18 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r infra/ci/requirements.txt - pip install -r infra/build/functions/requirements.txt + sudo env "PATH=$PATH" python -m pip install --upgrade pip + sudo env "PATH=$PATH" pip install -r infra/ci/requirements.txt + sudo env "PATH=$PATH" pip install -r infra/build/functions/requirements.txt - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master with: version: '298.0.0' - run: | - gcloud components install beta cloud-datastore-emulator - gcloud info + sudo env "PATH=$PATH" gcloud components install beta cloud-datastore-emulator + sudo env "PATH=$PATH" gcloud info - name: Run infra tests - run: python infra/presubmit.py infra-tests + run: sudo env "PATH=$PATH" python infra/presubmit.py infra-tests diff --git a/infra/build_specified_commit_test.py b/infra/build_specified_commit_test.py index 7a8c8fefb..34a1b11f8 100644 --- a/infra/build_specified_commit_test.py +++ b/infra/build_specified_commit_test.py @@ -41,9 +41,8 @@ class BuildImageIntegrationTests(unittest.TestCase): The old commit should show the error when its fuzzers run and the new one should not. """ - with tempfile.TemporaryDirectory() as tmp_dir: - test_case = test_repos.TEST_REPOS[0] + test_case = test_repos.TEST_REPOS[1] self.assertTrue(helper.build_image_impl(test_case.project_name)) host_src_dir = build_specified_commit.copy_src_from_docker( test_case.project_name, tmp_dir) @@ -74,10 +73,7 @@ class BuildImageIntegrationTests(unittest.TestCase): """Test the detect main repo function from build specific commit module.""" # TODO(metzman): Fix these tests so they don't randomly break because of # changes in the outside world. - test_repos_list = [ - repo for repo in test_repos.TEST_REPOS if repo.project_name != 'usrsctp' - ] - for example_repo in test_repos_list: + for example_repo in test_repos.TEST_REPOS: if example_repo.new_commit: # TODO(metzman): This function calls _build_image_with_retries which # has a long delay (30 seconds). Figure out how to make this quicker. @@ -111,7 +107,6 @@ class BuildImageIntegrationTests(unittest.TestCase): if __name__ == '__main__': - # Change to oss-fuzz main directory so helper.py runs correctly. if os.getcwd() != os.path.dirname(TEST_DIR_PATH): os.chdir(os.path.dirname(TEST_DIR_PATH)) diff --git a/infra/test_repos.py b/infra/test_repos.py index 080ba53eb..fb12fbec5 100644 --- a/infra/test_repos.py +++ b/infra/test_repos.py @@ -33,21 +33,10 @@ ExampleRepo = collections.namedtuple('ExampleRepo', [ TEST_DIR_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'testcases') -# WARNING: These tests are dependent upon the following repos existing and -# the specified commits existing. +# WARNING: Tests are dependent upon the following repos existing and the +# specified commits existing. # TODO(metzman): Fix this problem. TEST_REPOS = [ - ExampleRepo(project_name='usrsctp', - oss_repo_name='usrsctp', - git_repo_name='usrsctp', - image_location='/src', - git_url='https://github.com/sctplab/usrsctp', - old_commit='4886aaa49fb90e479226fcfc3241d74208908232', - new_commit='c710749b1053978179a027973a3ea3bccf20ee5c', - intro_commit='457d6ead58e82584d9dcb826f6739347f59ebd3a', - fuzz_target='fuzzer_connect', - test_case_path=os.path.join(TEST_DIR_PATH, - 'usrsctp_test_data')), ExampleRepo(project_name='curl', oss_repo_name='curl', git_repo_name='curl',