Skip to content

Commit

Permalink
Do not strip ingress prefix (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-seijas authored Mar 11, 2024
1 parent 07fa609 commit 4d3e7e9
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jobs:
juju-channel: 3.1/stable
self-hosted-runner: true
self-hosted-runner-label: "xlarge"
microk8s-addons: "dns ingress rbac storage metallb:10.15.119.2-10.15.119.4"
2 changes: 1 addition & 1 deletion src-docs/actions.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Initialize the observer and register actions handlers.

- <b>`charm`</b>: The parent charm to attach the observer to.
- <b>`state`</b>: The Jenkins charm state.
- <b>`jenkins_instance`</b>: The Jenkins wrapper.
- <b>`jenkins_instance`</b>: The Jenkins instance.


---
Expand Down
2 changes: 1 addition & 1 deletion src-docs/agent.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Initialize the observer and register event handlers.

- <b>`charm`</b>: The parent charm to attach the observer to.
- <b>`state`</b>: The charm state.
- <b>`jenkins_instance`</b>: The Jenkins wrapper.
- <b>`jenkins_instance`</b>: The Jenkins instance.
- <b>`ingress_observer`</b>: The ingress observer responsible for agent discovery.


Expand Down
2 changes: 1 addition & 1 deletion src-docs/ingress.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Shortcut for more simple access the model.

---

<a href="../src/ingress.py#L34"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/ingress.py#L33"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `get_path`

Expand Down
2 changes: 1 addition & 1 deletion src/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, charm: ops.CharmBase, state: State, jenkins_instance: jenkins
Args:
charm: The parent charm to attach the observer to.
state: The Jenkins charm state.
jenkins_instance: The Jenkins wrapper.
jenkins_instance: The Jenkins instance.
"""
super().__init__(charm, "actions-observer")
self.charm = charm
Expand Down
2 changes: 1 addition & 1 deletion src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
Args:
charm: The parent charm to attach the observer to.
state: The charm state.
jenkins_instance: The Jenkins wrapper.
jenkins_instance: The Jenkins instance.
ingress_observer: The ingress observer responsible for agent discovery.
"""
super().__init__(charm, "agent-observer")
Expand Down
1 change: 0 additions & 1 deletion src/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __init__(self, charm: ops.CharmBase, key: str, relation_name: str):
self.charm,
relation_name=relation_name,
port=jenkins.WEB_PORT,
strip_prefix=True,
)

def get_path(self) -> str:
Expand Down
8 changes: 2 additions & 6 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,17 +777,13 @@ def external_hostname_fixture() -> str:


@pytest_asyncio.fixture(scope="module", name="traefik_application_and_unit_ip")
async def traefik_application_fixture(model: Model, external_hostname: str):
async def traefik_application_fixture(model: Model):
"""The application related to Jenkins via ingress v2 relation."""
traefik = await model.deploy(
"traefik-k8s",
channel="edge",
trust=True,
config={
"external_hostname": external_hostname,
"routing_mode": "path",
"enable_experimental_forward_auth": True,
},
config={"routing_mode": "path"},
)

await model.wait_for_idle(
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/test_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ async def test_ingress_integration(
model: Model,
application: Application,
traefik_application_and_unit_ip: typing.Tuple[Application, str],
external_hostname: str,
):
"""
arrange: deploy the Jenkins charm and establish relations via ingress.
Expand All @@ -35,7 +34,6 @@ async def test_ingress_integration(
)
response = requests.get(
f"http://{traefik_address}/{model.name}-{application.name}",
headers={"Host": f"{external_hostname}"},
timeout=5,
)

Expand All @@ -59,7 +57,12 @@ async def test_agent_discovery_ingress_integration(
machine_model = jenkins_machine_agents.model
traefik_application, traefik_address = traefik_application_and_unit_ip
# The jenkins prefix will be fetch from the main ingress, which is not related for this test
await traefik_application.set_config({"routing_mode": "subdomain"})
await traefik_application.set_config(
{
"routing_mode": "subdomain",
"external_hostname": external_hostname,
}
)
await application.relate(
AGENT_DISCOVERY_INGRESS_RELATION_NAME, f"{traefik_application.name}:ingress"
)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def test_version_error(
assert: JenkinsError exception is raised.
"""
monkeypatch.setattr(jenkins.requests, "get", MagicMock(side_effect=exception))
jenking_wrapper = jenkins.Jenkins(mock_env)
jenking_instance = jenkins.Jenkins(mock_env)

with pytest.raises(jenkins.JenkinsError):
jenking_wrapper.version # pylint: disable=pointless-statement
jenking_instance.version # pylint: disable=pointless-statement


def test_version(
Expand Down

0 comments on commit 4d3e7e9

Please sign in to comment.