Skip to content

Commit

Permalink
Update viewer-crd-controller to 2.2.0 (#91)
Browse files Browse the repository at this point in the history
* Update viewer-crd-controller to 2.2.0
  • Loading branch information
misohu authored May 30, 2024
1 parent 517f00c commit aaa1d41
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 14 deletions.
20 changes: 11 additions & 9 deletions viewer-crd-controller/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
# Dockerfile: https://github.com/kubeflow/pipelines/blob/2.0.5/backend/Dockerfile.viewercontroller
# Based on: https://github.com/kubeflow/pipelines/blob/2.2.0/backend/Dockerfile.viewercontroller
name: viewer-crd-controller
summary: An image for the Viewer CRD Controller
description: |
This image is used as part of the Charmed Kubeflow product.
version: 2.0.5
version: "2.2.0"
license: Apache-2.0
base: ubuntu@22.04
build-base: ubuntu@22.04
platforms:
amd64:
run-user: _daemon_
services:
controller:
override: replace
summary: "viewer CRD controller"
startup: enabled
command: controller
platforms:
amd64:
environment:
MAX_NUM_VIEWERS: "50"
NAMESPACE: "kubeflow"
command: bash -c '/bin/controller --logtostderr=true --max_num_viewers=${MAX_NUM_VIEWERS} --namespace=${NAMESPACE}'

parts:
viewer-crd-controller:
plugin: go
source: https://github.com/kubeflow/pipelines
build-snaps:
- go/1.20/stable
- go/1.21/stable
source-type: git
source-tag: 2.0.5
source-tag: 2.2.0
build-packages:
- git
- gcc
- musl-dev
build-environment:
- CGO_ENABLED: 0
- GOOS: linux
- GO111MODULE: "on"
override-build: |
mkdir -p $CRAFT_PART_INSTALL/bin
mkdir -p $CRAFT_PART_INSTALL/third_party
go build -o $CRAFT_PART_INSTALL/bin/controller backend/src/crd/controller/viewer/*.go
./hack/install-go-licenses.sh
$GOBIN/go-licenses check ./backend/src/crd/controller/viewer
$GOBIN/go-licenses csv ./backend/src/crd/controller/viewer > $CRAFT_PART_INSTALL/third_party/licenses.csv
Expand Down
56 changes: 56 additions & 0 deletions viewer-crd-controller/tests/test_rock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
import random
import pytest
import string
import subprocess

from charmed_kubeflow_chisme.rock import CheckRock


@pytest.fixture()
def rock_test_env(tmpdir):
"""Yields a temporary directory and random docker container name, then cleans them up after."""
container_name = "".join(
[str(i) for i in random.choices(string.ascii_lowercase, k=8)]
)
yield tmpdir, container_name

subprocess.run(["docker", "rm", container_name], shell=True, check=False)
# tmpdir fixture we use here should clean up the other files for us


@pytest.mark.abort_on_fail
def test_rock(rock_test_env):
"""Test rock."""
temp_dir, container_name = rock_test_env
check_rock = CheckRock("rockcraft.yaml")
rock_image = check_rock.get_name()
rock_version = check_rock.get_version()
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}"

# assert we have the expected files
subprocess.run(
[
"docker",
"run",
"--entrypoint",
"/bin/bash",
LOCAL_ROCK_IMAGE,
"-c",
"ls -la /bin/controller",
],
check=True,
)
subprocess.run(
[
"docker",
"run",
"--entrypoint",
"/bin/bash",
LOCAL_ROCK_IMAGE,
"-c",
"ls -la /third_party",
],
check=True,
)
11 changes: 6 additions & 5 deletions viewer-crd-controller/tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 Canonical Ltd.
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
[tox]
skipsdist = True
Expand Down Expand Up @@ -38,11 +38,12 @@ commands =

[testenv:sanity]
passenv = *
allowlist_externals =
echo
deps =
pytest
charmed-kubeflow-chisme
commands =
# TODO: Implement sanity tests
echo "WARNING: This is a placeholder test - no test is implemented here."
# run rock tests
pytest -s -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests

[testenv:integration]
passenv = *
Expand Down

0 comments on commit aaa1d41

Please sign in to comment.