Merge branch 'script_improvement'
This commit is contained in:
commit
df3045e424
5
Makefile
5
Makefile
@ -42,6 +42,11 @@ dockertest:
|
|||||||
> $(MAKE) -C docker/organic_test
|
> $(MAKE) -C docker/organic_test
|
||||||
> docker run --rm -i -t -v "$$(readlink -f ./):/.source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry -w / organic-test sh -c "cp -r /.source /source && cd /source && cargo test --no-fail-fast --lib --test test_loader"
|
> docker run --rm -i -t -v "$$(readlink -f ./):/.source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry -w / organic-test sh -c "cp -r /.source /source && cd /source && cargo test --no-fail-fast --lib --test test_loader"
|
||||||
|
|
||||||
|
.PHONY: dockerclean
|
||||||
|
dockerclean:
|
||||||
|
# Delete volumes created for running the tests in docker. This does not touch anything related to the jaeger docker container.
|
||||||
|
> docker volume rm cargo-cache rust-cache
|
||||||
|
|
||||||
.PHONY: integrationtest
|
.PHONY: integrationtest
|
||||||
integrationtest:
|
integrationtest:
|
||||||
> cargo test --no-fail-fast --test test_loader -- --test-threads $(TESTJOBS)
|
> cargo test --no-fail-fast --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
56
scripts/run_docker_compare.bash
Executable file
56
scripts/run_docker_compare.bash
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: ${SHELL:="NO"} # or YES to launch a shell instead of running the test
|
||||||
|
: ${TRACE:="NO"} # or YES to send traces to jaeger
|
||||||
|
: ${BACKTRACE:="NO"} # or YES to print a rust backtrace when panicking
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local org_file="$($REALPATH "$1")"
|
||||||
|
build_container
|
||||||
|
launch_container "$org_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch_container {
|
||||||
|
local org_file="$1"
|
||||||
|
local additional_flags=()
|
||||||
|
local additional_args=()
|
||||||
|
|
||||||
|
local init_script=$(cat <<EOF
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo run -- /input.org
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$SHELL" != "YES" ]; then
|
||||||
|
additional_args+=(sh -c "$init_script")
|
||||||
|
else
|
||||||
|
additional_flags+=(-i -t)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TRACE" = "YES" ]; then
|
||||||
|
# We use the host network so it can talk to jaeger hosted at 127.0.0.1
|
||||||
|
additional_flags+=(--network=host --env RUST_LOG=debug)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BACKTRACE" = "YES" ]; then
|
||||||
|
additional_flags+=(--env RUST_BACKTRACE=full)
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run "${additional_flags[@]}" --rm -v "${org_file}:/input.org:ro" -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test "${additional_args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
@ -4,17 +4,33 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
REALPATH=$(command -v uu-realpath || command -v realpath)
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
samples_dir=$(readlink -f "$DIR/../org_mode_samples")
|
function main {
|
||||||
|
local test_names=$(get_test_names "${@}")
|
||||||
|
build_container
|
||||||
|
|
||||||
|
local test
|
||||||
|
while read test; do
|
||||||
|
launch_container "$test"
|
||||||
|
done<<<"$test_names"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
function get_test_names {
|
function get_test_names {
|
||||||
|
local test_file
|
||||||
|
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
|
||||||
for test_file in "$@"
|
for test_file in "$@"
|
||||||
do
|
do
|
||||||
if [ -e "$test_file" ]; then
|
if [ -e "$test_file" ]; then
|
||||||
test_file_full_path=$(readlink -f "$test_file")
|
local test_file_full_path=$($REALPATH "$test_file")
|
||||||
relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
||||||
without_extension="${relative_to_samples%.org}"
|
local without_extension="${relative_to_samples%.org}"
|
||||||
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
||||||
else
|
else
|
||||||
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
||||||
@ -22,10 +38,20 @@ function get_test_names {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_test_names "$@" | while read test; do
|
function launch_container {
|
||||||
(
|
local test="$1"
|
||||||
cd "$DIR/../"
|
local additional_args=()
|
||||||
make -C docker/organic_test
|
|
||||||
docker run --rm -v "$(readlink -f ./):/.source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry -w / organic-test sh -c "cp -r /.source /source && cd /source && cargo test --no-fail-fast --lib --test test_loader \"$test\" -- --show-output"
|
local init_script=$(cat <<EOF
|
||||||
)
|
set -euo pipefail
|
||||||
done
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo test --no-fail-fast --lib --test test_loader "$test" -- --show-output
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
docker run --rm -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test sh -c "$init_script"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
|
@ -4,17 +4,27 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
REALPATH=$(command -v uu-realpath || command -v realpath)
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
|
||||||
samples_dir=$(readlink -f "$DIR/../org_mode_samples")
|
function main {
|
||||||
|
local test_names=$(get_test_names "${@}")
|
||||||
|
|
||||||
|
local test
|
||||||
|
while read test; do
|
||||||
|
cargo test --no-fail-fast --test test_loader "$test" -- --show-output
|
||||||
|
done<<<"$test_names"
|
||||||
|
}
|
||||||
|
|
||||||
function get_test_names {
|
function get_test_names {
|
||||||
|
local test_file
|
||||||
|
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
|
||||||
for test_file in "$@"
|
for test_file in "$@"
|
||||||
do
|
do
|
||||||
if [ -e "$test_file" ]; then
|
if [ -e "$test_file" ]; then
|
||||||
test_file_full_path=$(readlink -f "$test_file")
|
local test_file_full_path=$($REALPATH "$test_file")
|
||||||
relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
||||||
without_extension="${relative_to_samples%.org}"
|
local without_extension="${relative_to_samples%.org}"
|
||||||
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
||||||
else
|
else
|
||||||
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
||||||
@ -22,6 +32,4 @@ function get_test_names {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_test_names "$@" | while read test; do
|
main "${@}"
|
||||||
(cd "$DIR/../" && cargo test --no-fail-fast --test test_loader "$test" -- --show-output)
|
|
||||||
done
|
|
||||||
|
@ -15,7 +15,8 @@ pub fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
|
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
|
||||||
let exporter = opentelemetry_otlp::new_exporter()
|
let exporter = opentelemetry_otlp::new_exporter()
|
||||||
.tonic()
|
.tonic()
|
||||||
.with_endpoint("http://localhost:4317/v1/traces");
|
// Using "localhost" is broken inside the docker container when tracing
|
||||||
|
.with_endpoint("http://127.0.0.1:4317/v1/traces");
|
||||||
|
|
||||||
let tracer = opentelemetry_otlp::new_pipeline()
|
let tracer = opentelemetry_otlp::new_pipeline()
|
||||||
.tracing()
|
.tracing()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user