-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move package tests from contrib repo
Signed-off-by: Moritz Wiesinger <[email protected]> add shellcheck option to follow other files Signed-off-by: Moritz Wiesinger <[email protected]> use shellcheck directive Signed-off-by: Moritz Wiesinger <[email protected]> make shellcheck happy Signed-off-by: Moritz Wiesinger <[email protected]> fix shellcheck things Signed-off-by: Moritz Wiesinger <[email protected]> move dockerfiles, remove unneeded files Signed-off-by: Moritz Wiesinger <[email protected]> also test rpm package Signed-off-by: Moritz Wiesinger <[email protected]> add missing variable Signed-off-by: Moritz Wiesinger <[email protected]> only build linux amd64 for now Signed-off-by: Moritz Wiesinger <[email protected]> only build linux amd64 for now Signed-off-by: Moritz Wiesinger <[email protected]> fix service unit name Signed-off-by: Moritz Wiesinger <[email protected]> add missing files Signed-off-by: Moritz Wiesinger <[email protected]> remove unneeded variables and files Signed-off-by: Moritz Wiesinger <[email protected]> add checkout step Signed-off-by: Moritz Wiesinger <[email protected]> fix if conditionals Signed-off-by: Moritz Wiesinger <[email protected]> add demo config, add script run Signed-off-by: Moritz Wiesinger <[email protected]> copy over package test scripts Signed-off-by: Moritz Wiesinger <[email protected]> add job dependency Signed-off-by: Moritz Wiesinger <[email protected]> move package test steps for testing Signed-off-by: Moritz Wiesinger <[email protected]> revert goreleaser change Signed-off-by: Moritz Wiesinger <[email protected]> fix if statement Signed-off-by: Moritz Wiesinger <[email protected]> test commit Signed-off-by: Moritz Wiesinger <[email protected]> run package tests as part of core ci workflow Signed-off-by: Moritz Wiesinger <[email protected]> download artifacts in new workflow Signed-off-by: Moritz Wiesinger <[email protected]> defuse package tests for now Signed-off-by: Moritz Wiesinger <[email protected]> upload linux/amd64 service packages after building a snapshot Signed-off-by: Moritz Wiesinger <[email protected]> update goreleaser-pro to latest version, add version field to config files to remove warning Signed-off-by: Moritz Wiesinger <[email protected]> add package test workflow Signed-off-by: Moritz Wiesinger <[email protected]>
- Loading branch information
Showing
16 changed files
with
227 additions
and
12 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
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
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
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,11 @@ | ||
name: Package Tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "test" |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
version: 2 | ||
release: | ||
header: | | ||
Check the [v{{.Version}} contrib changelog](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tags/v{{.Version}}) and the [v{{.Version}} core changelog](https://github.com/open-telemetry/opentelemetry-collector/releases/tags/v{{.Version}}) for changelogs on specific components. |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
partial: | ||
by: target | ||
version: 2 | ||
project_name: opentelemetry-collector-releases | ||
env: | ||
- COSIGN_YES=true | ||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
partial: | ||
by: target | ||
version: 2 | ||
project_name: opentelemetry-collector-releases | ||
env: | ||
- COSIGN_YES=true | ||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
partial: | ||
by: target | ||
version: 2 | ||
project_name: opentelemetry-collector-releases | ||
env: | ||
- COSIGN_YES=true | ||
|
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
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
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,14 @@ | ||
# A debian11 image with systemd enabled. Must be run with: | ||
# `-d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro` flags | ||
FROM debian:12 | ||
|
||
ENV container docker | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Enable systemd. | ||
RUN apt-get update ; \ | ||
apt-get install -y systemd systemd-sysv procps; \ | ||
apt-get clean ; \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
CMD ["/lib/systemd/systemd"] |
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,9 @@ | ||
# A rockylinux8.5 image with systemd enabled. Must be run with: | ||
# `-d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro` flags | ||
FROM rockylinux:9.3 | ||
|
||
ENV container docker | ||
|
||
RUN dnf install -y initscripts | ||
|
||
CMD ["/usr/sbin/init"] |
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,48 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
export SERVICE_NAME="otelcol" | ||
export PROCESS_NAME="otelcol" | ||
export PKG_NAME="otelcol" | ||
|
||
podman_cp() { | ||
local container="$1" | ||
local src="$2" | ||
local dest="$3" | ||
local dest_dir | ||
dest_dir="$( dirname "$dest" )" | ||
|
||
echo "Copying $src to $container:$dest ..." | ||
podman exec "$container" mkdir -p "$dest_dir" | ||
podman cp "$src" "$container":"$dest" | ||
} | ||
|
||
install_pkg() { | ||
local container="$1" | ||
local pkg_path="$2" | ||
local pkg_base | ||
pkg_base=$( basename "$pkg_path" ) | ||
|
||
echo "Installing $pkg_base ..." | ||
podman_cp "$container" "$pkg_path" /tmp/"$pkg_base" | ||
if [[ "${pkg_base##*.}" = "deb" ]]; then | ||
podman exec "$container" dpkg -i /tmp/"$pkg_base" | ||
else | ||
podman exec "$container" rpm -ivh /tmp/"$pkg_base" | ||
fi | ||
} | ||
|
||
uninstall_pkg() { | ||
local container="$1" | ||
local pkg_type="$2" | ||
local pkg_name="${3:-"$PKG_NAME"}" | ||
|
||
echo "Uninstalling $pkg_name ..." | ||
if [[ "$pkg_type" = "deb" ]]; then | ||
podman exec "$container" dpkg -r "$pkg_name" | ||
else | ||
podman exec "$container" rpm -e "$pkg_name" | ||
fi | ||
} |
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,91 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euov pipefail | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
REPO_DIR="$( cd "$SCRIPT_DIR/../../../../" && pwd )" | ||
export REPO_DIR | ||
PKG_PATH="${1:-}" | ||
|
||
# shellcheck source=scripts/package-tests/common.sh | ||
source "$SCRIPT_DIR"/common.sh | ||
|
||
if [[ -z "$PKG_PATH" ]]; then | ||
echo "usage: ${BASH_SOURCE[0]} DEB_OR_RPM_PATH" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f "$PKG_PATH" ]]; then | ||
echo "$PKG_PATH not found!" >&2 | ||
exit 1 | ||
fi | ||
|
||
|
||
pkg_base="$( basename "$PKG_PATH" )" | ||
pkg_type="${pkg_base##*.}" | ||
if [[ ! "$pkg_type" =~ ^(deb|rpm)$ ]]; then | ||
echo "$PKG_PATH not supported!" >&2 | ||
exit 1 | ||
fi | ||
image_name="otelcontribcol-$pkg_type-test" | ||
container_name="$image_name" | ||
container_exec="podman exec $container_name" | ||
|
||
trap 'podman rm -fv $container_name >/dev/null 2>&1 || true' EXIT | ||
|
||
podman build -t "$image_name" -f "$SCRIPT_DIR/Dockerfile.test.$pkg_type" "$SCRIPT_DIR" | ||
podman rm -fv "$container_name" >/dev/null 2>&1 || true | ||
|
||
# test install | ||
CRUN_VER='1.14.4' | ||
mkdir -p "${HOME}/.local/bin" | ||
curl -L "https://github.com/containers/crun/releases/download/${CRUN_VER}/crun-${CRUN_VER}-linux-amd64" -o "${HOME}/.local/bin/crun" | ||
chmod +x "${HOME}/.local/bin/crun" | ||
mkdir -p "${HOME}/.config/containers" | ||
cat << EOF > "${HOME}/.config/containers/containers.conf" | ||
[engine.runtimes] | ||
crun = [ | ||
"${HOME}/.local/bin/crun", | ||
"/usr/bin/crun" | ||
] | ||
EOF | ||
|
||
echo | ||
podman run --name "$container_name" -d "$image_name" | ||
install_pkg "$container_name" "$PKG_PATH" | ||
|
||
# ensure service has started and still running after 5 seconds | ||
sleep 5 | ||
echo "Checking $SERVICE_NAME service status ..." | ||
$container_exec systemctl --no-pager status "$SERVICE_NAME" | ||
|
||
echo "Checking $PROCESS_NAME process ..." | ||
$container_exec pgrep -a -u otel "$PROCESS_NAME" | ||
|
||
# test uninstall | ||
echo | ||
uninstall_pkg "$container_name" "$pkg_type" | ||
|
||
echo "Checking $SERVICE_NAME service status after uninstall ..." | ||
if $container_exec systemctl --no-pager status "$SERVICE_NAME"; then | ||
echo "$SERVICE_NAME service still running after uninstall" >&2 | ||
exit 1 | ||
fi | ||
echo "$SERVICE_NAME service successfully stopped after uninstall" | ||
|
||
echo "Checking $SERVICE_NAME service existence after uninstall ..." | ||
if $container_exec systemctl list-unit-files --all | grep "$SERVICE_NAME"; then | ||
echo "$SERVICE_NAME service still exists after uninstall" >&2 | ||
exit 1 | ||
fi | ||
echo "$SERVICE_NAME service successfully removed after uninstall" | ||
|
||
echo "Checking $PROCESS_NAME process after uninstall ..." | ||
if $container_exec pgrep "$PROCESS_NAME"; then | ||
echo "$PROCESS_NAME process still running after uninstall" | ||
exit 1 | ||
fi | ||
echo "$PROCESS_NAME process successfully killed after uninstall" |