Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
allow_failures:
- name: "Ubuntu 18.04.sudo.mpich [Job failure permitted]"
- name: "Ubuntu 16.04 home PETSc [Job failure permitted]"
- name: "[16.04 PETSc] OpenFOAM <-> CalculiX [FSI] [Job failure permitted]"

include:
- stage: Building preCICE
Expand Down Expand Up @@ -360,7 +361,7 @@ jobs:
all_branches: true
script: python push.py -s -t of-of_np

- name: "[16.04 PETSc] OpenFOAM <-> CalculiX [FSI]"
- name: "[16.04 PETSc] OpenFOAM <-> CalculiX [FSI] [Job failure permitted]"
script:
- python system_testing.py -s of-ccx_fsi --base Ubuntu1604.home.PETSc
after_failure:
Expand Down
2 changes: 1 addition & 1 deletion compare_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ do case $i in
max_diff_limit="${i#*=}"
;;
*)
echo "Uknown options $i. Possible options: --avg_diff, --max_diff "; exit 1;;
echo "Unknown options $i. Possible options: --avg_diff, --max_diff "; exit 1;;
esac
done

Expand Down
72 changes: 38 additions & 34 deletions silent_compose.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
#!/bin/bash

# Runs docker-compose in the detached mode silently and then displays logs for the failed
# Runs docker-compose in the detached mode silently and then displays logs for the failed
# services as well as ones, that could not finish communication in the timeout time

taillen=500
failed=0

docker-compose up -d || exit 1
services=($(docker-compose ps | awk '{print $1}'| tail -n +3))
if [ "$1" = "debug" ]; then
docker-compose up
else
docker-compose up -d || exit 1
services=($(docker-compose ps | awk '{print $1}'| tail -n +3))

