Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests for COS integration for OpenStack #277

Merged
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
18d9294
Add config for repo-policy-compliance-{token,url}
cbartz Apr 25, 2024
d8b928b
rename pre-job contents variables
cbartz Apr 25, 2024
c0df2e8
add config validation
cbartz Apr 26, 2024
237dba8
remove redundant catch
cbartz Apr 26, 2024
7047198
use repo policy check in openstack
cbartz Apr 26, 2024
5636795
Merge branch 'refs/heads/feat/openstack-integration' into feat/openst…
cbartz Apr 29, 2024
6413b69
generate src-docs
cbartz Apr 29, 2024
27c1ebf
fix after merge and lint
cbartz Apr 29, 2024
50e95d5
fix lint
cbartz May 2, 2024
de68eaa
fix unit tests
cbartz May 2, 2024
bfcf111
add unit test
cbartz May 2, 2024
d3e7af8
fix comment in repo policy compliance client
cbartz May 2, 2024
02c271b
temporary enable integration test
cbartz May 2, 2024
9e7a1a8
Add note to config that only the OpenStack cloud is supported
cbartz May 2, 2024
402ae10
temporary enable integration test
cbartz May 2, 2024
854db92
Revert "temporary enable integration test"
cbartz May 2, 2024
dea2c5c
Revert "temporary enable integration test"
cbartz May 2, 2024
adc845b
go in blocked state when using repo-policy without os
cbartz May 3, 2024
4becec3
define and use AnyHttpsUrl for dockerhub-mirror
cbartz May 3, 2024
1e311b5
WIP checkin
cbartz May 3, 2024
6116154
remove x64 from workflow files
cbartz May 4, 2024
34c1ba9
add labels config
cbartz May 4, 2024
4c8684e
Merge branch 'refs/heads/feat/openstack-integration' into feat/integr…
cbartz May 6, 2024
6281c3c
write_post_metrics also on error
cbartz May 6, 2024
f8b7e12
chmod and owner of ssh key
cbartz May 6, 2024
24379e6
fix write_post_metrics also on error
cbartz May 6, 2024
19a8547
Checkin adaptions to let integration test run
cbartz May 6, 2024
c7e2585
Use marker
cbartz May 6, 2024
7a42ea7
fix write_post_metrics also on error
cbartz May 6, 2024
99f8126
enable integration tests
cbartz May 6, 2024
77d6132
add OpenStackInstanceHelper
cbartz May 6, 2024
1690d88
reuse ops_test.model
cbartz May 6, 2024
3fe6895
enable integration tests
cbartz May 6, 2024
9c08ba6
deploy latest grafana agent
cbartz May 6, 2024
9952f88
request openstack_connection dynamically
cbartz May 6, 2024
5bcdecb
fix test_charm_issues_runner_installed_metric
cbartz May 6, 2024
bedabe6
revert outcommenting of proxy settings
cbartz May 6, 2024
9357f93
add instance helper fixture
cbartz May 6, 2024
950200e
lint and refactor
cbartz May 7, 2024
aad16ea
lint
cbartz May 7, 2024
0a2c85c
outcomment integration test
cbartz May 7, 2024
0bee459
fix refactor
cbartz May 7, 2024
fa158fc
add sleep
cbartz May 7, 2024
2725966
revert comment
cbartz May 7, 2024
336b18b
add explanatory comment
cbartz May 8, 2024
4be2932
fix trailing ws
cbartz May 8, 2024
a0795c6
Add more context to metrics pull errors
cbartz May 8, 2024
b0776c4
add explanatory comment
cbartz May 8, 2024
bd4f83e
add more explanations to --use-existing-app config
cbartz May 8, 2024
e95d1da
use > instead of >> in start_test_http_server
cbartz May 8, 2024
9e9b206
use wait_for in start_test_http_server
cbartz May 8, 2024
bf60114
set job_duration to zero in edge cases
cbartz May 8, 2024
cda2037
lint
cbartz May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test_run.yaml
yanksyoon marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
e2e-test:
name: End-to-End Test Run
runs-on: [self-hosted, linux, x64, "${{ inputs.runner-tag }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner-tag }}"]
cbartz marked this conversation as resolved.
Show resolved Hide resolved
steps:
# Snapd can have some issues in privileged LXD containers without setting
# security.nesting=True and this.
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: integration-tests

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

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
push-event-tests:
runs-on: [self-hosted, linux, x64, "${{ github.ref_name }}"]
runs-on: [self-hosted, linux, "${{ github.ref_name }}"]
steps:
- name: Echo runner name
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule_issues_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

