<commit_before>#!/bin/bash

docker-compose up -d consul app > /dev/null 2>&1
APP_ID="$(docker-compose ps -q app)"
sleep 6
NUM_ZOMBIES=$(docker exec $APP_ID ps -o stat,ppid,pid,comm | awk '
BEGIN { count=0 }
$1 ~ /^Z/ && $2 ~ /1/ { count++ }
END { print count }
')
if [ $NUM_ZOMBIES -gt 1 ]; then
  echo "Number of zombies > 1: $NUM_ZOMBIES" >&2
  docker exec $APP_ID ps -o stat,ppid,pid,args
  docker logs $APP_ID
  exit 1
fi
exit 0
<commit_msg>Avoid racing reparent in zombie-reaping integration test<commit_after>#!/bin/bash
# Test to verify that we're correctly reaping zombies.
# At any given time we may have up to 1 zombie parented to PID1 (it has been
# reparented but not yet reaped) and 1 zombie not yet parented to PID1.
# We can't test any more precisely than this without racing the kernel
# reparenting mechanism.

docker-compose up -d consul app > /dev/null 2>&1
APP_ID="$(docker-compose ps -q app)"
sleep 6

PTREE=$(docker exec $APP_ID ps -o stat,ppid,pid,comm)
REPARENTED_ZOMBIES=$(echo $PTREE | awk '
BEGIN { count=0 }
$1 ~ /^Z/ && $2 ~ /^1$/ { count++ }
END { print count }
')

TOTAL_ZOMBIES=$(echo $PTREE | awk '
BEGIN { count=0 }
$1 ~ /^Z/ { count++ }
END { print count }
')

if [ $REPARENTED_ZOMBIES -gt 1 ] || [ $TOTAL_ZOMBIES -gt 2 ]; then
  echo "More than permitted number of zombies." >&2
  echo $PTREE >&2
  docker logs $APP_ID
  exit 1
fi
exit 0

{'fraction_non_alphanumeric': 0.13682678311499272, 'fraction_numerical': 0.022561863173216887, 'mean_word_length': 3.67687074829932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '247159', 'n_tokens_mistral': 567, 'n_tokens_neox': 524, 'n_words': 186}