# maximum test timeout is 10 minutes
for i in {1..10}; do
for service in ${services[@]}; do
# check if the service is still running
if [ -z "$(docker ps | grep $service | cut -d ' ' -f 1)" ]; then
if [ "$(docker inspect $service --format='{{.State.ExitCode}}')" -eq 1 ]; then
echo "$service failed! Find the logs below"
failed=1
docker-compose logs --tail=$taillen $service
fi
# pop
services=(${services[@]/$service})
fi
done
# exit if nothing is running
if [ ${#services[@]} -eq 0 ]; then
echo "All adapters finished!"
exit $failed
fi
echo "Running the simulation...Be patient"
sleep 60
done
# maximum test timeout is 10 minutes
for i in {1..10}; do
for service in ${services[@]}; do
# check if the service is still running
if [ -z "$(docker ps | grep $service | cut -d ' ' -f 1)" ]; then
if [ "$(docker inspect $service --format='{{.State.ExitCode}}')" -eq 1 ]; then
echo "$service failed! Find the logs below"
failed=1
docker-compose logs --tail=$taillen $service
fi
# pop
services=(${services[@]/$service})
fi
done
# exit if nothing is running
if [ ${#services[@]} -eq 0 ]; then
echo "All adapters finished!"
exit $failed
fi
echo "Running the simulation...Be patient"
sleep 60
done

echo "Timeout!"
echo "Printing logs for services:"
echo "Timeout!"
echo "Printing logs for services:"

# probably failed due to communication issues,
# list individual logs and exit
for service in ${services[@]}; do
docker-compose logs --tail=$taillen $service
docker-compose stop $service
done
# probably failed due to communication issues,
# list individual logs and exit
for service in ${services[@]}; do
docker-compose logs --tail=$taillen $service
docker-compose stop $service
done

exit 1
exit 1
fi
45 changes: 28 additions & 17 deletions system_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def build_adapters(systest, tag, branch, local, force_rebuild):
docker_args = { 'tag': '',
'build_args': {"from": docker.get_namespace() + baseimage_name if local
else 'precice/' + baseimage_name },
'force_rebuild': force_rebuild,
'force_rebuild': force_rebuild,
'dockerfile': 'Dockerfile'}

with common.chdir(os.path.join(os.getcwd(), 'adapters')):
Expand All @@ -57,7 +57,7 @@ def build_adapters(systest, tag, branch, local, force_rebuild):
if os.path.exists("Dockerfile.{}".format(participant)):
docker.build_image(**docker_args)

def run_compose(systest, branch, local, tag, force_rebuild, rm_all):
def run_compose(systest, branch, local, tag, force_rebuild, rm_all=False, verbose=False):
""" Runs necessary systemtest with docker compose """

test_dirname = "TestCompose_{systest}".format(systest = systest)
Expand All @@ -67,12 +67,17 @@ def run_compose(systest, branch, local, tag, force_rebuild, rm_all):

# set up environment variables, to detect precice base image, that we
# should run with and docker images location
commands_main = ["""export PRECICE_BASE=-{base}; {extra_cmd} docker-compose config &&
bash ../../silent_compose.sh""".format(base =
adapter_base_name, extra_cmd =\
"export SYSTEST_REMOTE={remote};".format(
remote = docker.get_namespace()) if local else "" ),
"docker cp tutorial-data:/Output ."]
export_cmd = "export PRECICE_BASE=-{}; ".format(adapter_base_name)
extra_cmd = "export SYSTEST_REMOTE={}; ".format(docker.get_namespace()) if local else ""
compose_config_cmd = "docker-compose config && "
compose_exec_cmd = "bash ../../silent_compose.sh {}".format('debug' if verbose else "")
copy_cmd = "docker cp tutorial-data:/Output ."

commands_main = [export_cmd +
extra_cmd +
compose_config_cmd +
compose_exec_cmd,
copy_cmd]
# rebuild tutorials image if needed
if force_rebuild:
commands_main.insert(0, "docker-compose build --no-cache")
Expand All @@ -84,8 +89,8 @@ def run_compose(systest, branch, local, tag, force_rebuild, rm_all):

# cleanup previous results
shutil.rmtree("Output", ignore_errors=True)
try:

try:
for command in commands_main:
ccall(command)

Expand All @@ -98,7 +103,7 @@ def run_compose(systest, branch, local, tag, force_rebuild, rm_all):
for command in commands_cleanup:
ccall(command)

except (CalledProcessError, IncorrectOutput) as e:
except (CalledProcessError, IncorrectOutput) as e:
# cleanup in either case
if rm_all:
for command in commands_cleanup:
Expand Down Expand Up @@ -141,18 +146,23 @@ def comparison(pathToRef, pathToOutput):
num_diff = call("bash ../../compare_results.sh {} {}".format(pathToRef, pathToOutput))
if num_diff == 1:
raise IncorrectOutput(*ret)
elif num_diff != 0:
raise ValueError('compare_results.sh exited with unknown code {}'.format(num_diff))
else:
print('Test succeeded! Differences to referenceOutput within tolerance.')
else:
print('Test succeeded! No difference to referenceOutput found.')



def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all):
def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all=False, verbose=False):
""" Runs and compares test, using precice branch. """
compose_tests = ["dealii-of", "of-of", "su2-ccx", "of-ccx", "of-of_np",
"fe-fe","nutils-of", "of-ccx_fsi"]
test_basename = test.split(".")[0]
if local_precice:
build_adapters(test_basename, tag, branch, local_precice, force_rebuild)
if test_basename in compose_tests:
run_compose(test, branch, local_precice, tag, force_rebuild, rm_all)
run_compose(test, branch, local_precice, tag, force_rebuild, rm_all, verbose)
else:
# remaining, non-compose tests
test_dirname = "Test_{systest}".format(systest=test)
Expand All @@ -171,14 +181,15 @@ def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all):
if __name__ == "__main__":
# Parsing flags
parser = argparse.ArgumentParser(description='Build local.')
parser.add_argument('-l', '--local', action='store_true', help="use local preCICE image (default: use remote image)")
parser.add_argument('-s', '--systemtest', type=str, help="choose system tests you want to use",
parser.add_argument('-l', '--local', action='store_true', help="Use local preCICE image (default: use remote image)")
parser.add_argument('-s', '--systemtest', type=str, help="Choose system tests you want to use",
choices = common.get_tests(), required = True)
parser.add_argument('-b', '--branch', help="preCICE branch to use", default = "develop")
parser.add_argument('-f', '--force_rebuild', nargs='+', help="Force rebuild of variable parts of docker image",
default = [], choices = ["precice", "tests"])
parser.add_argument('--base', type=str,help="Base preCICE image to use",
default= "Ubuntu1604.home")
parser.add_argument('-v', '--verbose', action='store_true',help="Verbose output of participant containers")
args = parser.parse_args()
# check if there is specialized dir for this version
test_name = args.systemtest
Expand All @@ -190,4 +201,4 @@ def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all):
test = test[0]
tag = args.base.lower()
build_run_compare(test, tag, args.branch.lower(), args.local,
args.force_rebuild, False)
args.force_rebuild, rm_all=False, verbose=args.verbose)
5 changes: 3 additions & 2 deletions tests/TestCompose_dealii-of/Dockerfile.tutorial_data
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ RUN apk add git

