Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
prow fix to run in the right repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kam D Kasravi committed Sep 4, 2019
1 parent 3a1eb06 commit 03c0b9a
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 13 deletions.
76 changes: 76 additions & 0 deletions testing/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import pytest

def pytest_addoption(parser):
parser.addoption(
"--app_path", action="store", default="",
help="Path where the KF application should be stored")

parser.addoption(
"--app_name", action="store", default="",
help="Name of the KF application")

parser.addoption(
"--kfctl_path", action="store", default="",
help="Path to kfctl.")

parser.addoption(
"--namespace", action="store", default="kubeflow",
help="Namespace to use.")

parser.addoption(
"--project", action="store", default="kubeflow-ci-deployment",
help="GCP project to deploy Kubeflow to")

parser.addoption(
"--config_path", action="store", default="",
help="The config to use for kfctl init")

parser.addoption(
"--use_basic_auth", action="store", default="False",
help="Use basic auth.")

parser.addoption(
"--use_istio", action="store", default="False",
help="Use istio.")

@pytest.fixture
def app_path(request):
return request.config.getoption("--app_path")

@pytest.fixture
def app_name(request):
return request.config.getoption("--app_name")

@pytest.fixture
def kfctl_path(request):
return request.config.getoption("--kfctl_path")

@pytest.fixture
def namespace(request):
return request.config.getoption("--namespace")

@pytest.fixture
def project(request):
return request.config.getoption("--project")

@pytest.fixture
def config_path(request):
return request.config.getoption("--config_path")

@pytest.fixture
def use_basic_auth(request):
value = request.config.getoption("--use_basic_auth").lower()

if value in ["t", "true"]:
return True
else:
return False

@pytest.fixture
def use_istio(request):
value = request.config.getoption("--use_istio").lower()

if value in ["t", "true"]:
return True
else:
return False
36 changes: 36 additions & 0 deletions testing/e2e/endpoint_ready_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import datetime
import logging
import os
import subprocess
import tempfile
import uuid
from retrying import retry

import pytest

from kubeflow.testing import util
from testing import deploy_utils
from testing import gcp_util

def test_endpoint_is_ready(project, app_name):
"""Test that Kubeflow was successfully deployed.
Args:
project: The gcp project that we deployed kubeflow
app_name: The name of the kubeflow deployment
"""
# Owned by project kubeflow-ci-deployment.
os.environ["CLIENT_ID"] = "29647740582-7meo6c7a9a76jvg54j0g2lv8lrsb4l8g.apps.googleusercontent.com"
if not gcp_util.endpoint_is_ready(
"https://{}.endpoints.{}.cloud.goog".format(app_name, project),
wait_min=25):
raise Exception("Endpoint not ready")

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format=('%(levelname)s|%(asctime)s'
'|%(pathname)s|%(lineno)d| %(message)s'),
datefmt='%Y-%m-%dT%H:%M:%S',
)
logging.getLogger().setLevel(logging.INFO)
pytest.main()
104 changes: 104 additions & 0 deletions testing/e2e/kf_is_ready_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import datetime
import logging
import os
import subprocess
import tempfile
import uuid
from retrying import retry

import pytest

from kubeflow.testing import util
from testing import deploy_utils

def test_kf_is_ready(namespace, use_basic_auth, use_istio):
"""Test that Kubeflow was successfully deployed.
Args:
namespace: The namespace Kubeflow is deployed to.
"""

logging.info("Using namespace %s", namespace)

# Need to activate account for scopes.
if os.getenv("GOOGLE_APPLICATION_CREDENTIALS"):
util.run(["gcloud", "auth", "activate-service-account",
"--key-file=" + os.environ["GOOGLE_APPLICATION_CREDENTIALS"]])

api_client = deploy_utils.create_k8s_client()

util.load_kube_config()

# Verify that components are actually deployed.
# TODO(jlewi): We need to parameterize this list based on whether
# we are using IAP or basic auth.
deployment_names = [
"argo-ui",
"centraldashboard",
"cloud-endpoints-controller",
"jupyter-web-app-deployment",
"metadata-db",
"metadata-deployment",
"metadata-ui",
"ml-pipeline",
"ml-pipeline-scheduledworkflow",
"ml-pipeline-ui",
"notebook-controller-deployment",
"tf-job-operator",
"pytorch-operator",
"katib-controller",
"workflow-controller",
]

