feat(test): enhance test_local.sh with better cleanup
- Replace `curl` with `wget` for Vault health check. - Ensure cleanup of temporary files and directories.
This commit is contained in:
parent
fbc8e689d4
commit
c662dfbfd8
|
@ -41,6 +41,7 @@ fi
|
|||
echo "Starting Vault server in non-dev mode..."
|
||||
|
||||
# Create temporary config file
|
||||
rm -fr /tmp/vault-test/data /tmp/vault-test/config
|
||||
mkdir -p /tmp/vault-test/data /tmp/vault-test/config
|
||||
|
||||
cat > /tmp/vault-test/config/vault.hcl << EOF
|
||||
|
@ -70,16 +71,16 @@ sleep 5
|
|||
|
||||
# Check if Vault is up and running
|
||||
for i in {1..10}; do
|
||||
if curl -fs -m 1 http://127.0.0.1:8200/v1/sys/health?standbyok=true\&sealedok=true\&uninitok=true > /dev/null 2>&1; then
|
||||
if wget -q -O- --no-check-certificate http://127.0.0.1:8200/v1/sys/health?standbyok=true\\&sealedok=true\\&uninitok=true > /dev/null 2>&1; then
|
||||
echo "Vault is up and running!"
|
||||
break
|
||||
fi
|
||||
|
||||
|
||||
if [ $i -eq 10 ]; then
|
||||
echo "Timed out waiting for Vault to become available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Vault is unavailable - sleeping (attempt $i/10)"
|
||||
sleep 2
|
||||
done
|
||||
|
@ -94,11 +95,11 @@ if [ -f "vault-credentials.txt" ]; then
|
|||
# Extract the unseal keys for demonstration
|
||||
UNSEAL_KEYS=$(grep "Key" vault-credentials.txt | head -n 3 | awk '{print $3}')
|
||||
ROOT_TOKEN=$(grep "Root Token" vault-credentials.txt | awk '{print $3}')
|
||||
|
||||
|
||||
echo "Root Token: $ROOT_TOKEN"
|
||||
echo "First 3 Unseal Keys (needed for threshold):"
|
||||
echo "$UNSEAL_KEYS"
|
||||
|
||||
|
||||
# Clean up temporary files
|
||||
rm -f vault-credentials.txt
|
||||
else
|
||||
|
@ -115,4 +116,4 @@ rm "$VAULT_PID_FILE"
|
|||
rm -rf /tmp/vault-test
|
||||
rm -f ./vault_server.log
|
||||
|
||||
echo "All cleaned up. Test successful!"
|
||||
echo "All cleaned up. Test successful!"
|
||||
|
|
Loading…
Reference in a new issue