ARG branch=develop
RUN git clone --branch $branch https://github.com/precice/tutorials
RUN mkdir configs && sed -e 's|gather-scatter"|gather-scatter" exchange-directory="/home/precice/Data/Exchange/" network="eth0"|g' $tutorial_path/precice-config_serial.xml > configs/precice-config.xml
RUN mkdir configs && sed -e 's|<m2n:sockets from=\"Fluid\" to=\"Solid\"/>|<m2n:sockets from=\"Fluid\" to=\"Solid\" exchange-directory=\"/home/precice/Data/Exchange/\" network=\"eth0\"/>|g'\
$tutorial_path/precice-config.xml > configs/precice-config.xml
RUN sed -i '/application pimpleFoam/d; s/\/\/ application pimpleDyMFoam/application pimpleDyMFoam/g' \
$tutorial_path/Fluid/system/controlDict
RUN rm $tutorial_path/precice-config_serial.xml $tutorial_path/precice-config.xml
RUN rm $tutorial_path/precice-config.xml
RUN rm -rfv $tutorial_path/Fluid/0/
RUN cp -r $tutorial_path/Fluid/0.orig/ $tutorial_path/Fluid/0/
RUN addgroup -g 1000 precice && adduser -u 1000 -G precice -D precice && chown -R precice:precice tutorials configs
Expand Down
16 changes: 8 additions & 8 deletions tests/TestCompose_dealii-of/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version : '3'
services:
dealii-adapter:

