Skip to content

Commit

Permalink
Updated test artifacts to report repos in finished/metadata (kubeflow…
Browse files Browse the repository at this point in the history
…#349)

* updated test artifacts to report repos in finished/metadata

* fixed atypo

* unset PULL_REFS after used in testing finished artifact

* formating

* lint error

* fixed pylint error
  • Loading branch information
zabbasi authored and k8s-ci-robot committed Apr 2, 2019
1 parent 6872f51 commit 2cc1bfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions py/kubeflow/testing/prow_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def create_finished(success, workflow_phase, ui_urls):
"metadata": {
},
}
# kettle (https://github.com/kubernetes/test-infra/tree/master/kettle) expexts
# to get commit information in finished["metadata"]["repos"].
# We leverage kettle to upload kubeflow test logs into bigquery.
PULL_REFS = os.getenv("PULL_REFS", "")
repo_owner = os.getenv("REPO_OWNER", "")
repo_name = os.getenv("REPO_NAME", "")
if repo_owner and PULL_REFS:
finished["metadata"]["repos"] = {}
finished["metadata"]["repos"][repo_owner + "/" + repo_name] = PULL_REFS

names = set()
names.update(workflow_phase.keys())
Expand Down
8 changes: 7 additions & 1 deletion py/kubeflow/tests/prow_artifacts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def testCreateStartedPresubmit(self, mock_time): # pylint: disable=no-self-use
@mock.patch("kubeflow.testing.prow_artifacts.time.time")
def testCreateFinished(self, mock_time): # pylint: disable=no-self-use
"""Test create finished job."""
os.environ["REPO_OWNER"] = "fake_org"
os.environ["REPO_NAME"] = "fake_name"
os.environ["PULL_REFS"] = "master:abcd,72:efgh"
mock_time.return_value = 1000
workflow_phase = {
"wfA": "Succeeded"
Expand All @@ -45,13 +48,16 @@ def testCreateFinished(self, mock_time): # pylint: disable=no-self-use
"timestamp": 1000,
"result": "FAILED",
"metadata": {
"repos": {
"fake_org/fake_name": "master:abcd,72:efgh"
},
"wfA-phase": "Succeeded",
"wfA-ui": "https://example.com",
},
}

actual = prow_artifacts.create_finished(False, workflow_phase, test_urls)

os.environ.pop("PULL_REFS")
self.assertEqual(expected, json.loads(actual))

@mock.patch("kubeflow.testing.prow_artifacts.util.run")
Expand Down

0 comments on commit 2cc1bfb

Please sign in to comment.