Skip to content
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
18 changes: 18 additions & 0 deletions pkg/container/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ func prepareComposeCommand(commandArgs ...string) (command string, args []string
if err != nil {
return
}

// Normalized differences between the commands
if command == "podman-compose" && len(commandArgs) > 0 && commandArgs[0] == "down" {
// Note: podman-compose down does not support "--remove-orphans" argument, so strip it out
commandArgs = filter(commandArgs, func(s string) bool {
return s != "--remove-orphans"
})
}

args = append(args, commandArgs...)
return command, args, nil
}

func filter(ss []string, test func(string) bool) (ret []string) {
for _, s := range ss {
if test(s) {
ret = append(ret, s)
}
}
return
}
14 changes: 9 additions & 5 deletions test-images/debian-systemd-docker-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ ARG TARGETPLATFORM
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Install with all recommended packages as this is simplier to maintain
podman \
&& DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y --no-install-recommends \
&& install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc \
&& chmod a+r /etc/apt/keyrings/docker.asc \
&& echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::="--force-confnew" -y --no-install-recommends \
# Installing docker-ce at build time fails.
# See https://github.com/docker/cli/issues/4807 for details
# docker-ce \
Expand All @@ -28,9 +34,7 @@ RUN case ${TARGETPLATFORM} in \
"linux/arm/v7") PKG_ARCH=linux_armv7 ;; \
*) echo "Unsupported target platform: TARGETPLATFORM=$TARGETPLATFORM"; exit 1 ;; \
esac \
# FIXME: Replace once project is merged back with tedge-container-plugin
# && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" --allow-downgrades -y /tmp/*${PKG_ARCH}*.deb \
&& dpkg -i --force-overwrite /tmp/*${PKG_ARCH}*.deb \
&& apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" --allow-downgrades -y /tmp/*${PKG_ARCH}*.deb \
&& mkdir -p /opt/packages \
&& cp /tmp/*${PKG_ARCH}*.deb /opt/packages/ \
&& rm -f /tmp/*.deb
12 changes: 2 additions & 10 deletions test-images/debian-systemd-podman-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
FROM ghcr.io/thin-edge/tedge-demo-main-systemd:latest
ARG TARGETPLATFORM

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Install with all recommended packages as this is simplier to maintain
podman \
&& DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y --no-install-recommends \
podman-compose \
&& tedge config unset c8y.proxy.client.host \
RUN tedge config unset c8y.proxy.client.host \
&& tedge config unset mqtt.client.host \
&& tedge config unset http.client.host

Expand All @@ -23,9 +17,7 @@ RUN case ${TARGETPLATFORM} in \
"linux/arm/v7") PKG_ARCH=linux_armv7 ;; \
*) echo "Unsupported target platform: TARGETPLATFORM=$TARGETPLATFORM"; exit 1 ;; \
esac \
# FIXME: Replace once project is merged back with tedge-container-plugin
# && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" --allow-downgrades -y /tmp/*${PKG_ARCH}*.deb \
&& dpkg -i --force-overwrite /tmp/*${PKG_ARCH}*.deb \
&& apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" --allow-downgrades -y /tmp/*${PKG_ARCH}*.deb \
&& mkdir -p /opt/packages \
&& cp /tmp/*${PKG_ARCH}*.deb /opt/packages/ \
&& rm -f /tmp/*.deb
2 changes: 1 addition & 1 deletion tests/data/apps/app1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM nginx
FROM docker.io/nginx
COPY static /usr/share/nginx/html
2 changes: 1 addition & 1 deletion tests/data/apps/app2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM nginx
FROM docker.io/nginx
COPY static /usr/share/nginx/html
2 changes: 1 addition & 1 deletion tests/data/apps/app3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM alpine:3.18
FROM docker.io/alpine:3.18
ENTRYPOINT [ "/bin/sleep", "infinity" ]
2 changes: 1 addition & 1 deletion tests/data/docker-compose.nginx.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
nginx:
image: nginx
image: docker.io/nginx
hostname: nginx
networks:
- tedge
Expand Down
7 changes: 4 additions & 3 deletions tests/installation.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Test Teardown Collect Logs
*** Test Cases ***

Update to tedge-container-plugin-ng
DeviceLibrary.Execute Command cmd=apt-get install -y -o Dpkg::Options::="--force-confdef" /opt/packages/*.deb
DeviceLibrary.Execute Command cmd=apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" /opt/packages/*.deb
Cumulocity.Should Have Services name=tedge-container-plugin service_type=service min_count=1 max_count=1 timeout=30
Cumulocity.Should Have Services name=tedge-container-monitor service_type=service min_count=0 max_count=0 timeout=30

Expand All @@ -26,10 +26,11 @@ Test Setup
Set Suite Variable $DEVICE_SN
Cumulocity.External Identity Should Exist ${DEVICE_SN}

# Install older version
# Remove an previously installed versions (for a clean install)
DeviceLibrary.Execute Command apt-get remove -y tedge-container-plugin-ng && apt-get purge -y tedge-container-plugin-ng
DeviceLibrary.Execute Command apt-get remove -y tedge-container-plugin && apt-get purge -y tedge-container-plugin ignore_exit_code=${True}
DeviceLibrary.Execute Command apt-get remove -y tedge-container-plugin && apt-get purge -y tedge-container-plugin && rm -rf /etc/tedge-container-plugin ignore_exit_code=${True}

# Install older version
DeviceLibrary.Execute Command apt-get update && apt-get install -y tedge-container-plugin
Cumulocity.Should Have Services name=tedge-container-monitor service_type=service min_count=1 max_count=1 timeout=60

Expand Down
15 changes: 8 additions & 7 deletions tests/operations.robot
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ Install/uninstall container-group package
Device Should Not Have Installed Software nginx
Cumulocity.Should Have Services name=nginx@nginx service_type=container-group min_count=0 max_count=0

Install container-group with multiple files
[Template] Install container-group file
app1 1.0.1 app1 ${CURDIR}/data/apps/app1.tar.gz
app2 1.2.3 app2 ${CURDIR}/data/apps/app2.zip
Install container-group with multiple files - app1
Install container-group file app1 1.0.1 app1 ${CURDIR}/data/apps/app1.tar.gz

Install container-group with multiple files - app2
Install container-group file app2 1.2.3 app2 ${CURDIR}/data/apps/app2.zip

Install/uninstall container package
${operation}= Cumulocity.Install Software {"name": "webserver", "version": "httpd:2.4", "softwareType": "container"}
Operation Should Be SUCCESSFUL ${operation} timeout=60
Device Should Have Installed Software {"name": "webserver", "version": "httpd:2.4", "softwareType": "container"}
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge busybox wget -O- webserver:80;
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge docker.io/busybox wget -O- webserver:80;
Operation Should Be SUCCESSFUL ${operation}
Should Contain ${operation.to_json()["c8y_Command"]["result"]} It works!
Cumulocity.Should Have Services name=webserver service_type=container status=up
Expand Down Expand Up @@ -72,7 +73,7 @@ Manual container creation/deletion
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker network create tedge ||:; sudo tedge-container engine docker run -d --network tedge --name manualapp1 httpd:2.4
Operation Should Be SUCCESSFUL ${operation} timeout=60

${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge busybox wget -O- manualapp1:80;
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge docker.io/busybox wget -O- manualapp1:80;
Operation Should Be SUCCESSFUL ${operation}

Should Contain ${operation.to_json()["c8y_Command"]["result"]} It works!
Expand Down Expand Up @@ -137,7 +138,7 @@ Install container-group file
${operation}= Cumulocity.Install Software {"name": "${package_name}", "version": "${package_version}", "softwareType": "container-group", "url": "${binary_url}"}
Operation Should Be SUCCESSFUL ${operation} timeout=300
Device Should Have Installed Software {"name": "${package_name}", "version": "${package_version}", "softwareType": "container-group"}
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge busybox wget -O- ${service_name}:80
${operation}= Cumulocity.Execute Shell Command sudo tedge-container engine docker run --rm -t --network tedge docker.io/busybox wget -O- ${service_name}:80
Operation Should Be SUCCESSFUL ${operation}
Should Contain ${operation.to_json()["c8y_Command"]["result"]} My Custom Web Application
Cumulocity.Should Have Services name=${package_name}@${service_name} service_type=container-group status=up
Expand Down