From c29e1eba981caebaffe4ad721ca1917b6a8d7a70 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Tue, 18 Aug 2020 13:48:40 +0200 Subject: [PATCH 1/8] Fix nmap error --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f8cfd30..22798e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,7 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/nmap script: # run illuminatio e2e tests @@ -100,6 +101,7 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/nmap script: # run illuminatio e2e tests From c90eb50aa2f3509ac86abd99673901626cc53f51 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Tue, 18 Aug 2020 14:29:28 +0200 Subject: [PATCH 2/8] Fix nmap error --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 22798e8..b0b7ffb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/nmap + - cp ./nmap /home/travis/.local/bin/nmap script: # run illuminatio e2e tests @@ -101,7 +101,7 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/nmap + - cp ./nmap /home/travis/.local/bin/nmap script: # run illuminatio e2e tests From dba719b56d305de1c5795cab3a7ce79f3cc8db9f Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Tue, 18 Aug 2020 14:37:00 +0200 Subject: [PATCH 3/8] Fix nmap error --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0b7ffb..fdccd8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,8 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - cp ./nmap /home/travis/.local/bin/nmap + - ls -lah ${TRAVIS_BUILD_DIR}/nmap + - cp ${TRAVIS_BUILD_DIR}/nmap /home/travis/.local/bin/nmap script: # run illuminatio e2e tests @@ -101,7 +102,8 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - cp ./nmap /home/travis/.local/bin/nmap + - mkdir -p /home/travis/.local/bin + - cp ${TRAVIS_BUILD_DIR}/nmap /home/travis/.local/bin/nmap script: # run illuminatio e2e tests From bb0290b9e9b0a47749a89bc218bfc6112f613cda Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Tue, 18 Aug 2020 15:00:50 +0200 Subject: [PATCH 4/8] Fix nmap error --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdccd8a..d6e1b36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ jobs: - pip install codecov - python setup.py install - ls -lah ${TRAVIS_BUILD_DIR}/nmap - - cp ${TRAVIS_BUILD_DIR}/nmap /home/travis/.local/bin/nmap + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap script: # run illuminatio e2e tests @@ -102,8 +102,7 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - mkdir -p /home/travis/.local/bin - - cp ${TRAVIS_BUILD_DIR}/nmap /home/travis/.local/bin/nmap + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap script: # run illuminatio e2e tests From 6890efb20d58eaa7a6e11add8f5172673f9505c4 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Thu, 20 Aug 2020 16:55:27 +0200 Subject: [PATCH 5/8] Add error handling --- tests/test_e2e.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 378c53c..1d51c7c 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -38,7 +38,10 @@ def clean_cluster(core_v1): for namespace in e2e_namespaces.items: core_v1.delete_namespace(name=namespace.metadata.name) # delete illuminatio resources - subprocess.check_output(["illuminatio", "clean"]) + try: + print(subprocess.check_output(["illuminatio", "clean"])) + except subprocess.CalledProcessError as cpe: + print(cpe) @pytest.mark.parametrize( @@ -66,7 +69,10 @@ def test__e2e__clean_setup__results_are_expected(e2e_test_case, api_client, apps "-o", f"{result_file.name}", ] - subprocess.check_output(cmd, timeout=120) + try: + print(subprocess.check_output(cmd, timeout=120)) + except subprocess.CalledProcessError as cpe: + print(cpe) # load contents of result and expected result = None with open(result_file_name, "r") as stream: From 87ecc26a83856164a197f36033203f6d4bd2af4f Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Thu, 20 Aug 2020 17:47:03 +0200 Subject: [PATCH 6/8] Fix nsenter version --- .travis.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++-- requirements.txt | 3 +- tests/test_e2e.py | 15 +++++++--- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6e1b36..156be6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ jobs: - codecov - stage: "Test" - name: "docker - calico e2e Tests" + name: "docker - calico e2e Tests (py3.8)" language: python cache: pip python: "3.8" @@ -77,7 +77,7 @@ jobs: - codecov - stage: "Test" - name: "containerd - calico e2e Tests" + name: "containerd - calico e2e Tests (py3.8)" language: python cache: pip python: "3.8" @@ -111,6 +111,77 @@ jobs: after_success: - codecov + - stage: "Test" + name: "docker - calico e2e Tests (py3.7)" + language: python + cache: pip + python: "3.7" + env: + - KUBECONFIG="$HOME/.kube/config" + # stable version in minikube v1.12.2 + - KUBERNETES_VERSION=v1.18.3 + - MINIKUBE_VERSION=v1.12.2 + - CHANGE_MINIKUBE_NONE_USER=true + - MINIKUBE_WANTUPDATENOTIFICATION=false + - MINIKUBE_WANTREPORTERRORPROMPT=false + - MINIKUBE_HOME=$HOME + + before_script: + # install dependent binaries + - curl --fail -Lo kubectl "https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + - curl --fail -Lo minikube "https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64" && chmod +x minikube && sudo mv minikube /usr/local/bin/ + - mkdir -p $HOME/.kube $HOME/.minikube + - touch $KUBECONFIG + - minikube config set driver docker + - ./local_dev/start_docker.sh + - pip install -r requirements.txt + - pip install codecov + - python setup.py install + - ls -lah ${TRAVIS_BUILD_DIR}/nmap + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap + + script: + # run illuminatio e2e tests + - ./local_dev/run_e2e_tests.sh + + after_success: + - codecov + + - stage: "Test" + name: "containerd - calico e2e Tests (py3.7)" + language: python + cache: pip + python: "3.7" + env: + - KUBECONFIG="$HOME/.kube/config" + # stable version in minikube v1.12.2 + - KUBERNETES_VERSION=v1.18.3 + - MINIKUBE_VERSION=v1.12.2 + - CHANGE_MINIKUBE_NONE_USER=true + - MINIKUBE_WANTUPDATENOTIFICATION=false + - MINIKUBE_WANTREPORTERRORPROMPT=false + - MINIKUBE_HOME=$HOME + + before_script: + # install dependent binaries + - curl --fail -Lo kubectl "https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + - curl --fail -Lo minikube "https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64" && chmod +x minikube && sudo mv minikube /usr/local/bin/ + - mkdir -p $HOME/.kube $HOME/.minikube + - touch $KUBECONFIG + - minikube config set driver docker + - ./local_dev/start_containerd.sh + - pip install -r requirements.txt + - pip install codecov + - python setup.py install + - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap + + script: + # run illuminatio e2e tests + - ./local_dev/run_e2e_tests.sh + + after_success: + - codecov + # merely build the image for untagged commits - stage: build name: "build images" diff --git a/requirements.txt b/requirements.txt index 3a1383b..d167625 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,8 @@ kubernetes==10.0.1 click==6.7 click_log==0.3.2 docker==3.7.0 -nsenter==0.2 +# Use current master to prevent pathlib error +git+https://github.com/zalando/python-nsenter.git@b7fd78fef24c456d88130c75fe734417728e97e8 attrs==19.1.0 pluggy==0.11.0 pytest==4.5.0 diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 1d51c7c..0d3eb4a 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -75,12 +75,19 @@ def test__e2e__clean_setup__results_are_expected(e2e_test_case, api_client, apps print(cpe) # load contents of result and expected result = None - with open(result_file_name, "r") as stream: - result = yaml.safe_load(stream) + try: + with open(result_file_name, "r") as stream: + result = yaml.safe_load(stream) + except OSError: + pass assert result is not None, f"Could not load result from {result_file_name}" expected = None - with open(expected_yaml, "r") as stream: - expected = yaml.safe_load(stream) + + try: + with open(expected_yaml, "r") as stream: + expected = yaml.safe_load(stream) + except OSError: + pass assert expected is not None, f"Could not load expected from {expected_yaml}" # assert that the correct cases have been generated and results match assert "cases" in result From 55cc52edcc47b096602a849fc36d7a9e4a615537 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Thu, 20 Aug 2020 17:49:38 +0200 Subject: [PATCH 7/8] Remove debug statement --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 156be6c..3b3ff96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,6 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - ls -lah ${TRAVIS_BUILD_DIR}/nmap - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap script: @@ -137,7 +136,6 @@ jobs: - pip install -r requirements.txt - pip install codecov - python setup.py install - - ls -lah ${TRAVIS_BUILD_DIR}/nmap - sudo cp ${TRAVIS_BUILD_DIR}/nmap /usr/local/bin/nmap script: From b40d07b108b5df6fba7d9953523055a7f1fc6d43 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Thu, 20 Aug 2020 17:51:00 +0200 Subject: [PATCH 8/8] Fix intend --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b3ff96..1f66487 100644 --- a/.travis.yml +++ b/.travis.yml @@ -110,7 +110,7 @@ jobs: after_success: - codecov - - stage: "Test" + - stage: "Test" name: "docker - calico e2e Tests (py3.7)" language: python cache: pip