issues-schedule-event-tests:
needs: [ extract-runner-name ]
runs-on: [ self-hosted, linux, x64, "${{ needs.extract-runner-name.outputs.name }}" ]
runs-on: [ self-hosted, linux, "${{ needs.extract-runner-name.outputs.name }}" ]
steps:
- name: Echo runner name
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_dispatch_crash_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
workflow-dispatch-tests:
runs-on: [self-hosted, linux, x64, "${{ inputs.runner }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner }}"]
steps:
- name: Sleep for an hour to give the integration test some time to crash the runner.
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_dispatch_failure_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
workflow-dispatch-tests:
runs-on: [self-hosted, linux, x64, "${{ inputs.runner }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner }}"]
steps:
- name: Echo input variable and message
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_dispatch_ssh_debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
workflow-dispatch-tests:
runs-on: [self-hosted, linux, x64, "${{ inputs.runner }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner }}"]
steps:
- name: Setup tmate session
uses: canonical/action-tmate@chore/env_var_change
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_dispatch_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
workflow-dispatch-tests:
runs-on: [self-hosted, linux, x64, "${{ inputs.runner }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner }}"]
steps:
- name: Echo input variable and message
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow_dispatch_wait_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
workflow-dispatch-tests:
runs-on: [self-hosted, linux, x64, "${{ inputs.runner }}"]
runs-on: [self-hosted, linux, "${{ inputs.runner }}"]
steps:
- name: Echo input variable and message
run: |
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ show_missing = true
[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"
markers = [
"openstack: mark a test as applicable for openstack cloud",
]

[tool.pylint.'MESSAGES CONTROL']
extension-pkg-whitelist = "pydantic"
Expand Down
22 changes: 11 additions & 11 deletions src-docs/openstack_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Module for handling interactions with OpenStack.

---

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

## <kbd>function</kbd> `build_image`

Expand Down Expand Up @@ -56,7 +56,7 @@ Build and upload an image to OpenStack.

---

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

## <kbd>function</kbd> `create_instance_config`

Expand Down Expand Up @@ -92,7 +92,7 @@ Create an instance config from charm data.

---

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

## <kbd>class</kbd> `InstanceConfig`
The configuration values for creating a single runner instance.
Expand Down Expand Up @@ -131,7 +131,7 @@ __init__(

---

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

## <kbd>class</kbd> `ProxyStringValues`
Wrapper class to proxy values to string.
Expand All @@ -150,7 +150,7 @@ Wrapper class to proxy values to string.

---

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

## <kbd>class</kbd> `OpenstackUpdateImageError`
Represents an error while updating image on Openstack.
Expand All @@ -161,7 +161,7 @@ Represents an error while updating image on Openstack.

---

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

## <kbd>class</kbd> `GithubRunnerRemoveError`
Represents an error removing registered runner from Github.
Expand All @@ -172,7 +172,7 @@ Represents an error removing registered runner from Github.

---

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

## <kbd>class</kbd> `OpenstackRunnerManager`
Runner manager for OpenStack-based instances.
Expand All @@ -185,7 +185,7 @@ Runner manager for OpenStack-based instances.
- <b>`unit_num`</b>: The juju unit number.
- <b>`instance_name`</b>: Prefix of the name for the set of runners.

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

### <kbd>method</kbd> `__init__`

Expand Down Expand Up @@ -214,7 +214,7 @@ Construct OpenstackRunnerManager object.

---

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

### <kbd>method</kbd> `flush`

Expand All @@ -231,7 +231,7 @@ Flush Openstack servers.

---

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

### <kbd>method</kbd> `get_github_runner_info`

Expand All @@ -248,7 +248,7 @@ Get information on GitHub for the runners.

---

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

### <kbd>method</kbd> `reconcile`

Expand Down
3 changes: 3 additions & 0 deletions src/openstack_cloud/openstack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""Module for handling interactions with OpenStack."""
import logging
import secrets
import shutil
import time
from contextlib import contextmanager
from dataclasses import dataclass
Expand Down Expand Up @@ -638,6 +639,8 @@ def _setup_runner_keypair(conn: OpenstackConnection, name: str) -> None:

keypair = conn.create_keypair(name=name)
private_key_path.write_text(keypair.private_key)
shutil.chown(private_key_path, user="ubuntu", group="ubuntu")
private_key_path.chmod(0o400)

@staticmethod
def _ssh_health_check(server: Server) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions templates/openstack-userdata.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ write_post_metrics(){
}

# Run runner
su - ubuntu -c "cd ~/actions-runner && /home/ubuntu/actions-runner/run.sh"
write_post_metrics $?
(set +e; su - ubuntu -c "cd ~/actions-runner && /home/ubuntu/actions-runner/run.sh"; write_post_metrics $?)
cbartz marked this conversation as resolved.
Show resolved Hide resolved

su - ubuntu -c "touch /home/ubuntu/run-completed"
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ def pytest_addoption(parser: Parser):
action="store",
help="The OpenStack clouds yaml file for the charm to use.",
)
parser.addoption(
"--use-existing-app",
action="store",
help="The existing app to use. "
cbartz marked this conversation as resolved.
Show resolved Hide resolved
"This will skip deployment of the charm and use the existing app. "
"Useful for local testing.",
)
Loading
Loading