Skip to content

Commit 934696e

Browse files
Test Userpadelsbach
authored andcommitted
Add the ls-remote git test
1 parent 2e5b5a8 commit 934696e

File tree

1 file changed

+113
-4
lines changed

1 file changed

+113
-4
lines changed

scripts/test-git-ssh-dr.sh

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ echo ""
2828
# Configuration
2929
KEY_TYPES=("rsa" "ecdsa" "ed25519" "chacha20-poly1305")
3030
ITERATIONS=10
31+
GITHUB_ITERATIONS=5
3132
TEST_BASE_DIR="/tmp/git-wolfprovider-test"
3233
SSH_TEST_ENABLED=${SSH_TEST_ENABLED:-true}
3334

@@ -274,6 +275,109 @@ verify_ssh_setup() {
274275
rm -f "$ssh_log" "$ssh_error_log"
275276
}
276277

278+
# Function to test GitHub SSH connectivity
279+
test_github_ssh_connectivity() {
280+
echo "=== Testing GitHub SSH Connectivity ==="
281+
echo "Testing lightweight git operation to GitHub via SSH"
282+
echo ""
283+
284+
local github_repo="git@github.com:wolfSSL/wolfProvider.git"
285+
local test_iterations=${1:-1} # Default to 1 iteration for GitHub test
286+
local success_count=0
287+
local failure_count=0
288+
local timing_log="/tmp/github-ssh-timing.log"
289+
local error_log="/tmp/github-ssh-errors.log"
290+
291+
# Clear previous logs
292+
> "$timing_log"
293+
> "$error_log"
294+
295+
echo "Testing git ls-remote to $github_repo"
296+
echo "This tests SSH connectivity and crypto without heavy operations"
297+
echo ""
298+
299+
# Ensure we're in a valid directory for git operations
300+
local original_dir=$(pwd)
301+
cd /tmp || cd / || cd "$HOME" || true
302+
echo "Current directory: $(pwd)"
303+
echo ""
304+
305+
for ((attempt=1; attempt<=test_iterations; attempt++)); do
306+
echo "--- GitHub SSH Test $attempt ---"
307+
308+
local start_time=$(date +%s.%N)
309+
local status="UNKNOWN"
310+
311+
echo "Attempting git ls-remote to GitHub..."
312+
313+
# Test the lightweight git operation
314+
if timeout 30 git ls-remote "$github_repo" HEAD 2>>"$error_log" | head -1 >/dev/null; then
315+
local end_time=$(date +%s.%N)
316+
local duration=$(echo "$end_time - $start_time" | bc -l)
317+
318+
if [ "${WOLFPROV_FORCE_FAIL}" = "1" ]; then
319+
status="SUCCESS"
320+
((success_count++))
321+
print_status "SUCCESS" "GitHub SSH operation successful (with WPFF=1"
322+
check_force_fail
323+
else
324+
status="SUCCESS"
325+
((success_count++))
326+
print_status "SUCCESS" "GitHub SSH operation successful"
327+
fi
328+
329+
echo " GitHub SSH test: $status ($(printf "%.6f" "$duration")s)"
330+
echo "$attempt,$status,$duration" >> "$timing_log"
331+
else
332+
local end_time=$(date +%s.%N)
333+
local duration=$(echo "$end_time - $start_time" | bc -l)
334+
335+
if [ "${WOLFPROV_FORCE_FAIL}" = "1" ]; then
336+
status="EXPECTED_FAIL"
337+
print_status "SUCCESS" "GitHub SSH operation failed as expected (WPFF=1)"
338+
else
339+
status="FAILURE"
340+
((failure_count++))
341+
print_status "FAILURE" "GitHub SSH operation failed on attempt $attempt"
342+
fi
343+
344+
echo " GitHub SSH test: $status ($(printf "%.6f" "$duration")s)"
345+
echo "$attempt,$status,$duration" >> "$timing_log"
346+
fi
347+
348+
echo ""
349+
done
350+
351+
# Summary
352+
echo "=== GITHUB SSH TEST SUMMARY ==="
353+
echo "Total operations: $((success_count + failure_count))"
354+
echo "Successful operations: $success_count"
355+
echo "Failed operations: $failure_count"
356+
if [ $((success_count + failure_count)) -gt 0 ]; then
357+
local failure_rate=$((failure_count * 100 / (success_count + failure_count)))
358+
echo "Failure rate: ${failure_rate}%"
359+
else
360+
echo "Failure rate: 0%"
361+
fi
362+
echo ""
363+
echo "GitHub SSH timing data saved to: $timing_log"
364+
echo "GitHub SSH error log saved to: $error_log"
365+
echo ""
366+
367+
# Show error log summary if there were errors
368+
if [ -s "$error_log" ]; then
369+
echo "=== GITHUB SSH ERROR LOG SUMMARY ==="
370+
head -20 "$error_log"
371+
if [ $(wc -l < "$error_log") -gt 20 ]; then
372+
echo "... (showing first 20 lines, see $error_log for full log)"
373+
fi
374+
echo ""
375+
fi
376+
377+
# Return to original directory
378+
cd "$original_dir" 2>/dev/null || true
379+
}
380+
277381
# Function to test git operations
278382
test_git_operations() {
279383
local key_type=$1
@@ -823,10 +927,6 @@ test_ssh_key_operations() {
823927
if [ $failure_count -gt 0 ]; then
824928
local failure_rate=$(echo "scale=2; $failure_count * 100 / ($success_count + failure_count)" | bc -l)
825929
echo "Failure rate: ${failure_rate}%"
826-
if [ "$key_type" = "ed25519" ] && [ $failure_count -gt 2 ]; then
827-
print_status "WARNING" "High failure rate detected for ED25519 keys - potential intermittent issue!"
828-
echo "This confirms the suspected ED25519 intermittent failures!"
829-
fi
830930
else
831931
echo "Failure rate: 0%"
832932
fi
@@ -870,6 +970,7 @@ show_usage() {
870970
echo " -s, --ssh Enable SSH key testing (default: enabled)"
871971
echo " -n, --no-ssh Disable SSH key testing"
872972
echo " -i, --iterations N Number of iterations per test (default: 10)"
973+
echo " -g, --github-iterations N Number of GitHub SSH test iterations (default: 5)"
873974
echo " -k, --key-types TYPES Comma-separated key types (default: rsa,ecdsa,ed25519)"
874975
echo " -l, --log-lines N Maximum git log lines to show (default: 5)"
875976
echo ""
@@ -885,6 +986,7 @@ show_usage() {
885986
echo " $0 --verbose # Run with verbose debug output"
886987
echo " $0 --no-ssh # Skip SSH key testing"
887988
echo " $0 --iterations 20 # Run 20 iterations per test"
989+
echo " $0 --github-iterations 10 # Run 10 GitHub SSH tests"
888990
echo " $0 --key-types rsa,ed25519 # Test only RSA and ED25519 keys"
889991
echo " WOLFPROV_FORCE_FAIL=1 $0 # Test with force fail to verify wolfProvider usage"
890992
echo ""
@@ -918,6 +1020,10 @@ parse_args() {
9181020
ITERATIONS="$2"
9191021
shift 2
9201022
;;
1023+
-g|--github-iterations)
1024+
GITHUB_ITERATIONS="$2"
1025+
shift 2
1026+
;;
9211027
-k|--key-types)
9221028
IFS=',' read -ra KEY_TYPES <<< "$2"
9231029
shift 2
@@ -983,6 +1089,9 @@ main() {
9831089
echo ""
9841090
fi
9851091

1092+
# Test GitHub SSH connectivity
1093+
test_github_ssh_connectivity "$GITHUB_ITERATIONS"
1094+
9861095
# Final verification
9871096
echo "=== Final wolfProvider Verification ==="
9881097
if openssl list -providers | grep -q "wolfSSL Provider"; then

0 commit comments

Comments
 (0)