Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanhphan1147 committed Dec 11, 2023
1 parent 8b9012c commit 7a75828
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from pytest import Parser


def pytest_addoption(parser: Parser):
"""Parse additional pytest options.
Expand Down
27 changes: 12 additions & 15 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
import secrets
import typing

import jenkinsapi.jenkins
import pytest
import pytest_asyncio
from juju.action import Action
from juju.application import Application
from juju.client._definitions import FullStatus, UnitStatus
from juju.model import Controller, Model
from juju.unit import Unit
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)

BLOCKED_STATUS_NAME = "blocked"


@pytest_asyncio.fixture(scope="module", name="charm")
async def charm_fixture(request: pytest.FixtureRequest, ops_test: OpsTest) -> str:
"""The path to charm."""
Expand Down Expand Up @@ -51,23 +48,20 @@ async def application_fixture(
model: Model, charm: str, num_agents: int
) -> typing.AsyncGenerator[Application, None]:
"""Build and deploy the charm."""

# Deploy the charm and wait for blocked status
application = await model.deploy(
charm, num_units=num_agents, series="focal"
)
application = await model.deploy(charm, num_units=num_agents, series="focal")
await model.wait_for_idle(apps=[application.name], status=BLOCKED_STATUS_NAME)

yield application

await model.remove_application(application.name, block_until_done=True, force=True)


# Connect the k8s controller
@pytest_asyncio.fixture(scope="module", name="k8s_controller")
async def jenkins_server_k8s_controller_fixture() -> typing.AsyncGenerator[Controller, None]:
"""The juju controller on microk8s.
The controller is bootstrapped in "pre_run_script.sh"."""
The controller is bootstrapped in "pre_run_script.sh".
"""
controller = Controller()
await controller.connect("controller")
cloud = await controller.get_cloud()
Expand All @@ -77,7 +71,7 @@ async def jenkins_server_k8s_controller_fixture() -> typing.AsyncGenerator[Contr

await controller.disconnect()

# Create the model

@pytest_asyncio.fixture(scope="module", name="jenkins_server_model")
async def jenkins_server_model_fixture(
k8s_controller: Controller,
Expand All @@ -90,9 +84,11 @@ async def jenkins_server_model_fixture(

yield model

await k8s_controller.destroy_models(model.name, destroy_storage=True, force=True, max_wait= 10 * 60)
await k8s_controller.destroy_models(
model.name, destroy_storage=True, force=True, max_wait=10 * 60
)


# Deploy jenkins-k8s
@pytest_asyncio.fixture(scope="module", name="jenkins_server")
async def jenkins_server_fixture(jenkins_server_model: Model) -> Application:
"""The jenkins machine server."""
Expand All @@ -102,12 +98,13 @@ async def jenkins_server_fixture(jenkins_server_model: Model) -> Application:
timeout=20 * 60,
wait_for_active=True,
idle_period=30,
raise_on_error=False
raise_on_error=False,
)

return jenkins

# # Get IP of jenkins-k8s

# Get IP of jenkins-k8s
# @pytest_asyncio.fixture(scope="module", name="server_unit_ip")
# async def server_unit_ip_fixture(jenkins_server_model: Model, jenkins_server: Application):
# """Get Jenkins machine server charm unit IP."""
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

MICROK8S_CONTROLLER = "controller"


async def test_agent_relation(
jenkins_server: Application,
jenkins_agent_application: Application,
Expand Down

0 comments on commit 7a75828

Please sign in to comment.