-
Notifications
You must be signed in to change notification settings - Fork 17
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
e2e-tests: Add end-to-end test script and docker compose app #359
Open
detsch
wants to merge
7
commits into
master
Choose a base branch
from
detsch-e2e-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ae4b810
dev-flow: Build aktualizr-get by default
detsch f5cca3e
e2e-tests: Add end-to-end test environment
detsch b3fbd8c
e2e-tests: Add e2e-tests.py script, based on pytest
detsch d72be8a
e2e-tests: Add GitHub action to run a subset of 2e2 tests
detsch 84e47d0
makefile: Add helpers to run common tasks inside e2e tests container
detsch 54f6886
readme: Remove custom client documentation, and add reference to sotactl
detsch ab1fad4
readme: Add documentation for development container usage
detsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,17 @@ | ||
#!/bin/bash | ||
|
||
docker_dir=docker-e2e-test | ||
docker_path=${PWD}/${docker_dir} | ||
|
||
# Function to execute custom commands before exiting | ||
down() { | ||
docker compose --env-file=${docker_path}/.env.dev -f ${docker_path}/docker-compose.yml down --remove-orphans | ||
# remove the docker runtime part | ||
docker volume rm ${docker_dir}_docker-runtime | ||
} | ||
|
||
# Register the cleanup function to be called on EXIT | ||
trap down EXIT | ||
|
||
mkdir -p $PWD/.device/sysroot | ||
docker compose --env-file=${docker_path}/.env.dev -f ${docker_path}/docker-compose.yml run -e DEV_USER=$(id -u) -e DEV_GROUP=$(id -g) -e BASE_TARGET_VERSION=${BASE_TARGET_VERSION} -e USER_TOKEN=${USER_TOKEN} aklite-e2e-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FACTORY=$FACTORY | ||
AUTH_TOKEN=$USER_TOKEN | ||
DEVICE_TAG=main | ||
|
||
DEV_DIR=$PWD/.device | ||
SOTA_DIR=$DEV_DIR/sota | ||
USR_SOTA_DIR=$DEV_DIR/usr.sota | ||
ETC_SOTA_DIR=$DEV_DIR/etc.sota | ||
DOCKER_DIR=$DEV_DIR/docker | ||
|
||
# /sysroot dir containing ostree repo in /sysroot/ostree/repo | ||
SYSROOT=$DEV_DIR/sysroot | ||
BOOTDIR=$DEV_DIR/boot | ||
|
||
# /var/lib/docker | ||
DOCKER_DATA_ROOT=$DOCKER_DIR/data | ||
|
||
# Dir containing Dockerfile and build context to build the "aklite-test" image | ||
AKLITE_E2E_TEST_DOCKER_DIR=$PWD/docker-e2e-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
FROM golang:1.22.2-bookworm AS composeapp | ||
# Build composeapp | ||
WORKDIR /build | ||
RUN git clone https://github.com/foundriesio/composeapp.git && cd composeapp \ | ||
&& STOREROOT=/var/sota/reset-apps COMPOSEROOT=/var/sota/compose-apps BASESYSTEMCONFIG=/usr/lib/docker make \ | ||
&& cp ./bin/composectl /usr/bin/ | ||
|
||
# We may add fioctl and fioconfig to the test sequence. For now, we don't use them | ||
# WORKDIR /build | ||
# RUN git clone https://github.com/foundriesio/fioconfig.git && cd fioconfig \ | ||
# && make bin/fioconfig-linux-amd64 \ | ||
# && cp ./bin/fioconfig-linux-amd64 /usr/bin/fioconfig | ||
|
||
# WORKDIR /build | ||
# RUN git clone https://github.com/foundriesio/fioctl.git && cd fioctl \ | ||
# && make fioctl-linux-amd64 \ | ||
# && cp ./bin/fioctl-linux-amd64 /usr/bin/fioctl | ||
|
||
|
||
FROM foundries/aklite-dev AS aklite | ||
|
||
# Install composectl | ||
COPY --from=composeapp /build/composeapp/bin/composectl /usr/bin/ | ||
|
||
# # Install fioconfig | ||
# COPY --from=composeapp /build/fioconfig/bin/fioconfig-linux-amd64 /usr/bin/fioconfig | ||
|
||
# # Install fioctl | ||
# COPY --from=composeapp /build/fioctl/bin/fioctl-linux-amd64 /usr/bin/fioctl | ||
|
||
|
||
# Install lmp-device-register | ||
RUN apt-get install -y libboost-iostreams-dev | ||
|
||
RUN git clone https://github.com/foundriesio/lmp-device-register \ | ||
&& cd lmp-device-register && git checkout mp-90 \ | ||
&& cmake -S . -B ./build -DDOCKER_COMPOSE_APP=ON -DHARDWARE_ID=intel-corei7-64 && cmake --build ./build --target install | ||
|
||
|
||
# Add Docker's official GPG key: | ||
RUN apt-get update && apt-get install -y ca-certificates curl | ||
RUN install -m 0755 -d /etc/apt/keyrings | ||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | ||
RUN chmod a+r /etc/apt/keyrings/docker.asc | ||
|
||
# Add the repository to Apt sources: | ||
RUN echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | ||
tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
||
RUN apt-get update && apt-get install -y docker-ce-cli docker-compose-plugin | ||
|
||
# Install docker credential helper and auth configuration | ||
COPY config.json /usr/lib/docker/config.json | ||
COPY docker-credential-fio-helper /usr/bin/docker-credential-fio-helper | ||
|
||
# Install gosu required for the entry/startup script to add a user and group in the container | ||
RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.14/gosu-amd64" && \ | ||
chmod +x /usr/local/bin/gosu && \ | ||
gosu nobody true | ||
|
||
# Install pytest | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir pytest | ||
|
||
# Copy the entrypoint script | ||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["bash"] |
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,6 @@ | ||
{ | ||
"credHelpers": { | ||
"hub.foundries.io": "fio-helper" | ||
} | ||
} | ||
|
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,45 @@ | ||
version: '3.8' | ||
|
||
services: | ||
dockerd: | ||
image: docker:25.0-dind | ||
command: ["dockerd", "-H", "unix:///var/run/docker/docker.sock"] | ||
volumes: | ||
- ${DOCKER_DATA_ROOT}:/var/lib/docker | ||
- docker-runtime:/var/run/docker | ||
privileged: true | ||
|
||
aklite-e2e-test: | ||
build: | ||
context: ${AKLITE_E2E_TEST_DOCKER_DIR} | ||
args: | ||
AKLITE_VER: master | ||
dockerfile: Dockerfile | ||
|
||
image: aklite-e2e-test | ||
volumes: | ||
- "${PWD}:${PWD}" | ||
- ${SYSROOT}:/sysroot | ||
- ${SYSROOT}/ostree:/ostree | ||
- ${BOOTDIR}:/boot | ||
- ${SOTA_DIR}:/var/sota | ||
- ${USR_SOTA_DIR}:/usr/lib/sota/conf.d | ||
- ${ETC_SOTA_DIR}:/etc/sota/conf.d | ||
- ${DOCKER_DATA_ROOT}:/var/lib/docker | ||
- docker-runtime:/var/run/docker | ||
working_dir: "${PWD}" | ||
hostname: device | ||
user: "root" | ||
environment: | ||
- FACTORY=${FACTORY} | ||
- AUTH_TOKEN=${AUTH_TOKEN} | ||
- DEVICE_TAG=${DEVICE_TAG} | ||
- DOCKER_HOST=unix:///var/run/docker/docker.sock | ||
- DOCKER_CONFIG=/usr/lib/docker | ||
- CXX=clang++ | ||
- CC=clang | ||
depends_on: | ||
- dockerd | ||
|
||
volumes: | ||
docker-runtime: |
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,19 @@ | ||
#!/bin/sh -e | ||
|
||
# Use stderr for logging err output in libaktualizr | ||
export LOG_STDERR=1 | ||
SOTA_DIR="${SOTA_DIR-/var/sota}" | ||
|
||
LOGLEVEL="${CREDS_LOGLEVEL-4}" | ||
|
||
if [ "$1" = "get" ] ; then | ||
if [ ! -f ${SOTA_DIR}/sota.toml ] ; then | ||
echo "ERROR: Device does not appear to be registered under $SOTA_DIR" | ||
exit 1 | ||
fi | ||
server=$(grep -m1 '^[[:space:]]*server' ${SOTA_DIR}/sota.toml | cut -d\" -f2) | ||
if [ -z $server ] ; then | ||
server="https://ota-lite.foundries.io:8443" | ||
fi | ||
exec /usr/local/bin/aktualizr-get --loglevel $LOGLEVEL -u ${server}/hub-creds/ | ||
fi |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be useful to add an example. Something like:
cat <sota-project-home-dir>/.device/etc.sota/z-90-apps.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done