Initial commit
This commit is contained in:
parent
b82184fcc5
commit
5d28675e27
35
compose/docker-compose-external-test.yml
Normal file
35
compose/docker-compose-external-test.yml
Normal file
@ -0,0 +1,35 @@
|
||||
services:
|
||||
test:
|
||||
image: cerc/test-container:local
|
||||
restart: always
|
||||
environment:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_TEST_PARAM_1: ${CERC_TEST_PARAM_1:-FAILED}
|
||||
CERC_TEST_PARAM_2: "CERC_TEST_PARAM_2_VALUE"
|
||||
CERC_TEST_PARAM_3: ${CERC_TEST_PARAM_3:-FAILED}
|
||||
volumes:
|
||||
- test-data-bind:/data
|
||||
- test-data-auto:/data2
|
||||
- test-config:/config:ro
|
||||
ports:
|
||||
- "80"
|
||||
|
||||
external-test:
|
||||
image: cerc/external-test-container:local
|
||||
restart: always
|
||||
environment:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_TEST_PARAM_1: ${CERC_TEST_PARAM_1:-FAILED}
|
||||
CERC_TEST_PARAM_2: "CERC_TEST_PARAM_2_VALUE"
|
||||
CERC_TEST_PARAM_3: ${CERC_TEST_PARAM_3:-FAILED}
|
||||
volumes:
|
||||
- test-data-bind:/data
|
||||
- test-data-auto:/data2
|
||||
- test-config:/config:ro
|
||||
ports:
|
||||
- "80"
|
||||
|
||||
volumes:
|
||||
test-data-bind:
|
||||
test-data-auto:
|
||||
test-config:
|
12
container-build/cerc-external-test-container/Dockerfile
Normal file
12
container-build/cerc-external-test-container/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NOWARNINGS="yes" && \
|
||||
apt-get install -y software-properties-common && \
|
||||
apt-get install -y nginx && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY run.sh /app/run.sh
|
||||
|
||||
ENTRYPOINT ["/app/run.sh"]
|
5
container-build/cerc-external-test-container/build.sh
Executable file
5
container-build/cerc-external-test-container/build.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/test-container
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
docker build -t cerc/external-test-container:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
68
container-build/cerc-external-test-container/run.sh
Executable file
68
container-build/cerc-external-test-container/run.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
echo "Test container starting"
|
||||
|
||||
DATA_DEVICE=$(df | grep "/data$" | awk '{ print $1 }')
|
||||
if [[ -n "$DATA_DEVICE" ]]; then
|
||||
echo "/data: MOUNTED dev=${DATA_DEVICE}"
|
||||
else
|
||||
echo "/data: not mounted"
|
||||
fi
|
||||
|
||||
DATA2_DEVICE=$(df | grep "/data2$" | awk '{ print $1 }')
|
||||
if [[ -n "$DATA_DEVICE" ]]; then
|
||||
echo "/data2: MOUNTED dev=${DATA2_DEVICE}"
|
||||
else
|
||||
echo "/data2: not mounted"
|
||||
fi
|
||||
|
||||
# Test if the container's filesystem is old (run previously) or new
|
||||
test_file_name="external-exists"
|
||||
for d in /data /data2; do
|
||||
if [[ -f "$d/${test_file_name}" ]];
|
||||
then
|
||||
TIMESTAMP=`cat $d/${test_file_name}`
|
||||
echo "$d filesystem is old, created: $TIMESTAMP"
|
||||
else
|
||||
echo "$d filesystem is fresh"
|
||||
echo `date` > $d/${test_file_name}
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$CERC_TEST_PARAM_1" ]; then
|
||||
echo "Test-param-1: ${CERC_TEST_PARAM_1}"
|
||||
fi
|
||||
if [ -n "$CERC_TEST_PARAM_2" ]; then
|
||||
echo "Test-param-2: ${CERC_TEST_PARAM_2}"
|
||||
fi
|
||||
if [ -n "$CERC_TEST_PARAM_3" ]; then
|
||||
echo "Test-param-3: ${CERC_TEST_PARAM_3}"
|
||||
fi
|
||||
if [ -n "$CERC_TEST_PARAM_4" ]; then
|
||||
echo "Test-param-4: ${CERC_TEST_PARAM_4}"
|
||||
fi
|
||||
if [ -n "$CERC_TEST_PARAM_5" ]; then
|
||||
echo "Test-param-5: ${CERC_TEST_PARAM_5}"
|
||||
fi
|
||||
|
||||
if [ -d "/config" ]; then
|
||||
echo "/config: EXISTS"
|
||||
for f in /config/*; do
|
||||
if [[ -f "$f" ]] || [[ -L "$f" ]]; then
|
||||
echo "$f:"
|
||||
cat "$f"
|
||||
echo ""
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "/config: does NOT EXIST"
|
||||
fi
|
||||
|
||||
# Run nginx which will block here forever
|
||||
/usr/sbin/nginx -g "daemon off;"
|
4
stacks/test-external-stack/README.md
Normal file
4
stacks/test-external-stack/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# An external test stack
|
||||
|
||||
Used to test stack orchestrator's support for external stacks.
|
||||
|
57
stacks/test-external-stack/deploy/commands.py
Normal file
57
stacks/test-external-stack/deploy/commands.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright © 2022, 2023 Vulcanize
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from stack_orchestrator.util import get_yaml
|
||||
from stack_orchestrator.deploy.deploy_types import DeployCommandContext
|
||||
from stack_orchestrator.deploy.stack_state import State
|
||||
from stack_orchestrator.deploy.deploy_util import VolumeMapping, run_container_command
|
||||
from pathlib import Path
|
||||
|
||||
default_spec_file_content = """config:
|
||||
test-variable-1: test-value-1
|
||||
"""
|
||||
|
||||
|
||||
# Output a known string to a know file in the bind mounted directory ./container-output-dir
|
||||
# for test purposes -- test checks that the file was written.
|
||||
def setup(command_context: DeployCommandContext, parameters, extra_args):
|
||||
host_directory = "./container-output-dir"
|
||||
host_directory_absolute = Path(extra_args[0]).absolute().joinpath(host_directory)
|
||||
host_directory_absolute.mkdir(parents=True, exist_ok=True)
|
||||
mounts = [
|
||||
VolumeMapping(host_directory_absolute, "/data")
|
||||
]
|
||||
output, status = run_container_command(command_context, "test", "echo output-data > /data/output-file && echo success", mounts)
|
||||
|
||||
|
||||
def init(command_context: DeployCommandContext):
|
||||
yaml = get_yaml()
|
||||
return yaml.load(default_spec_file_content)
|
||||
|
||||
|
||||
def create(command_context: DeployCommandContext, extra_args):
|
||||
data = "create-command-output-data"
|
||||
output_file_path = command_context.deployment_dir.joinpath("create-file")
|
||||
with open(output_file_path, 'w+') as output_file:
|
||||
output_file.write(data)
|
||||
|
||||
|
||||
def get_state(command_context: DeployCommandContext):
|
||||
print("Here we get state")
|
||||
return State.CONFIGURED
|
||||
|
||||
|
||||
def change_state(command_context: DeployCommandContext):
|
||||
pass
|
11
stacks/test-external-stack/stack.yml
Normal file
11
stacks/test-external-stack/stack.yml
Normal file
@ -0,0 +1,11 @@
|
||||
version: "1.0"
|
||||
name: external-test
|
||||
description: "An external test stack"
|
||||
repos:
|
||||
- git.vdb.to/cerc-io/test-project@test-branch
|
||||
containers:
|
||||
- cerc/test-container
|
||||
- cerc/external-test-container
|
||||
pods:
|
||||
- test
|
||||
- external-test
|
Loading…
Reference in New Issue
Block a user