Skip to content

Commit

Permalink
[pre-commit.ci] Apply automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jul 21, 2023
1 parent 9625b0d commit 08f9400
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
6 changes: 4 additions & 2 deletions src/_nebari/provider/cloud/digital_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def regions():
def kubernetes_versions(region):
"""Return list of available kubernetes supported by cloud provider. Sorted from oldest to latest."""
supported_kubernetes_versions = sorted(
[_["slug"].split('-')[0] for _ in _kubernetes_options()["options"]["versions"]]
[_["slug"].split("-")[0] for _ in _kubernetes_options()["options"]["versions"]]
)
filtered_versions = filter_by_highest_supported_k8s_version(
supported_kubernetes_versions
)
filtered_versions = filter_by_highest_supported_k8s_version(supported_kubernetes_versions)
return [f"{v}-do.0" for v in filtered_versions]
2 changes: 1 addition & 1 deletion tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from _nebari.render import render_template, set_env_vars_in_config

from .utils import render_config_partial, PRESERVED_DIR
from .utils import PRESERVED_DIR, render_config_partial


@pytest.fixture
Expand Down
4 changes: 1 addition & 3 deletions tests_e2e/playwright/run_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def __init__(self, navigator: Navigator):
self.nav = navigator
self.nav.initialize

def run(
self, path, expected_output_text, conda_env, runtime=30000, retry=2
):
def run(self, path, expected_output_text, conda_env, runtime=30000, retry=2):
"""Run jupyter notebook and check for expected output text anywhere on
the page.
Expand Down
18 changes: 8 additions & 10 deletions tests_integration/deployment_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import logging
import pytest
import os
import random
import string
import warnings

from pathlib import Path

import pytest
import yaml
from urllib3.exceptions import InsecureRequestWarning

from _nebari.deploy import deploy_configuration
from _nebari.destroy import destroy_configuration
from _nebari.render import render_template
from urllib3.exceptions import InsecureRequestWarning
from tests.utils import render_config_partial

import random
import string

DEPLOYMENT_DIR = '_test_deploy'
DEPLOYMENT_DIR = "_test_deploy"

logger = logging.getLogger(__name__)

Expand All @@ -30,7 +28,7 @@ def ignore_warnings():

def _random_letters(length=5):
letters = string.ascii_letters
return ''.join(random.choice(letters) for _ in range(length)).lower()
return "".join(random.choice(letters) for _ in range(length)).lower()


def _get_or_create_deployment_directory(cloud):
Expand All @@ -48,8 +46,8 @@ def _get_or_create_deployment_directory(cloud):


def _set_do_environment():
os.environ['AWS_ACCESS_KEY_ID'] = os.environ['SPACES_ACCESS_KEY_ID']
os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ['SPACES_SECRET_ACCESS_KEY']
os.environ["AWS_ACCESS_KEY_ID"] = os.environ["SPACES_ACCESS_KEY_ID"]
os.environ["AWS_SECRET_ACCESS_KEY"] = os.environ["SPACES_SECRET_ACCESS_KEY"]


@pytest.fixture(scope="session")
Expand Down
52 changes: 39 additions & 13 deletions tests_integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import requests

from tests_integration.deployment_fixtures import on_cloud, ignore_warnings
from tests_integration.deployment_fixtures import ignore_warnings, on_cloud


@pytest.fixture(autouse=True)
Expand All @@ -12,25 +12,51 @@ def disable_warnings():
@on_cloud("do")
def test_do_service_status(deploy):
"""Tests if deployment on DigitalOcean succeeds"""
service_urls = deploy['stages/07-kubernetes-services']['service_urls']['value']
assert requests.get(service_urls["jupyterhub"]['health_url'], verify=False).status_code == 200
assert requests.get(service_urls["keycloak"]['health_url'], verify=False).status_code == 200
assert requests.get(service_urls["dask_gateway"]['health_url'], verify=False).status_code == 200
assert requests.get(service_urls["conda_store"]['health_url'], verify=False).status_code == 200
assert requests.get(service_urls["monitoring"]['health_url'], verify=False).status_code == 200
service_urls = deploy["stages/07-kubernetes-services"]["service_urls"]["value"]
assert (
requests.get(service_urls["jupyterhub"]["health_url"], verify=False).status_code
== 200
)
assert (
requests.get(service_urls["keycloak"]["health_url"], verify=False).status_code
== 200
)
assert (
requests.get(
service_urls["dask_gateway"]["health_url"], verify=False
).status_code
== 200
)
assert (
requests.get(
service_urls["conda_store"]["health_url"], verify=False
).status_code
== 200
)
assert (
requests.get(service_urls["monitoring"]["health_url"], verify=False).status_code
== 200
)


@on_cloud("do")
def test_verify_keycloak_users(deploy):
"""Tests if keycloak is working and it has expected users"""
keycloak_credentials = deploy['stages/05-kubernetes-keycloak']['keycloak_credentials']['value']
keycloak_credentials = deploy["stages/05-kubernetes-keycloak"][
"keycloak_credentials"
]["value"]
from keycloak import KeycloakAdmin

keycloak_admin = KeycloakAdmin(
server_url=f"{keycloak_credentials['url']}/auth/",
username=keycloak_credentials['username'],
password=keycloak_credentials['password'],
realm_name=keycloak_credentials['realm'],
client_id=keycloak_credentials['client_id'],
username=keycloak_credentials["username"],
password=keycloak_credentials["password"],
realm_name=keycloak_credentials["realm"],
client_id=keycloak_credentials["client_id"],
verify=False,
)
assert set([u['username'] for u in keycloak_admin.get_users()]) == {'nebari-bot', 'read-only-user', 'root'}
assert set([u["username"] for u in keycloak_admin.get_users()]) == {
"nebari-bot",
"read-only-user",
"root",
}

0 comments on commit 08f9400

Please sign in to comment.