stateful_set_names = [
"kfserving-controller-manager",
]

ingress_related_deployments = []
ingress_related_stateful_sets = []

if use_basic_auth:
deployment_names.extend(["basic-auth-login"])
ingress_related_stateful_sets.extend(["backend-updater"])
else:
ingress_related_deployments.extend(["iap-enabler"])
ingress_related_stateful_sets.extend(["backend-updater"])

# TODO(jlewi): Might want to parallelize this.
for deployment_name in deployment_names:
logging.info("Verifying that deployment %s started...", deployment_name)
util.wait_for_deployment(api_client, namespace, deployment_name, 10)

for stateful_set_name in stateful_set_names:
logging.info("Verifying that stateful set %s started...", stateful_set_name)
util.wait_for_statefulset(api_client, namespace, stateful_set_name)

ingress_namespace = "istio-system" if use_istio else namespace
for deployment_name in ingress_related_deployments:
logging.info("Verifying that deployment %s started...", deployment_name)
util.wait_for_deployment(api_client, ingress_namespace, deployment_name, 10)

for name in ingress_related_stateful_sets:
logging.info("Verifying that statefulset %s started...", name)
util.wait_for_statefulset(api_client, ingress_namespace, name)

# TODO(jlewi): We should verify that the ingress is created and healthy.

knative_namespace = "knative-serving"
knative_related_deployments = [
"activator",
"autoscaler",
"controller",
]
for deployment_name in knative_related_deployments:
logging.info("Verifying that deployment %s started...", deployment_name)
util.wait_for_deployment(api_client, knative_namespace, deployment_name, 10)

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format=('%(levelname)s|%(asctime)s'
'|%(pathname)s|%(lineno)d| %(message)s'),
datefmt='%Y-%m-%dT%H:%M:%S',
)
logging.getLogger().setLevel(logging.INFO)
pytest.main()
74 changes: 74 additions & 0 deletions testing/e2e/kfctl_delete_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""Run kfctl delete as a pytest.
We use this in order to generate a junit_xml file.
"""
import datetime
import logging
import os
import subprocess
import tempfile
import uuid
from retrying import retry

import pytest

from kubeflow.testing import util
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials

# TODO(gabrielwen): Move this to a separate test "kfctl_go_check_post_delete"
def get_endpoints_list(project):
cred = GoogleCredentials.get_application_default()
services_mgt = discovery.build('servicemanagement', 'v1', credentials=cred)
services = services_mgt.services()
next_page_token = None
endpoints = []

while True:
results = services.list(producerProjectId=project,
pageToken=next_page_token).execute()

for s in results.get("services", {}):
name = s.get("serviceName", "")
endpoints.append(name)
if not "nextPageToken" in results:
break
next_page_token = results["nextPageToken"]

return endpoints

def test_kfctl_delete(kfctl_path, app_path, project):
if not kfctl_path:
raise ValueError("kfctl_path is required")

if not app_path:
raise ValueError("app_path is required")

logging.info("Using kfctl path %s", kfctl_path)
logging.info("Using app path %s", app_path)

util.run([kfctl_path, "delete", "all", "--delete_storage", "-V"],
cwd=app_path)

# Use services.list instead of services.get because error returned is not
# 404, it's 403 which is confusing.
name = os.path.basename(app_path)
endpoint_name = "{deployment}.endpoints.{project}.cloud.goog".format(
deployment=name,
project=project)
logging.info("Verify endpoint service is deleted: " + endpoint_name)
if endpoint_name in get_endpoints_list(project):
msg = "Endpoint is not deleted: " + endpoint_name
logging.error(msg)
raise AssertionError(msg)
else:
logging.info("Verified endpoint service is deleted.")

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format=('%(levelname)s|%(asctime)s'
'|%(pathname)s|%(lineno)d| %(message)s'),
datefmt='%Y-%m-%dT%H:%M:%S',
)
logging.getLogger().setLevel(logging.INFO)
pytest.main()
Loading

0 comments on commit 03c0b9a

Please sign in to comment.