Skip to content

Commit

Permalink
Remove octopoes integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruinsslot committed Oct 23, 2023
1 parent d089341 commit 6f8dfb1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 88 deletions.
29 changes: 0 additions & 29 deletions mula/.ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ services:
- .ci/.env.test
depends_on:
- ci_postgres
- ci_octopoes
- ci_bytes
- ci_katalogus
- ci_rabbitmq
Expand Down Expand Up @@ -90,33 +89,5 @@ services:
ci_postgres:
condition: service_healthy

ci_octopoes:
build:
context: ../octopoes/
target: dev
args:
ENVIRONMENT: dev
ports:
- "127.0.0.1:8001:80"
env_file:
- .ci/.env.test
command: uvicorn octopoes.api.api:app --host 0.0.0.0 --port 80 --reload --reload-dir /app/octopoes/octopoes
volumes:
- ../octopoes:/app/octopoes
depends_on:
ci_crux:
condition: service_started
ci_rabbitmq:
condition: service_healthy

ci_crux:
image: "ghcr.io/dekkers/xtdb-http-multinode:main"
restart: unless-stopped
ports:
- "127.0.0.1:3000:3000"
volumes:
- xtdb-data:/var/lib/xtdb

volumes:
bytes-data:
xtdb-data:
4 changes: 2 additions & 2 deletions mula/scheduler/connectors/services/bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def __init__(self, host: str, source: str, user: str, password: str, timeout: in
super().__init__(host=host, source=source, timeout=timeout)

def login(self) -> None:
self.headers.update({"Authorization": f"bearer {self._get_token()}"})
self.headers.update({"Authorization": f"bearer {self.get_token()}"})

@staticmethod
def _verify_response(response: requests.Response) -> None:
response.raise_for_status()

def _get_token(self) -> str:
def get_token(self) -> str:
url = f"{self.host}/token"
response = self.post(
url=url,
Expand Down
64 changes: 7 additions & 57 deletions mula/tests/integration/test_services.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import copy
import time
import unittest
import urllib.parse
from unittest import mock

from scheduler import config, models, storage
from scheduler.connectors import services
from scheduler.utils import remove_trailing_slash

from tests.factories import OrganisationFactory, PluginFactory
from tests.factories import PluginFactory


class BytesTestCase(unittest.TestCase):
Expand All @@ -27,15 +26,6 @@ def test_login(self):
self.assertIsNotNone(self.service_bytes.headers)
self.assertIsNotNone(self.service_bytes.headers.get("Authorization"))

def test_login_token_refresh(self):
self.service_bytes.login()
initial_token = copy.deepcopy(self.service_bytes.headers.get("Authorization"))

self.service_bytes.login()
refresh_token = copy.deepcopy(self.service_bytes.headers.get("Authorization"))

self.assertNotEqual(initial_token, refresh_token)

def test_expired_token_refresh(self):
self.service_bytes.get_last_run_boefje(
boefje_id="boefje-1",
Expand All @@ -55,14 +45,6 @@ def test_expired_token_refresh(self):

self.assertNotEqual(initial_token, refresh_token)

# TODO: do we want to mock the response here?
def test_get_last_run_boefje(self):
pass

# TODO: do we want to mock the response here?
def test_get_last_run_boefje_by_organisation_id(self):
pass


class KatalogusTestCase(unittest.TestCase):
def setUp(self) -> None:
Expand All @@ -81,17 +63,12 @@ def tearDown(self) -> None:
self.service_katalogus.organisations_normalizer_type_cache.reset()
models.Base.metadata.drop_all(self.dbconn.engine)

def test_get_organisations(self):
orgs = self.service_katalogus.get_organisations()
self.assertIsInstance(orgs, list)
self.assertEqual(len(orgs), 0)

@mock.patch("scheduler.connectors.services.Katalogus.get_organisations")
def test_flush_organisations_plugin_cache(self, mock_get_organisations):
# Mock
mock_get_organisations.return_value = [
OrganisationFactory(id="org-1"),
OrganisationFactory(id="org-2"),
models.Organisation(id="org-1", name="org-1"),
models.Organisation(id="org-2", name="org-2"),
]

# Act
Expand All @@ -118,8 +95,8 @@ def test_flush_organisations_plugin_cache_empty(self, mock_get_organisations):
def test_flush_organisations_boefje_type_cache(self, mock_get_organisations, mock_get_plugins_by_organisation):
# Mock
mock_get_organisations.return_value = [
OrganisationFactory(id="org-1"),
OrganisationFactory(id="org-2"),
models.Organisation(id="org-1", name="org-1"),
models.Organisation(id="org-2", name="org-2"),
]

mock_get_plugins_by_organisation.return_value = [
Expand All @@ -146,8 +123,8 @@ def test_flush_organisations_boefje_type_cache(self, mock_get_organisations, moc
def test_flush_organisations_normalizer_type_cache(self, mock_get_organisations, mock_get_plugins_by_organisation):
# Mock
mock_get_organisations.return_value = [
OrganisationFactory(id="org-1"),
OrganisationFactory(id="org-2"),
models.Organisation(id="org-1", name="org-1"),
models.Organisation(id="org-2", name="org-2"),
]

mock_get_plugins_by_organisation.return_value = [
Expand All @@ -169,12 +146,6 @@ def test_flush_organisations_normalizer_type_cache(self, mock_get_organisations,
self.assertIsNotNone(self.service_katalogus.organisations_normalizer_type_cache.get("org-2").get("Hostname"))
self.assertEqual(len(self.service_katalogus.organisations_normalizer_type_cache.get("org-2").get("Hostname")), 2)

def test_get_plugins_by_org_id(self):
pass

def test_get_plugins_by_org_id_expired(self):
pass

@mock.patch("scheduler.connectors.services.Katalogus.get_plugins_by_organisation")
def test_get_new_boefjes_by_org_id(self, mock_get_plugins_by_organisation):
# Mock
Expand Down Expand Up @@ -218,24 +189,3 @@ def test_get_new_boefjes_by_org_id(self, mock_get_plugins_by_organisation):
self.assertIsNotNone(self.service_katalogus.organisations_new_boefjes_cache.get("org-1").get("plugin-5"))
self.assertEqual(len(new_boefjes), 1)
self.assertEqual(new_boefjes[0].id, "plugin-5")


class OctopoesTestCase(unittest.TestCase):
def setUp(self):
self.config = config.settings.Settings()
self.service_octopoes = services.Octopoes(
host=remove_trailing_slash(str(self.config.host_octopoes)),
source="scheduler_test",
orgs=[OrganisationFactory(id="org-1"), OrganisationFactory(id="org-2")],
timeout=5,
)

def test_is_host_available(self):
parsed_url = urllib.parse.urlparse(str(self.config.host_octopoes))
hostname, port = parsed_url.hostname, parsed_url.port
response = self.service_octopoes.is_host_available(hostname, port)
self.assertTrue(response)

def test_is_healthy(self):
response = self.service_octopoes.is_healthy()
self.assertTrue(response)

0 comments on commit 6f8dfb1

Please sign in to comment.