Skip to content

Commit

Permalink
CI: Add a periodic multinode job
Browse files Browse the repository at this point in the history
  • Loading branch information
markgoddard committed Aug 22, 2024
1 parent 3b543c6 commit 29a1409
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/multinode-inputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Generate inputs for the reusable multinode.yml workflow.
# The test scenario is randomly selected.
# The inputs are printed to stdout in GitHub step output key=value format.

from dataclasses import dataclass
import random
import typing as t


@dataclass
class OSRelease:
distribution: str
release: str
ssh_username: str


@dataclass
class OpenStackRelease:
version: str
previous_version: str
os_releases: t.List[OSRelease]


@dataclass
class Scenario:
openstack_release: OpenStackRelease
os_release: OSRelease
neutron_plugin: str
upgrade: bool


ROCKY_9 = OSRelease("rocky", "9", "cloud-user")
UBUNTU_JAMMY = OSRelease("ubuntu", "jammy", "ubuntu")
OPENSTACK_RELEASES = [
OpenStackRelease("2023.1", "zed", [ROCKY_9, UBUNTU_JAMMY])
]
NEUTRON_PLUGINS = ["ovs", "ovn"]


def main() -> None:
scenario = choose_scenario()
inputs = generate_inputs(scenario)
for name, value in inputs.items():
write_output(name, value)


def choose_scenario() -> Scenario:
openstack_release = random.choice(OPENSTACK_RELEASES)
os_release = random.choice(openstack_release.os_releases)
neutron_plugin = random.choice(NEUTRON_PLUGINS)
upgrade = random.random() > 0.6
return Scenario(openstack_release, os_release, neutron_plugin, upgrade)


def generate_inputs(scenario: Scenario) -> t.Dict[str, str]:
branch = get_branch(scenario.openstack_release.version)
previous_branch = get_branch(scenario.openstack_release.previous_version)
inputs = {
"os_distribution": scenario.os_release.distribution,
"os_release": scenario.os_release.release,
"ssh_username": scenario.os_release.ssh_username,
"neutron_plugin": scenario.neutron_plugin,
"upgrade": str(scenario.upgrade).lower(),
"stackhpc_kayobe_config_version": branch,
"stackhpc_kayobe_config_previous_version": previous_branch,
}
return inputs


def get_branch(version: str) -> str:
return f"stackhpc/{version}"


def write_output(name: str, value: str) -> None:
print(f"{name}={value}")


if __name__ == "__main__":
main()
49 changes: 49 additions & 0 deletions .github/workflows/stackhpc-multinode-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# This workflow provides a scheduled deploy of a multi-node test cluster.

name: Multinode periodic
'on':
push:
schedule:
# Runs nightly at 2:42 AM.
- cron: "42 2 * * *"
jobs:
generate-inputs:
name: Generate inputs
runs-on: ubuntu-latest
outputs:
os_distribution: ${{ steps.generate-inputs.outputs.os_distribution }}
os_release: ${{ steps.generate-inputs.outputs.os_release }}
ssh_username: ${{ steps.generate-inputs.outputs.ssh_username }}
neutron_plugin: ${{ steps.generate-inputs.outputs.neutron_plugin }}
upgrade: ${{ steps.generate-inputs.outputs.upgrade }}
stackhpc_kayobe_config_version: ${{ steps.generate-inputs.outputs.stackhpc_kayobe_config_version }}
stackhpc_kayobe_config_previous_version: ${{ steps.generate-inputs.outputs.stackhpc_kayobe_config_previous_version }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate inputs
id: generate-inputs
run: |
python3 .github/workflows/multinode-inputs.py >> $GITHUB_OUTPUT
multinode:
name: Multinode periodic
needs:
- generate-inputs
# FIXME: slack
uses: stackhpc/stackhpc-openstack-gh-workflows/.github/workflows/multinode.yml@slack
with:
multinode_name: mn-prdc-${{ github.run_id }}
os_distribution: ${{ needs.generate-inputs.outputs.os_distribution }}
os_release: ${{ needs.generate-inputs.outputs.os_release }}
ssh_username: ${{ needs.generate-inputs.outputs.ssh_username }}
neutron_plugin: ${{ needs.generate-inputs.outputs.neutron_plugin }}
upgrade: ${{ needs.generate-inputs.outputs.upgrade == 'true' }}
stackhpc_kayobe_config_version: ${{ needs.generate-inputs.outputs.stackhpc_kayobe_config_version }}
stackhpc_kayobe_config_previous_version: ${{ needs.generate-inputs.outputs.stackhpc_kayobe_config_previous_version }}
enable_slack_alert: true
# FIXME: Remove
break_on: failure
secrets: inherit

0 comments on commit 29a1409

Please sign in to comment.