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

backing-image-manager: add rockcraft specs and tests. #18

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
41 changes: 41 additions & 0 deletions tests/sanity/test_longhorn_backing_image_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Copyright 2024 Canonical, Ltd.
#

import logging
import sys

import pytest
from k8s_test_harness.util import docker_util, env_util, platform_util

LOG: logging.Logger = logging.getLogger(__name__)

LOG.addHandler(logging.FileHandler(f"{__name__}.log"))
LOG.addHandler(logging.StreamHandler(sys.stdout))


IMAGE_NAME = "backing-image-manager"
IMAGE_VERSIONS = ["v1.7.0"]


@pytest.mark.abort_on_fail
@pytest.mark.parametrize("image_version", IMAGE_VERSIONS)
def test_check_rock_image_contents(image_version):
"""Test ROCK contains same fileset as original image."""

architecture = platform_util.get_current_rockcraft_platform_architecture()

rock_meta = env_util.get_build_meta_info_for_rock_version(
IMAGE_NAME, image_version, architecture
)
rock_image = rock_meta.image

binary_paths_to_check = [
"/tini",
"/usr/local/bin/backing-image-manager"
]

docker_util.ensure_image_contains_paths(
rock_image,
binary_paths_to_check,
)
144 changes: 144 additions & 0 deletions v1.7.0/backing-image-manager/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

# Rockcraft definition for the Longhorn Backing Image Manager image:
# longhornio/backing-image-manager:v1.7.0

name: backing-image-manager
summary: Rock containing the Longhorn Backing Image Manager component.
description: |
Rock containing Longhorn Backing Image manager component: https://github.com/longhorn/backing-image-manager
Aims to replicate the upstream official image: longhornio/backing-image-manager:v1.7.0
license: Apache-2.0

version: "v1.7.0"

# NOTE(aznashwan): the base for the image is the Suse Linux Enterprise
# Base Container Image (SLE BCE) Service Pack 6 which ships with Linux 6.4,
# and is thus most comparable to 24.04:
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/package/Dockerfile#L3
base: [email protected]

build-base: [email protected]
platforms:
amd64:


services:
backing-image-manager:
startup: enabled
override: replace

# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/package/Dockerfile#L31-L33
command: /tini -- [ backing-image-manager ]

on-success: shutdown
on-failure: shutdown

entrypoint-service: backing-image-manager

parts:

# NOTE(aznashwan): the binary is built within a Docker container
# which is set up by Rancher's Dapper tool: https://github.com/rancher/dapper
# The setup steps for the build container are contained within this Dockerfile:
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/Dockerfile.dapper
setup-build-env:
plugin: nil

build-packages:
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/Dockerfile.dapper#L20-L24
berkayoz marked this conversation as resolved.
Show resolved Hide resolved
- cmake
- wget
- curl
- git
- less
- file
- libkmod-dev # libkmod-devel
- libnl-3-dev # libnl3-devel
- linux-headers-6.8.0-41 # linux-glibc-devel
- pkg-config
- psmisc
- fuse
- librdmacm-dev # librdmacm1
- rdmacm-utils # librdmacm-utils
- libibverbs-dev # libibverbs
- libaio-dev # libaio-devel
- libc6-dev # glibc-devel, glibc-devel-static
- iptables
- libltdl7
- libdevmapper1.02.1 # libdevmapper1_03
- iproute2
- jq
- gcc

# NOTE(aznashwan): the Makefile targets are just the scripts found in the
# scripts/ directory which are executed within the Dapper build container:
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/Makefile#L1
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/Makefile#L10-L11
build-lonhorn-backing-image-manager:
plugin: nil
after: ["setup-build-env"]

source-type: git
source: https://github.com/longhorn/backing-image-manager
source-tag: v1.7.0
source-depth: 1

build-snaps:
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/Dockerfile.dapper#L1
- go/1.22/stable

override-build: |
set -eux -o pipefail

cd $CRAFT_PART_SRC

bash ./scripts/build

# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/package/Dockerfile#L23
mkdir -p $CRAFT_PART_INSTALL/usr/local/bin
cp $CRAFT_PART_SRC/bin/backing-image-manager-${CRAFT_ARCH_BUILD_FOR} $CRAFT_PART_INSTALL/usr/local/bin/backing-image-manager

# Pulls a pre-built binary release of the `tini` init system.
berkayoz marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/package/Dockerfile#L28-L30
fetch-tini-init:
plugin: nil
after: ["setup-build-env"]

override-build: |
set -eux -o pipefail

TINI_VERSION="v0.19.0"
ARCH="$CRAFT_TARGET_ARCH"

URL="https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${ARCH}"

curl -sSfL $URL -o $CRAFT_PART_INSTALL/tini
chmod +x $CRAFT_PART_INSTALL/tini

prep-final-image:
plugin: nil

# https://github.com/longhorn/backing-image-manager/blob/v1.7.0/package/Dockerfile#L19-L21
stage-packages:
- kmod
- curl
- wget
- nfs-common # nfs-client
- nfs4-acl-tools
- fuse
- librdmacm-dev # librdmacm1
- rdmacm-utils # librdmacm-utils
- libibverbs-dev # libibverbs
- libconfig-general-perl # perl-Config-General
- libaio-dev # libaio-devel
- sg3-utils # sg3_utils
- net-tools # iputils
- telnet
- iperf3 # iperf
- qemu-utils # qemu-tools
- iproute2
- e2fsprogs
- xfsprogs
- xfslibs-dev # xfsprogs-devel
Loading