-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac6a9e5
commit cfbbb4d
Showing
8 changed files
with
707 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- markdownlint-disable --> | ||
|
||
<a href="../src/ingress.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
# <kbd>module</kbd> `ingress.py` | ||
Observer module for Jenkins to ingress integration. | ||
|
||
|
||
|
||
--- | ||
|
||
## <kbd>class</kbd> `Observer` | ||
The Jenkins Ingress integration observer. | ||
|
||
<a href="../src/ingress.py#L15"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a> | ||
|
||
### <kbd>function</kbd> `__init__` | ||
|
||
```python | ||
__init__(charm: CharmBase) | ||
``` | ||
|
||
Initialize the observer and register event handlers. | ||
|
||
|
||
|
||
**Args:** | ||
|
||
- <b>`charm`</b>: The parent charm to attach the observer to. | ||
|
||
|
||
--- | ||
|
||
#### <kbd>property</kbd> model | ||
|
||
Shortcut for more simple access the model. | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
"""Observer module for Jenkins to ingress integration.""" | ||
|
||
import ops | ||
from charms.traefik_k8s.v1.ingress import IngressPerAppRequirer | ||
|
||
import jenkins | ||
|
||
|
||
class Observer(ops.Object): | ||
"""The Jenkins Ingress integration observer.""" | ||
|
||
def __init__(self, charm: ops.CharmBase): | ||
"""Initialize the observer and register event handlers. | ||
Args: | ||
charm: The parent charm to attach the observer to. | ||
""" | ||
super().__init__(charm, "ingress-observer") | ||
self.charm = charm | ||
|
||
self.ingress = IngressPerAppRequirer(self.charm, port=jenkins.WEB_PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
"""Integration tests for jenkins-k8s-operator with ingress.""" | ||
|
||
import pytest | ||
import requests | ||
from juju.application import Application | ||
from juju.model import Model | ||
|
||
|
||
@pytest.mark.abort_on_fail | ||
async def test_ingress_integration( | ||
model: Model, ingress_related: Application, external_hostname: str | ||
): | ||
""" | ||
arrange: deploy the Jenkins charm and establish relations via ingress. | ||
act: send a request to the ingress in /. | ||
assert: the response succeeds. | ||
""" | ||
status = await model.get_status(filters=[ingress_related.name]) | ||
unit = next(iter(status.applications[ingress_related.name].units)) | ||
response = requests.get( | ||
f"http://{unit.address}", | ||
headers={"Host": f"{model.name}-{ingress_related.name}.{external_hostname}"}, | ||
timeout=5, | ||
).json() | ||
assert response.status_code == 200 |