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

Stable/quincy ci fixes #65

Open
wants to merge 8 commits into
base: stable/quincy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Test with KVM Lxd
Signed-off-by: Utkarsh Bhatt <[email protected]>
(cherry picked from commit c0f7b65)
  • Loading branch information
UtkarshBhatthere authored and xtrusia committed Sep 11, 2024
commit 11fadc472007182c798de07dc002578d8c4f2e36
73 changes: 13 additions & 60 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,65 +32,23 @@ jobs:
name: rock
path: ${{ steps.rockcraft.outputs.rock }}

CephAdmScriptTest:
flake8-lint:
runs-on: ubuntu-latest
needs: build-rock
strategy:
matrix:
python-version: ["3.10"]

name: Lint
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: clean unrequired files.
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: rock

- name: set up python ${{ matrix.python-version }}
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
sudo apt install skopeo
sudo python -m pip install --upgrade pip
sudo pip install flake8 pep8-naming pylxd pyyaml argparse

- name: Lint Check
run: |
flake8 . --count --show-source --statistics
python-version: "3.10"
- name: flake8 Lint
uses: py-actions/flake8@v2

- name: use local block device
run: ./test/scripts/cephadm_helper.sh use_local_disk

- name: Load image to registry
run: |
ls
rock_file=$(ls *.rock | head -1)
docker run -d -p 5000:5000 --restart=always --name registry registry:2
skopeo --insecure-policy copy oci-archive:$rock_file docker-daemon:canonical/ceph:latest
docker image ls -a
docker image tag canonical/ceph:latest localhost:5000/canonical/ceph:latest
sleep 10
docker push localhost:5000/canonical/ceph
echo $'[registries.insecure]\nregistries = ["localhost:5000"]' | sudo tee -a /etc/containers/registries.conf

- name: Deploy Cephadm over Host
run: |
sudo python test/deploy.py --osd-num 1 --direct-host 1 image "localhost:5000/canonical/ceph:latest"

CephAdmScriptLxdTest:
CephadmTest:
runs-on: ubuntu-latest
needs: build-rock
needs: [build-rock, flake8-lint]
strategy:
matrix:
python-version: ["3.10"]
Expand All @@ -116,19 +74,14 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
sudo python -m pip install --upgrade pip
sudo pip install flake8 pep8-naming pylxd pyyaml argparse

- name: Lint Check
run: |
flake8 . --count --show-source --statistics
run: ./scripts/deploy-helper.sh install_custom_runner_dependencies

- name: Load image to registry
run: |
ls
rock_file=$(ls *.rock | head -1)
docker run -d -p 5000:5000 --restart=always --name registry registry:2
sleep 10
skopeo --insecure-policy copy oci-archive:$rock_file docker-daemon:canonical/ceph:latest
docker image ls -a
docker image tag canonical/ceph:latest localhost:5000/canonical/ceph:latest
Expand All @@ -150,7 +103,7 @@ jobs:
- name: Deploy Cephadm over LXD Container
run: |
reg_addr=$(./test/scripts/cephadm_helper.sh get_ip)
sudo python test/deploy.py --osd-num 0 --container 1 image "$reg_addr:5000/canonical/ceph:latest"
sudo python test/deploy.py --osd-num 3 --container 1 image "$reg_addr:5000/canonical/ceph:latest"

RookTest:
needs: build-rock
Expand Down
9 changes: 9 additions & 0 deletions scripts/deploy-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@

set -xeEo pipefail

function install_custom_runner_dependencies() {
sudo apt-get -y update
sudo apt-get -y install skopeo
sudo python -m pip install --upgrade pip
sudo pip install flake8 pep8-naming pylxd pyyaml argparse
sudo snap install docker
sleep 10
}


function deploy_operator_with_custom_image() {
local yaml=${1:?missing}
Expand Down
14 changes: 8 additions & 6 deletions test/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import os
import pwd
import json
import yaml
import time
import pylxd
import string
import random
import argparse
import subprocess
import pylxd
import yaml

# Helper Translation Tables
ceph_version_to_cloud_archive = {
Expand Down Expand Up @@ -39,7 +39,7 @@ class Cleaner:
def __init__(self, model_file_path: string) -> None:
if os.path.exists(model_file_path):
# init client
self.client = pylxd.Client()
self.client = pylxd.Client(project='default')
self.clean(model_file_path)
else:
print(f"Model File {model_file_path} does not exists.")
Expand Down Expand Up @@ -91,6 +91,7 @@ def clean(self, model_file_path: string) -> None:


class DeployRunner:
"""Deploys LXD based Cephadm"""
# LXD Vars
model_id = _get_random_string(4)
deploy_tag = "ubuntu-ceph-" + model_id
Expand Down Expand Up @@ -226,7 +227,7 @@ def create_instance_profile(

def create_instance(
self,
image="ubuntu/jammy",
image_name="jammy",
flavor="c4-m10",
pool_name=deploy_tag,
profile_name=deploy_tag,
Expand Down Expand Up @@ -254,8 +255,8 @@ def create_instance(
"source": {
"type": "image",
"certificate": "",
"alias": image,
"server": "https://images.linuxcontainers.org",
"alias": image_name,
"server": "https://cloud-images.ubuntu.com/releases",
"protocol": "simplestreams",
"mode": "pull",
"allow_inconsistent": False,
Expand Down Expand Up @@ -362,6 +363,7 @@ def check_output_on_target_cephadm_shell(
)

def wait_for_instance_ready(self, instance_name, max_attempt=20) -> None:
"""Wait for the LXD instance to be ready."""
is_container_ready = False
counter = 0
while not is_container_ready:
Expand Down