Skip to content

Commit

Permalink
chore(compiler): fix broken retry for flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aPere3 committed Dec 15, 2023
1 parent ddd85c4 commit 738b882
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
7 changes: 7 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,12 @@ 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
echo "/!\ WARNING RETRY TEST: Different results ..." > testing.log
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)/end_to_end_fhe.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,40 @@ 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

0 comments on commit 738b882

Please sign in to comment.