Skip to content
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

Add code to cpp-client/build.gradle to run tests in docker. #3006

Merged
merged 20 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
24 changes: 16 additions & 8 deletions cpp-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@ C++ compiler and tool suite (cmake etc).

6. Build and install dependencies for Deephaven C++ client.

Decide on a directory for the dependencies to live (eg, "$HOME/dhcpp").
Create that directory and copy the `$DHSRC/deephaven-core/cpp-client/deephaven/client/build-dependencies.sh`
to it. Edit the script if necessary to reflect your selection of build tools and build target
(defaults point to Ubuntu system's g++, cmake, and a Debug build target for cmake).
Run the script from the same directory you copied it to.
It will download, build and install the dependent libraries
Get the `build-dependencies.sh` script from Deephaven's base images repository
at `https://github.com/deephaven/deephaven-base-images/blob/main/cpp-client`
You can download it directly from the link
`https://github.com/deephaven/deephaven-base-images/raw/main/cpp-client/build-dependencies.sh`
(this script is also used from our automated tools, to generate a docker image to
support tests runs; that's why it lives in a separate repo).
The script downloads, builds and installs the dependent libraries
(Protobuf, re2, gflags, absl, flatbuffers, c-ares, zlib, gRPC, and Arrow).
Edit your local copy of the script if necessary to reflect your selection
of build tools and build target;
defaults point to Ubuntu system's g++, cmake, and a Debug build target for cmake.
Comments in the script will help you in identifying customization points.
Decide on a directory for the dependencies to live (eg, "$HOME/dhcpp").
Create that directory, and run your local copy of `build-dependencies.sh` from
that directory.


Example:
```
mkdir -p $HOME/dhcpp
cd $HOME/dhcpp
cp $DHSRC/deephaven-core/cpp-client/deephaven/client/build-dependencies.sh .
wget https://github.com/deephaven/deephaven-base-images/raw/main/cpp-client/build-dependencies.sh
# Maybe edit build-dependencies.sh to reflect choices of build tools and build target
./build-dependencies.sh
```
Expand Down
75 changes: 75 additions & 0 deletions cpp-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
plugins {
id 'com.bmuschko.docker-remote-api'
id 'io.deephaven.project.register'
id 'io.deephaven.deephaven-in-docker'
id 'license'
}

evaluationDependsOn Docker.registryProject('cpp-client-base')

license {
header rootProject.file('license-header')
include '**/*.h'
Expand All @@ -19,3 +23,74 @@ tasks.getByName('licenseFormat').dependsOn(tasks.create("licenseFormatPy", com.h
})

project.tasks.getByName('quick').dependsOn project.tasks.getByName('license')

// start a grpc-api server
String randomSuffix = UUID.randomUUID().toString();
deephavenDocker {
containerName.set "dh-server-for-cpp-${randomSuffix}"
networkName.set "cpp-test-network-${randomSuffix}"
}

def testCppClient = Docker.registerDockerTask(project, 'testCppClient') {
copyIn {
from(layout.projectDirectory) {
include 'cpp-tests-to-junit.sh'
include 'deephaven/CMakeLists.txt'
include 'deephaven/client/**'
include 'tests/CMakeLists.txt'
include 'tests/*.cc'
include 'tests/*.h'
include 'tests/third_party/**'
}
}
copyOut {
into layout.buildDirectory.dir('test-results')
}
dockerfile {
from('deephaven/cpp-client-base:local-build')
//
// Build client library.
//
runCommand('mkdir -p /cpp-client/deephaven/client /cpp-client/deephaven/build')
copyFile('deephaven/CMakeLists.txt', '/cpp-client/deephaven')
copyFile('deephaven/client', '/cpp-client/deephaven/client/')
runCommand('''set -eux; \\
cd /cpp-client/deephaven/build; \\
. /cpp-client/deps/env.sh; \\
cmake -DCMAKE_INSTALL_PREFIX=/cpp-client/install ..; \\
make -j\$NCPUS install; \\
jcferretti marked this conversation as resolved.
Show resolved Hide resolved
cd ..; \\
rm -fr /cpp-client/deephaven/build
''')
//
// Build tests.
//
runCommand('mkdir -p /cpp-client/tests/build /cpp-client/install/bin /out')
copyFile('cpp-tests-to-junit.sh', '/cpp-client/install/bin')
copyFile('tests/*.cc', '/cpp-client/tests/')
copyFile('tests/*.h', '/cpp-client/tests/')
copyFile('tests/CMakeLists.txt', '/cpp-client/tests/')
copyFile('tests/third_party', '/cpp-client/tests/third_party/')
runCommand('''set -eux; \\
cd /cpp-client/tests/build; \\
. /cpp-client/deps/env.sh; \\
cmake -DCMAKE_PREFIX_PATH=/cpp-client/install:$CMAKE_PREFIX_PATH ..; \\
make -j\$NCPUS; \\
jcferretti marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p /cpp-client/install/bin; \\
cp -f /cpp-client/tests/build/tests /cpp-client/install/bin; \
cd ..; \\
rm -fr /cpp-client/tests/build
''')
//
// Setup for test run.
//
environmentVariable 'DH_HOST', deephavenDocker.containerName.get()
environmentVariable 'DH_PORT', '8080'
}
containerDependencies.dependsOn = [deephavenDocker.healthyTask]
containerDependencies.finalizedBy = deephavenDocker.endTask
network = deephavenDocker.networkName.get()
parentContainers = [ Docker.registryTask(project, 'cpp-client-base') ]
entrypoint = ['/cpp-client/install/bin/cpp-tests-to-junit.sh', '/out/cpp-test.xml', '/out/cpp-test.log']
}
tasks.check.dependsOn(testCppClient)
13 changes: 13 additions & 0 deletions cpp-client/cpp-tests-to-junit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

if [ "$#" -ne 2 ]; then
echo "Usage: $0 out.xml out.log" 1>&2
exit 1
fi

/cpp-client/install/bin/tests --reporter XML --out "$1" 2>&1 | tee "$2"
246 changes: 0 additions & 246 deletions cpp-client/deephaven/client/build-dependencies.sh

This file was deleted.

Loading