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

chore(compiler): fix broken retry for flaky tests #632

Merged
merged 1 commit into from
Dec 18, 2023
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
6 changes: 6 additions & 0 deletions .github/workflows/compiler_build_and_test_cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
runs-on: ${{ github.event.inputs.runner_name }}
if: ${{ !cancelled() }}
steps:

- name: Instance configuration used
run: |
echo "IDs: ${{ inputs.instance_id }}"
Expand Down Expand Up @@ -142,6 +143,11 @@ jobs:
mkdir -p /tmp/concrete_compiler/gpu_tests/
make MINIMAL_TESTS=${{ env.MINIMAL_TESTS }} DATAFLOW_EXECUTION_ENABLED=ON CCACHE=ON Python3_EXECUTABLE=$PYTHON_EXEC BUILD_DIR=/build run-tests run-end-to-end-dataflow-tests
chmod -R ugo+rwx /tmp/KeySetCache
- name: Analyze logs
run: |
cd build/gtest-parallel-logs/passed
ls -1 | xargs grep -H "WARNING RETRY" | sed -e "s/.log.*//g" | uniq -c | sed -re "s/ *([0-9]*) (.*)/::warning ::Test \2 retried \1 times/g" | cat
# - name: Archive python package
# uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions compilers/concrete-compiler/compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ GTEST_PARALLEL_CMD=
GTEST_PARALLEL_SEPARATOR=
else
GTEST_PARALLEL_PY=./gtest-parallel/gtest-parallel
GTEST_PARALLEL_CMD=$(Python3_EXECUTABLE) $(GTEST_PARALLEL_PY)
GTEST_PARALLEL_CMD=$(Python3_EXECUTABLE) $(GTEST_PARALLEL_PY) -d $(BUILD_DIR)
GTEST_PARALLEL_SEPARATOR=--
$(GTEST_PARALLEL_PY):
git clone https://github.com/google/gtest-parallel.git
Expand Down Expand Up @@ -299,7 +299,7 @@ run-end-to-end-tests: $(GTEST_PARALLEL_PY) build-end-to-end-tests generate-cpu-t
$(foreach optimizer_strategy,$(OPTIMIZATION_STRATEGY_TO_TEST), $(foreach security,$(SECURITY_TO_TEST), \
$(GTEST_PARALLEL_CMD) $(BUILD_DIR)/tools/concretelang/tests/end_to_end_tests/end_to_end_test \
$(GTEST_PARALLEL_SEPARATOR) --backend=cpu --security-level=$(security) \
--optimizer-strategy=$(optimizer_strategy) --retry-failing-tests=1 $(FIXTURE_CPU_DIR)/*.yaml || exit $$?;))
--optimizer-strategy=$(optimizer_strategy) --retry-failing-tests=5 $(FIXTURE_CPU_DIR)/*.yaml || exit $$?;))

### end-to-end-tests GPU

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstdint>
#include <filesystem>
#include <gtest/gtest.h>
#include <llvm/Support/raw_ostream.h>
#include <regex>
#include <type_traits>

Expand Down Expand Up @@ -55,25 +56,41 @@ class EndToEndTest : public ::testing::Test {
}

void testOnce() {

// We try for a a number of times
for (auto tests_rep = 0; tests_rep <= retryFailingTests; tests_rep++) {
// We execute the circuit.
auto maybeRes = testCircuit->call(args);
ASSERT_OUTCOME_HAS_VALUE(maybeRes);
auto result = maybeRes.value();

/* Check result */
/* Check results */
bool allgood = true;
for (size_t i = 0; i < desc.outputs.size(); i++) {
auto maybeErr = checkResult(desc.outputs[i], result[i]);
if (maybeErr && tests_rep < 2) {
if (maybeErr) {
allgood = false;
llvm::errs() << "/!\\ WARNING RETRY TEST: " << maybeErr << "\n";
llvm::consumeError(std::move(maybeErr));
ASSERT_OUTCOME_HAS_VALUE(
testCircuit->generateKeyset(tests_rep + 1, tests_rep + 1));
break;
} else {
ASSERT_LLVM_ERROR(std::move(maybeErr));
}
}

// If OK we return
if (allgood) {
return;
}

// Otherwise we reset the keyset
llvm::errs() << "Regenerating keyset with seed: ";
llvm::errs() << tests_rep + 1;
llvm::errs() << "\n";
ASSERT_OUTCOME_HAS_VALUE(
testCircuit->generateKeyset(tests_rep + 1, tests_rep + 1));
}

// If all attempts fail, we return an error.
ASSERT_TRUE(false) << "Test failed after multiple attempts";
}

void testErrorRate() {
Expand Down
Loading