-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sanity test for the mentioned rock.
- Loading branch information
1 parent
bf9a6f3
commit 873fb8a
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright 2024 Canonical, Ltd. | ||
# | ||
|
||
import pytest | ||
from k8s_test_harness.util import docker_util, env_util | ||
|
||
ROCK_EXPECTED_FILES = [ | ||
"/usr/local/sbin/launch-manager", | ||
"/usr/local/sbin/longhorn-manager", | ||
"/usr/local/sbin/nsmounter", | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("image_version", ["v1.7.0"]) | ||
def test_longhorn_manager_rock(image_version): | ||
"""Test longhorn-manager rock.""" | ||
rock = env_util.get_build_meta_info_for_rock_version( | ||
"longhorn-manager", image_version, "amd64" | ||
) | ||
image = rock.image | ||
|
||
# check rock filesystem. | ||
docker_util.ensure_image_contains_paths(image, ROCK_EXPECTED_FILES) | ||
|
||
# check binary. | ||
process = docker_util.run_in_docker(image, ["longhorn-manager", "--version"]) | ||
assert f"longhorn-manager version {image_version}" in process.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
# Rockcraft definition for Longhorn manager image: | ||
# longhornio/longhorn-manager:v1.7.0 | ||
|
||
name: longhorn-manager | ||
summary: Rock containing Longhorn manager component. | ||
description: | | ||
Rock containing Longhorn manager component: https://github.com/longhorn/longhorn-manager | ||
Aims to replicate the upstream official image: longhornio/longhorn-manager:v1.7.0 | ||
license: Apache-2.0 | ||
|
||
version: "v1.7.0" | ||
|
||
# NOTE(aznashwan): the base for the manager 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/longhorn-manager/blob/v1.7.0/package/Dockerfile#L44 | ||
base: ubuntu@24.04 | ||
build-base: ubuntu@24.04 | ||
platforms: | ||
amd64: | ||
arm64: | ||
|
||
services: | ||
longhorn-manager: | ||
summary: "longhorn-manager service" | ||
startup: enabled | ||
override: replace | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L24 | ||
command: "launch-manager" | ||
on-success: shutdown | ||
on-failure: shutdown | ||
|
||
parts: | ||
# NOTE(aznashwan): the longhorn 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/longhorn-manager/blob/v1.7.0/Dockerfile.dapper | ||
# The Makefile targets are just the scripts found in the scripts/ directory which | ||
# are executed within the Dapper build container: | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Makefile#L10-L11 | ||
build-longhorn-manager: | ||
plugin: nil | ||
source-type: git | ||
source: https://github.com/longhorn/longhorn-manager | ||
source-tag: v1.7.0 | ||
source-depth: 1 | ||
build-packages: | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Dockerfile.dapper#L21 | ||
- gcc | ||
- ca-certificates | ||
# - libdevmapper1_03 | ||
- libltdl7 | ||
build-snaps: | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/Dockerfile.dapper#L1 | ||
- go/1.22/stable | ||
build-environment: | ||
- GOOS: linux | ||
- GOARCH: $CRAFT_ARCH_BUILD_FOR | ||
- CGO_ENABLED: 0 | ||
- VERSION: $CRAFT_PROJECT_VERSION | ||
override-build: | | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L15 | ||
mkdir -p $CRAFT_PART_INSTALL/usr/local/sbin/ | ||
cp package/launch-manager package/nsmounter $CRAFT_PART_INSTALL/usr/local/sbin/ | ||
LINKFLAGS="-X github.com/longhorn/longhorn-manager/meta.Version=$VERSION -extldflags -static -s" | ||
go build -o $CRAFT_PART_INSTALL/usr/local/sbin/ -ldflags "$LINKFLAGS" | ||
add-packages: | ||
plugin: nil | ||
# https://github.com/longhorn/longhorn-manager/blob/v1.7.0/package/Dockerfile#L20 | ||
stage-packages: | ||
- iproute2 | ||
- nfs-common # nfs-client | ||
- cifs-utils | ||
- bind9-utils # bind-utils | ||
- e2fsprogs | ||
- xfsprogs | ||
- zip | ||
- unzip | ||
- kmod | ||
stage-snaps: | ||
- iputils |