dealii-adapter:
image: "${SYSTEST_REMOTE}dealii-adapter${PRECICE_BASE}:${DEALII_TAG}"
networks:
networks:
- precicecomm
volumes:
- exchange:/home/precice/Data/Exchange/
Expand All @@ -12,24 +12,24 @@ services:
- output:/home/precice/Data/Output/
command: >
/bin/bash -c "
ln -sf configs/* . &&
ln -sf configs/* . &&
./coupled_elasto_dynamics /home/precice/Data/Input/parameters.prm"
container_name: dealii-adapter
depends_on:
- tutorial-data
- openfoam-adapter
openfoam-adapter:

openfoam-adapter:
image: "${SYSTEST_REMOTE}openfoam-adapter${PRECICE_BASE}:${OPENFOAM_TAG}"
networks:
networks:
- precicecomm
volumes:
- exchange:/home/precice/Data/Exchange/
- input_of:/home/precice/Data/Input/
- configs:/home/precice/openfoam-adapter/configs/
- output:/home/precice/Data/Output/
command: >
/bin/bash -c "source /opt/openfoam4/etc/bashrc &&
/bin/bash -c "source /opt/openfoam4/etc/bashrc &&
ln -sf configs/* . &&
blockMesh -case /home/precice/Data/Input &&
checkMesh -case /home/precice/Data/Input &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENV tutorial_path tutorials/HT/partitioned-heat/fenics-fenics
RUN apk add git
ARG branch=develop
RUN git clone --branch $branch https://github.com/precice/tutorials
RUN mkdir configs && sed -i 's|network="lo"|exchange-directory="/home/precice/Data/Exchange/" network="eth0"|g' $tutorial_path/precice-config.xml
RUN mkdir configs && sed -i 's|<m2n:sockets from="HeatDirichlet" to="HeatNeumann"/>|<m2n:sockets from="HeatDirichlet" to="HeatNeumann" exchange-directory="/home/precice/Data/Exchange/" network="eth0"/>|g' $tutorial_path/precice-config.xml

RUN addgroup -g 1000 precice && adduser -u 1000 -G precice -D precice && chown -R precice:precice tutorials configs
USER precice
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ RUN git clone --branch $branch https://github.com/precice/tutorials
WORKDIR /
# adjust configuration and paths
RUN mkdir configs && cp $tutorial_path/precice-config.xml configs/precice-config.xml && \
sed -i 's|exchange-directory\=".."|exchange-directory="/home/precice/Data/Exchange/" network="eth0"|g' \
sed -i 's|exchange-directory="\.\."|exchange-directory="/home/precice/Data/Exchange/" network="eth0"|g' \
configs/precice-config.xml && \
sed -i 's|\.\./precice-config.xml|configs/precice-config.xml|g' $tutorial_path/Nutils/cht.py && \
sed -i 's|\.\./precice-config.xml|configs/precice-config.xml|g' $tutorial_path/OpenFOAM/precice-adapter-config.yml

sed -i 's|\.\./precice-config\.xml|configs/precice-config.xml|g' $tutorial_path/Nutils/cht.py && \
sed -i 's|\.\./precice-config\.xml|configs/precice-config.xml|g' $tutorial_path/OpenFOAM/precice-adapter-config.yml
RUN addgroup -g 1000 precice && adduser -u 1000 -G precice -D precice && chown -R precice:precice tutorials configs
USER precice
14 changes: 8 additions & 6 deletions tests/TestCompose_nutils-of.Ubuntu1804/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
version: '3'
services:

openfoam-adapter-outer:
image: "${SYSTEST_REMOTE}openfoam-adapter${PRECICE_BASE}:${OPENFOAM_TAG}"
networks:
networks:
- precicecomm
volumes:
- exchange:/home/precice/Data/Exchange/
- output:/home/precice/Data/Output/
- openfoam_input:/home/precice/Data/Input/
- configs:/home/precice/openfoam-adapter/configs/
command: >
/bin/bash -c "source /opt/openfoam5/etc/bashrc
/bin/bash -c "sleep 10 && source /opt/openfoam5/etc/bashrc
&& blockMesh -case /home/precice/Data/Input
&& buoyantPimpleFoam -case /home/precice/Data/Input
&& cp -r /home/precice/Data/Input/. /home/precice/Data/Output/OpenFOAM"
&& cp -r /home/precice/Data/Input/. /home/precice/Data/Output/OpenFOAM"
container_name: openfoam-adapter-outer
depends_on:
- tutorial-data
Expand All @@ -26,7 +25,7 @@ services:
dockerfile: Dockerfile.nutils
args:
from: "${SYSTEST_REMOTE}precice${PRECICE_BASE}"
networks:
networks:
- precicecomm
volumes:
- exchange:/home/precice/Data/Exchange/
Expand All @@ -35,7 +34,7 @@ services:
- configs:/home/precice/nutils/configs/
command: >
/bin/bash -c "ln -sf /home/precice/Data/Input/* .
&& python3 cht.py
&& python3 cht.py
&& mkdir /home/precice/Data/Output/Nutils && cp *.log *.vtk /home/precice/Data/Output/Nutils"
container_name: nutils-adapter
depends_on:
Expand All @@ -45,7 +44,10 @@ services:
build:
context: .
dockerfile: Dockerfile.tutorial_data
args:
branch: "develop"
volumes:
- exchange:/Exchange/
- openfoam_input:/tutorials/CHT/flow-over-plate/buoyantPimpleFoam-nutils/OpenFOAM
- nutils_input:/tutorials/CHT/flow-over-plate/buoyantPimpleFoam-nutils/Nutils
- configs:/configs/
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCompose_of-ccx/Dockerfile.tutorial_data
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN git clone --branch $branch https://github.com/precice/tutorials
# Copy modified configs
COPY controlDict $tutorial_path/Inner-Fluid/system/controlDict
COPY controlDict $tutorial_path/Outer-Fluid/system/controlDict
COPY precice-config_serial.xml configs/precice-config.xml
COPY precice-config.xml configs/precice-config.xml

# Download meshes
WORKDIR $tutorial_path
Expand Down
Loading