Skip to content

Commit

Permalink
Update py unittest (kubeflow#794)
Browse files Browse the repository at this point in the history
* add tekton yamls

* add lint and test source path at the time of py test run

* make hydrate
  • Loading branch information
subodh101 authored Nov 14, 2020
1 parent 0780b98 commit af27d1d
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ spec:
in the form of 'gs://'
name: artifacts-gcs
type: string
- default: ""
description: It is the location of the directory to run lint over. If we set it
"", then it finds all the *.py files in the repository and test lint over them.
name: lint-src-dir
type: string
- default: ""
description: It is the location of the test directory which contains all the unit
tests. If we set it "", then it finds all the *_test.py files in the repository
and run unit test over them.
name: test-src-dir
type: string
resources:
- name: testing-repo
type: git
Expand All @@ -17,6 +28,8 @@ spec:
params:
- name: artifacts-gcs
value: $(params.artifacts-gcs)
- name: lint-src-dir
value: $(params.lint-src-dir)
resources:
inputs:
- name: testing-repo
Expand All @@ -27,6 +40,8 @@ spec:
params:
- name: artifacts-gcs
value: $(params.artifacts-gcs)
- name: test-src-dir
value: $(params.test-src-dir)
resources:
inputs:
- name: testing-repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,42 @@ metadata:
spec:
inputs:
params:
- default: py-lint
description: Name to give the test results file.
name: test-name
type: string
- description: GCS bucket and directory artifacts will be uploaded to. Should
be in the form of 'gs://'
name: artifacts-gcs
type: string
- default: gcr.io/kubeflow-ci/test-worker:latest
description: The docker image to run the tests in
- default: ""
description: It is the location of the directory to run lint over. If we set
it "", then it finds all the *.py files in the repository and test lint over
them.
name: lint-src-dir
type: string
- default: gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3
name: test-image
type: string
- default: py-lint
description: Name to give the test results file.
name: test-name
type: string
resources:
- description: The GitHub repo containing code to test
name: testing-repo
type: git
steps:
- env:
- name: PYTHONPATH
value: /workspace/$(inputs.resources.testing-repo.name)/py
value: /srcCache/kubeflow/testing/py
image: $(inputs.params.test-image)
name: py-lint
script: |
#!/usr/bin/env bash
set -x
mkdir -p /workspace/artifacts
echo Current Directory: $(pwd)
cd /workspace/$(inputs.resources.testing-repo.name)/py/kubeflow/testing/
cd /srcCache/kubeflow/testing/py/kubeflow/testing/
pytest py_lint_test.py -s \
--rcfile=/workspace/$(inputs.resources.testing-repo.name)/.pylintrc \
--src_dir=/workspace/$(inputs.resources.testing-repo.name)/$(inputs.params.lint-src-dir) \
--timeout=500 \
--junitxml=/workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test results:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@ metadata:
spec:
inputs:
params:
- default: py-unit
description: Name to give the test results file.
name: test-name
type: string
- description: GCS bucket and directory artifacts will be uploaded to. Should
be in the form of 'gs://'
name: artifacts-gcs
type: string
- default: gcr.io/kubeflow-ci/test-worker:latest
description: The docker image to run the tests in
- default: ""
description: It is the location of the test directory which contains all the
unit tests. If we set it "", then it finds all the *_test.py files in the
repository and run unit test over them.
name: test-src-dir
type: string
- default: gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3
name: test-image
type: string
- default: py-unit
description: Name to give the test results file.
name: test-name
type: string
resources:
- description: The GitHub repo containing code to test
name: testing-repo
type: git
steps:
- env:
- args:
- -m
- kubeflow.testing.test_py_checks
- --artifacts_dir=/workspace/artifacts/junit_$(inputs.params.test-name)
- --src_dir=/workspace/$(inputs.resources.testing-repo.name)/$(inputs.params.test-src-dir)
command:
- python
env:
- name: PYTHONPATH
value: /workspace/$(inputs.resources.testing-repo.name)/py
value: /srcCache/kubeflow/testing/py
image: $(inputs.params.test-image)
name: unit-test
script: |
#!/usr/bin/env bash
set -x
mkdir -p /workspace/artifacts
echo Current Directory: $(pwd)
python -m kubeflow.testing.test_py_checks \
--artifacts_dir=/workspace/artifacts/junit_$(inputs.params.test-name).xml \
--src_dir=/workspace/$(inputs.resources.testing-repo.name)/py/kubeflow/tests
echo Test results:
cat /workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test finished.
- args:
- -m
- kubeflow.testing.tekton_client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ spec:
in the form of 'gs://'
name: artifacts-gcs
type: string
- default: ""
description: It is the location of the directory to run lint over. If we set it
"", then it finds all the *.py files in the repository and test lint over them.
name: lint-src-dir
type: string
- default: ""
description: It is the location of the test directory which contains all the unit
tests. If we set it "", then it finds all the *_test.py files in the repository
and run unit test over them.
name: test-src-dir
type: string
resources:
- name: testing-repo
type: git
Expand All @@ -17,6 +28,8 @@ spec:
params:
- name: artifacts-gcs
value: $(params.artifacts-gcs)
- name: lint-src-dir
value: $(params.lint-src-dir)
resources:
inputs:
- name: testing-repo
Expand All @@ -27,6 +40,8 @@ spec:
params:
- name: artifacts-gcs
value: $(params.artifacts-gcs)
- name: test-src-dir
value: $(params.test-src-dir)
resources:
inputs:
- name: testing-repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,42 @@ metadata:
spec:
inputs:
params:
- default: py-lint
description: Name to give the test results file.
name: test-name
type: string
- description: GCS bucket and directory artifacts will be uploaded to. Should
be in the form of 'gs://'
name: artifacts-gcs
type: string
- default: gcr.io/kubeflow-ci/test-worker:latest
description: The docker image to run the tests in
- default: ""
description: It is the location of the directory to run lint over. If we set
it "", then it finds all the *.py files in the repository and test lint over
them.
name: lint-src-dir
type: string
- default: gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3
name: test-image
type: string
- default: py-lint
description: Name to give the test results file.
name: test-name
type: string
resources:
- description: The GitHub repo containing code to test
name: testing-repo
type: git
steps:
- env:
- name: PYTHONPATH
value: /workspace/$(inputs.resources.testing-repo.name)/py
value: /srcCache/kubeflow/testing/py
image: $(inputs.params.test-image)
name: py-lint
script: |
#!/usr/bin/env bash
set -x
mkdir -p /workspace/artifacts
echo Current Directory: $(pwd)
cd /workspace/$(inputs.resources.testing-repo.name)/py/kubeflow/testing/
cd /srcCache/kubeflow/testing/py/kubeflow/testing/
pytest py_lint_test.py -s \
--rcfile=/workspace/$(inputs.resources.testing-repo.name)/.pylintrc \
--src_dir=/workspace/$(inputs.resources.testing-repo.name)/$(inputs.params.lint-src-dir) \
--timeout=500 \
--junitxml=/workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test results:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@ metadata:
spec:
inputs:
params:
- default: py-unit
description: Name to give the test results file.
name: test-name
type: string
- description: GCS bucket and directory artifacts will be uploaded to. Should
be in the form of 'gs://'
name: artifacts-gcs
type: string
- default: gcr.io/kubeflow-ci/test-worker:latest
description: The docker image to run the tests in
- default: ""
description: It is the location of the test directory which contains all the
unit tests. If we set it "", then it finds all the *_test.py files in the
repository and run unit test over them.
name: test-src-dir
type: string
- default: gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3
name: test-image
type: string
- default: py-unit
description: Name to give the test results file.
name: test-name
type: string
resources:
- description: The GitHub repo containing code to test
name: testing-repo
type: git
steps:
- env:
- args:
- -m
- kubeflow.testing.test_py_checks
- --artifacts_dir=/workspace/artifacts/junit_$(inputs.params.test-name)
- --src_dir=/workspace/$(inputs.resources.testing-repo.name)/$(inputs.params.test-src-dir)
command:
- python
env:
- name: PYTHONPATH
value: /workspace/$(inputs.resources.testing-repo.name)/py
value: /srcCache/kubeflow/testing/py
image: $(inputs.params.test-image)
name: unit-test
script: |
#!/usr/bin/env bash
set -x
mkdir -p /workspace/artifacts
echo Current Directory: $(pwd)
python -m kubeflow.testing.test_py_checks \
--artifacts_dir=/workspace/artifacts/junit_$(inputs.params.test-name).xml \
--src_dir=/workspace/$(inputs.resources.testing-repo.name)/py/kubeflow/tests
echo Test results:
cat /workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test finished.
- args:
- -m
- kubeflow.testing.tekton_client
Expand Down
4 changes: 4 additions & 0 deletions tekton/runs/py-test-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ spec:
params:
- name: artifacts-gcs
value: "gs://kubeflow-ci-deployment/py-test"
- name: lint-src-dir
value: "py"
- name: test-src-dir
value: "py/kubeflow/tests"
serviceAccountName: kf-ci
resources:
- name: testing-repo
Expand Down
14 changes: 14 additions & 0 deletions tekton/templates/pipelines/py-unittests-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ spec:
type: string
description: GCS bucket and directory artifacts will be uploaded to. Should be
in the form of 'gs://'
- name: lint-src-dir
type: string
default: ""
description: It is the location of the directory to run lint over.
If we set it "", then it finds all the *.py files in the repository and test lint over them.
- name: test-src-dir
type: string
default: ""
description: It is the location of the test directory which contains all the unit tests.
If we set it "", then it finds all the *_test.py files in the repository and run unit test over them.
resources:
- name: testing-repo
type: git
Expand All @@ -16,6 +26,8 @@ spec:
params:
- name: artifacts-gcs
value: "$(params.artifacts-gcs)"
- name: lint-src-dir
value: "$(params.lint-src-dir)"
resources:
inputs:
- name: testing-repo
Expand All @@ -26,6 +38,8 @@ spec:
params:
- name: artifacts-gcs
value: "$(params.artifacts-gcs)"
- name: test-src-dir
value: "$(params.test-src-dir)"
resources:
inputs:
- name: testing-repo
Expand Down
21 changes: 13 additions & 8 deletions tekton/templates/tasks/py-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ metadata:
spec:
inputs:
params:
- name: test-name
type: string
default: py-lint
description: Name to give the test results file.
- name: artifacts-gcs
type: string
description: GCS bucket and directory artifacts will be uploaded to. Should
be in the form of 'gs://'
- name: lint-src-dir
type: string
default: ""
description: It is the location of the directory to run lint over.
If we set it "", then it finds all the *.py files in the repository and test lint over them.
- name: test-image
type: string
default: gcr.io/kubeflow-ci/test-worker:latest
description: The docker image to run the tests in
default: gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3 # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"test-image","value":"gcr.io/kubeflow-ci/test-worker-py3@sha256:a749d7fa4d77466c892a206d3adf0909e86717da898dbd12378e6cbed59ffbd3"}]}} description: The docker image to run the tests in
- name: test-name
type: string
default: py-lint
description: Name to give the test results file.
resources:
- name: testing-repo
type: git
Expand All @@ -29,17 +33,18 @@ spec:
set -x
mkdir -p /workspace/artifacts
echo Current Directory: $(pwd)
cd /workspace/$(inputs.resources.testing-repo.name)/py/kubeflow/testing/
cd /srcCache/kubeflow/testing/py/kubeflow/testing/
pytest py_lint_test.py -s \
--rcfile=/workspace/$(inputs.resources.testing-repo.name)/.pylintrc \
--src_dir=/workspace/$(inputs.resources.testing-repo.name)/$(inputs.params.lint-src-dir) \
--timeout=500 \
--junitxml=/workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test results:
cat /workspace/artifacts/junit_$(inputs.params.test-name).xml
echo Test finished.
env:
- name: PYTHONPATH
value: /workspace/$(inputs.resources.testing-repo.name)/py
value: /srcCache/kubeflow/testing/py
# This step is designed to be generic: given the output directory, it will try to
# parse all the XML files with prefix of junit and error out if failures been found.
- name: copy-artifacts
Expand Down
Loading

0 comments on commit af27d1d

Please sign in to comment.