Skip to content

Commit

Permalink
Feat/private endpoint (#284)
Browse files Browse the repository at this point in the history
Add support for private endpoint.

* Integration test for openstack integration
  • Loading branch information
yanksyoon authored Jun 26, 2024
1 parent f10e621 commit cb9c34b
Show file tree
Hide file tree
Showing 29 changed files with 762 additions and 993 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/e2e_test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: End-to-End Test

on:
# TODO: Re-enable
# pull_request:
workflow_dispatch:
pull_request:

jobs:
build-charm:
Expand Down Expand Up @@ -454,6 +452,7 @@ jobs:
uses: ./.github/workflows/e2e_test_run.yaml
with:
runner-tag: "pr-${{ needs.run-id.outputs.run-id }}${{ github.run_attempt}}"
runner-virt-type: "lxd"

required_status_checks:
name: Required E2E Test Status Checks
Expand Down
462 changes: 0 additions & 462 deletions .github/workflows/e2e_test_openstack.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/e2e_test_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,25 @@ on:
description: The e2e test runner tag to run the workflow on.
type: string
required: true
runner-virt-type:
description: The e2e test runner virtualization type. E.g. lxd, or openstack.
# workflow_call does not support choice type.
type: string
required: true
workflow_dispatch:
inputs:
runner-tag:
description: The e2e test runner tag to run the workflow on.
type: string
required: true
runner-virt-type:
description: The e2e test runner virtualization type.
type: choice
required: true
options:
- lxd
- openstack

jobs:
e2e-test:
name: End-to-End Test Run
Expand Down Expand Up @@ -89,8 +102,10 @@ jobs:
- name: test check-jsonschema
run: check-jsonschema --version
- name: Test Firewall
if: "${{ github.event.inputs.runner-virt-type == 'lxd' }}"
run: |
HOST_IP=$(ip route | grep default | cut -f 3 -d" ")
[ $((ping $HOST_IP -c 5 || :) | grep "Destination Port Unreachable" | wc -l) -eq 5 ]
- name: Test sctp support
if: "${{ github.event.inputs.runner-virt-type == 'lxd' }}"
run: sudo apt-get install lksctp-tools -yq && checksctp
19 changes: 15 additions & 4 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: integration-tests

on:
# TODO: Re-enable
# pull_request:
workflow_dispatch:
pull_request:

jobs:
# test option values defined at test/conftest.py are passed on via repository secret
Expand All @@ -27,4 +25,17 @@ jobs:
pre-run-script: scripts/pre-integration-test.sh
provider: lxd
test-tox-env: integration-juju3.1
modules: '["test_charm_base_image", "test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics_success", "test_charm_metrics_failure", "test_self_hosted_runner", "test_charm_with_proxy", "test_charm_with_juju_storage", "test_debug_ssh", "test_charm_upgrade"]'
modules: '["test_charm_base_image", "test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics_success", "test_charm_metrics_failure", "test_self_hosted_runner", "test_charm_with_proxy", "test_charm_with_juju_storage", "test_debug_ssh", "test_charm_upgrade"]'
openstack-integration-tests-private-endpoint:
name: Integration test using private-endpoint
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
secrets: inherit
with:
juju-channel: 3.2/stable
pre-run-script: scripts/setup-lxd.sh
provider: lxd
test-tox-env: integration-juju3.2
modules: '["test_charm_metrics_failure", "test_charm_metrics_success", "test_charm_fork_repo", "test_charm_runner", "test_e2e"]'
extra-arguments: "-m openstack --openstack-flavor-name=builder-cpu4-ram8-disk50 --http-proxy=http://squid.internal:3128 --https-proxy=http://squid.internal:3128 --no-proxy=keystone.ps6.canonical.com,glance.ps6.canonical.com,nova.ps6.canonical.com,neutron.ps6.canonical.com"
self-hosted-runner: true
self-hosted-runner-label: stg-private-endpoint
24 changes: 0 additions & 24 deletions .github/workflows/manual_test_env.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Tests

on:
# TODO: Re-enable
# pull_request:
workflow_dispatch:
pull_request:

jobs:
unit-tests:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ omit = [
"src/repo_policy_compliance_client.py",
# 2024/04/17: These files are pending a major refactor. The refactor includes a RunnerManager
# interface class which will include a complete re-organization of the code in these files.
"src/openstack_cloud/openstack_manager.py",
"src/runner.py",
"src/runner_manager.py",
]
Expand Down
8 changes: 8 additions & 0 deletions scripts/setup-lxd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

# Script to setup LXD for testing

juju bootstrap localhost lxd
36 changes: 18 additions & 18 deletions src-docs/charm_state.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ State of the Charm.

---

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

## <kbd>function</kbd> `parse_github_path`

Expand Down Expand Up @@ -137,7 +137,7 @@ Some charm configurations are grouped into other configuration models.

---

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

### <kbd>classmethod</kbd> `check_reconcile_interval`

Expand Down Expand Up @@ -166,7 +166,7 @@ Validate the general charm configuration.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -205,7 +205,7 @@ Raised when charm config is invalid.

- <b>`msg`</b>: Explanation of the error.

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

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -247,7 +247,7 @@ The charm state.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -292,7 +292,7 @@ Charm configuration related to GitHub.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -337,7 +337,7 @@ Represent GitHub organization.

---

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

### <kbd>function</kbd> `path`

Expand Down Expand Up @@ -370,7 +370,7 @@ Represent GitHub repository.

---

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

### <kbd>function</kbd> `path`

Expand All @@ -391,7 +391,7 @@ Return a string representing the path.
## <kbd>class</kbd> `ImmutableConfigChangedError`
Represents an error when changing immutable charm state.

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

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -446,7 +446,7 @@ Runner configurations for local LXD instances.

---

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

### <kbd>classmethod</kbd> `check_virtual_machine_resources`

Expand Down Expand Up @@ -477,7 +477,7 @@ Validate the virtual_machine_resources field values.

---

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

### <kbd>classmethod</kbd> `check_virtual_machines`

Expand Down Expand Up @@ -506,7 +506,7 @@ Validate the virtual machines configuration value.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -553,7 +553,7 @@ Runner configuration for OpenStack Instances.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -607,7 +607,7 @@ Return the aproxy address.

---

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

### <kbd>classmethod</kbd> `check_use_aproxy`

Expand Down Expand Up @@ -637,7 +637,7 @@ Validate the proxy configuration.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -676,7 +676,7 @@ Configuration for the repo policy compliance service.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -739,7 +739,7 @@ SSH connection information for debug workflow.

---

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

### <kbd>classmethod</kbd> `from_charm`

Expand Down Expand Up @@ -772,7 +772,7 @@ Raised when given machine charm architecture is unsupported.

- <b>`arch`</b>: The current machine architecture.

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

### <kbd>function</kbd> `__init__`

Expand Down
4 changes: 4 additions & 0 deletions src/charm_state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

# 2024/06/26 The charm contains a lot of states and configuration. The upcoming refactor will
# split each/related class to a file.
# pylint: disable=too-many-lines

"""State of the Charm."""

import dataclasses
Expand Down
2 changes: 1 addition & 1 deletion src/openstack_cloud/openstack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def _get_ssh_connection(
An SSH connection to OpenStack server instance.
"""
server: Server | None = conn.get_server(name_or_id=server_name)
if not server:
if server is None:
raise _SSHError(f"Server gone while trying to get SSH connection: {server_name}.")
if not server.key_name:
raise _SSHError(
Expand Down
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,53 @@ def pytest_addoption(parser: Parser):
"--openstack-network-name",
action="store",
help="The Openstack network to create testing instances under.",
default=None,
)
parser.addoption(
"--openstack-flavor-name",
action="store",
help="The Openstack flavor to create testing instances with.",
default=None,
)
parser.addoption(
"--openstack-auth-url",
action="store",
help="The URL to Openstack authentication service, i.e. keystone.",
default=None,
)
parser.addoption(
"--openstack-password",
action="store",
help="The password to authenticate to Openstack service.",
default=None,
)
parser.addoption(
"--openstack-project-domain-name",
action="store",
help="The Openstack project domain name to use.",
default=None,
)
parser.addoption(
"--openstack-project-name",
action="store",
help="The Openstack project name to use.",
default=None,
)
parser.addoption(
"--openstack-user-domain-name",
action="store",
help="The Openstack user domain name to use.",
default=None,
)
parser.addoption(
"--openstack-username",
action="store",
help="The Openstack user to authenticate as.",
default=None,
)
parser.addoption(
"--openstack-region-name",
action="store",
help="The Openstack region to authenticate to.",
default=None,
)
Loading

0 comments on commit cb9c34b

Please sign in to comment.