1+ #! /usr/bin/env bats
2+
3+ load helpers
4+
5+ @test " splitfdstream json-rpc-server and apply-splitfdstream" {
6+ case " $STORAGE_DRIVER " in
7+ overlay* )
8+ ;;
9+ * )
10+ skip " driver $STORAGE_DRIVER does not support splitfdstream"
11+ ;;
12+ esac
13+
14+ # Create and populate a test layer
15+ populate
16+
17+ # Start the JSON-RPC server in the background
18+ run storage json-rpc-server &
19+ SERVER_PID=$!
20+ # Give the server time to start
21+ sleep 2
22+
23+ # Get the socket path from runroot
24+ local runroot=` storage status 2>&1 | awk ' /^Run Root:/{print $3}' `
25+ local socket_path=" $runroot /json-rpc.sock"
26+
27+ # Wait for socket to be created (max 10 seconds)
28+ local count=0
29+ while [[ ! -S " $socket_path " && $count -lt 50 ]]; do
30+ sleep 0.2
31+ count=$(( count + 1 ))
32+ done
33+
34+ # Check that the socket exists
35+ [ -S " $socket_path " ]
36+
37+ # Create a new layer using apply-splitfdstream
38+ # This should connect to our JSON-RPC server and fetch the layer
39+ run storage apply-splitfdstream --socket " $socket_path " " $lowerlayer "
40+ echo " apply-splitfdstream output: $output "
41+ [ " $status " -eq 0 ]
42+ [ " $output " != " " ]
43+
44+ applied_layer=" $output "
45+
46+ # Verify the layer was created
47+ run storage layers
48+ [ " $status " -eq 0 ]
49+ [[ " $output " =~ " $applied_layer " ]]
50+
51+ # Check that we can mount the applied layer
52+ run storage mount " $applied_layer "
53+ [ " $status " -eq 0 ]
54+ [ " $output " != " " ]
55+ local applied_mount=" $output "
56+
57+ # Verify some expected content exists (from populate function)
58+ [ -f " $applied_mount /layer1file1" ]
59+ [ -f " $applied_mount /layer1file2" ]
60+ [ -d " $applied_mount /layerdir1" ]
61+
62+ # Unmount the layer
63+ run storage unmount " $applied_layer "
64+ [ " $status " -eq 0 ]
65+
66+ # Clean up - kill the server
67+ if [[ -n " $SERVER_PID " ]]; then
68+ kill $SERVER_PID 2> /dev/null || true
69+ wait $SERVER_PID 2> /dev/null || true
70+ fi
71+ }
72+
73+ @test " splitfdstream server socket path uses runroot" {
74+ case " $STORAGE_DRIVER " in
75+ overlay* )
76+ ;;
77+ * )
78+ skip " driver $STORAGE_DRIVER does not support splitfdstream"
79+ ;;
80+ esac
81+
82+ # Start the JSON-RPC server in the background
83+ run storage json-rpc-server &
84+ SERVER_PID=$!
85+ # Give the server time to start
86+ sleep 2
87+
88+ # Get the expected socket path from runroot
89+ local runroot=` storage status 2>&1 | awk ' /^Run Root:/{print $3}' `
90+ local expected_socket=" $runroot /json-rpc.sock"
91+
92+ # Verify the socket is created in the correct location
93+ [ -S " $expected_socket " ]
94+
95+ # Clean up - kill the server
96+ if [[ -n " $SERVER_PID " ]]; then
97+ kill $SERVER_PID 2> /dev/null || true
98+ wait $SERVER_PID 2> /dev/null || true
99+ fi
100+ }
0 commit comments