Skip to content

Commit 416ab62

Browse files
committed
add python docker-compose test
fix python integ tests Signed-off-by: Shyam Jesal <s.jesalpura@gmail.com>
1 parent eb1dbb5 commit 416ab62

File tree

16 files changed

+193
-218
lines changed

16 files changed

+193
-218
lines changed

.github/workflows/xdt_docker_compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
env:
4444
KO_DOCKER_REPO: ${{ secrets.DOCKER_HUB_USERNAME }}
4545
run: |
46-
make docker-images-push
46+
make all-images-push
4747
4848
docker-compose-integ-test:
4949
name: Docker compose integ test
@@ -60,3 +60,5 @@ jobs:
6060
run: |
6161
cd ./user-functions
6262
docker-compose up --abort-on-container-exit --exit-code-from fx
63+
docker-compose -f docker-compose-python.yml up --abort-on-container-exit --exit-code-from fx
64+

.github/workflows/xdt_tests.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
test-type: [unit, integ, timeout, parallel-invoke, fan-in, fan-out, get-put]
27+
test-type: [unit, integ, parallel-invoke, fan-in, fan-out, get-put]
2828
steps:
2929
- name: Set up Go 1.x
3030
uses: actions/setup-go@v2
@@ -46,32 +46,37 @@ jobs:
4646
uses: golangci/golangci-lint-action@v2
4747
with:
4848
working-directory: sdk/golang
49-
args: --timeout 5m
49+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
5050
- name: Check dQP code
5151
if: ${{ always() }}
52-
env:
53-
DIR: queue-proxy/dQP
54-
run: cd $DIR && golangci-lint run --out-format=github-actions --path-prefix=$DIR --timeout 5m
52+
uses: golangci/golangci-lint-action@v2
53+
with:
54+
working-directory: queue-proxy/dQP
55+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
5556
- name: Check plotter code
5657
if: ${{ always() }}
57-
env:
58-
DIR: plotter
59-
run: cd $DIR && golangci-lint run --out-format=github-actions --path-prefix=$DIR --timeout 5m
58+
uses: golangci/golangci-lint-action@v2
59+
with:
60+
working-directory: plotter
61+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
6062
- name: Check user-functions/fx code
6163
if: ${{ always() }}
62-
env:
63-
DIR: user-functions/fx
64-
run: cd $DIR && golangci-lint run --out-format=github-actions --path-prefix=$DIR --timeout 5m
64+
uses: golangci/golangci-lint-action@v2
65+
with:
66+
working-directory: user-functions/fx
67+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
6568
- name: Check user-functions/gx code
6669
if: ${{ always() }}
67-
env:
68-
DIR: user-functions/gx
69-
run: cd $DIR && golangci-lint run --out-format=github-actions --path-prefix=$DIR --timeout 5m
70+
uses: golangci/golangci-lint-action@v2
71+
with:
72+
working-directory: user-functions/gx
73+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
7074
- name: Check user-functions/dQP code
7175
if: ${{ always() }}
72-
env:
73-
DIR: user-functions/dQP
74-
run: cd $DIR && golangci-lint run --out-format=github-actions --path-prefix=$DIR --timeout 5m
76+
uses: golangci/golangci-lint-action@v2
77+
with:
78+
working-directory: user-functions/dQP
79+
args: "--timeout 5m -e \"S1000: should use a simple channel send/receive instead of \\`select\\` with a single case\""
7580
Benchmark:
7681
name: Benchmark XDT
7782
runs-on: ubuntu-latest
@@ -98,7 +103,7 @@ jobs:
98103
strategy:
99104
fail-fast: false
100105
matrix:
101-
test-type: [ unit, integ, timeout, get-put]
106+
test-type: [integ, timeout, get-put]
102107
python-version: [3.7, 3.8, 3.9]
103108
steps:
104109
- name: Set up Python
@@ -113,7 +118,7 @@ jobs:
113118
run: sudo apt-get install psmisc
114119
- name: Check out code into the Go module directory
115120
uses: actions/checkout@v2
116-
- name: install environs package
117-
run: pip install environs --user
118121
- name: Run test
119-
run: make python-${{ matrix.test-type }}-test
122+
run: |
123+
cp proto/crossXDT/crossXDT.py.capnp ./sdk/python/crossXDT.py.capnp
124+
make python-${{ matrix.test-type }}-test

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM python:slim as pygx
2+
3+
RUN apt update && \
4+
apt install g++ make cmake -y && \
5+
pip install pycapnp grpcio && \
6+
apt remove g++ make cmake -y && \
7+
apt autoremove -y
8+
RUN pip install environs grpcio-tools
9+
WORKDIR /app
10+
COPY sdk/python/ ./
11+
COPY user-functions/gx/gx.py ./
12+
COPY ./proto/*/*.py ./
13+
COPY ./proto/crossXDT/crossXDT.py.capnp ./
14+
15+
ENTRYPOINT ["python3", "-u", "gx.py"]
16+
17+
FROM python:slim as pyfx
18+
19+
RUN apt update && \
20+
apt install g++ make cmake -y && \
21+
pip install pycapnp grpcio && \
22+
apt remove g++ make cmake -y && \
23+
apt autoremove -y
24+
RUN pip install environs grpcio-tools
25+
WORKDIR /app
26+
COPY sdk/python/ ./
27+
COPY user-functions/fx/fx.py ./
28+
COPY ./proto/*/*.py ./
29+
COPY ./proto/crossXDT/crossXDT.py.capnp ./
30+
31+
ENTRYPOINT ["python3", "-u", "fx.py"]

Makefile

Lines changed: 14 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -65,87 +65,26 @@ build_local:
6565
clean:
6666
rm -rf bins
6767

68-
unit-test: export ROUTING = Store&Forward
6968
unit-test:
7069
cd tests && go test unit_test.go $(GO_TEST_FLAGS)
7170

72-
integ-test_CT: export ROUTING = CutThrough
73-
integ-test_CT:
71+
integ-test:
7472
cd tests && go test ./integration_test.go -run TestSdk_InvokeWithXDT $(GO_TEST_FLAGS)
7573

76-
77-
integ-test_SF: export ROUTING = Store&Forward
78-
integ-test_SF:
79-
cd tests && go test ./integration_test.go -run TestSdk_InvokeWithXDT $(GO_TEST_FLAGS)
80-
81-
integ-test-noCopy_CT: export ROUTING = CutThrough
82-
integ-test-noCopy_CT: export NO_COPY = true
83-
integ-test-noCopy_CT:
84-
cd tests && go test ./integration_test.go -run TestSdk_InvokeWithXDTNoCopy $(GO_TEST_FLAGS)
85-
86-
87-
integ-test-noCopy_SF: export ROUTING = Store&Forward
88-
integ-test-noCopy_SF: export NO_COPY = true
89-
integ-test-noCopy_SF:
90-
cd tests && go test ./integration_test.go -run TestSdk_InvokeWithXDTNoCopy $(GO_TEST_FLAGS)
91-
92-
integ-test: integ-test_CT integ-test_SF
93-
integ-test-noCopy: integ-test-noCopy_CT integ-test-noCopy_SF
94-
95-
timeout-test_CT: export ROUTING = CutThrough
96-
timeout-test_CT:
97-
sleep 60
98-
cd tests && go test ./integration_test.go -run TestErr_DQPTimeout $(GO_TEST_FLAGS)
99-
100-
timeout-test_SF: export ROUTING = Store&Forward
101-
timeout-test_SF:
102-
sleep 60
103-
cd tests && go test ./integration_test.go -run TestErr_DQPTimeout $(GO_TEST_FLAGS)
104-
105-
timeout-test: timeout-test_SF timeout-test_CT
106-
107-
parallel-invoke-test_CT: export ROUTING = CutThrough
108-
parallel-invoke-test_CT:
109-
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 1 $(GO_TEST_FLAGS)
110-
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 2 $(GO_TEST_FLAGS)
111-
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 5 $(GO_TEST_FLAGS)
112-
113-
parallel-invoke-test_SF: export ROUTING = Store&Forward
114-
parallel-invoke-test_SF:
74+
parallel-invoke-test:
11575
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 1 $(GO_TEST_FLAGS)
11676
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 2 $(GO_TEST_FLAGS)
11777
cd tests && go test ./integration_test.go -run TestParallel_Invoke -concurrentCalls 5 $(GO_TEST_FLAGS)
11878

119-
parallel-invoke-test: parallel-invoke-test_SF parallel-invoke-test_CT
120-
fan-out-test: fan-out_SF fan-out_CT
121-
fan-in-test: fan-in_SF fan-in_CT
122-
123-
fan-out_SF: export ROUTING = Store&Forward
124-
fan-out_SF:
125-
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 1 $(GO_TEST_FLAGS)
126-
sleep 2
127-
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 2 $(GO_TEST_FLAGS)
128-
sleep 2
129-
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 5 $(GO_TEST_FLAGS)
130-
sleep 2
131-
fan-out_CT: export ROUTING = CutThrough
132-
fan-out_CT:
79+
fan-out-test:
13380
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 1 $(GO_TEST_FLAGS)
13481
sleep 2
13582
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 2 $(GO_TEST_FLAGS)
13683
sleep 2
13784
cd tests && go test ./integration_test.go -run TestParallel_FanOut -concurrentCalls 5 $(GO_TEST_FLAGS)
13885
sleep 2
13986

140-
fan-in_SF: export ROUTING = Store&Forward
141-
fan-in_SF:
142-
cd tests && go test ./integration_test.go -run TestParallel_FanIn -concurrentCalls 1 $(GO_TEST_FLAGS)
143-
sleep 2
144-
cd tests && go test ./integration_test.go -run TestParallel_FanIn -concurrentCalls 2 $(GO_TEST_FLAGS)
145-
sleep 2
146-
cd tests && go test ./integration_test.go -run TestParallel_FanIn -concurrentCalls 5 $(GO_TEST_FLAGS)
147-
fan-in_CT: export ROUTING = CutThrough
148-
fan-in_CT:
87+
fan-in-test:
14988
cd tests && go test ./integration_test.go -run TestParallel_FanIn -concurrentCalls 1 $(GO_TEST_FLAGS)
15089
sleep 2
15190
cd tests && go test ./integration_test.go -run TestParallel_FanIn -concurrentCalls 2 $(GO_TEST_FLAGS)
@@ -155,19 +94,10 @@ fan-in_CT:
15594
install_python_modules:
15695
pip install grpcio --user
15796
pip install grpcio-tools --user
97+
pip install pycapnp --user
98+
pip install environs --user
15899

159-
python-unit-test: export ROUTING = Store&Forward
160-
python-unit-test: install_python_modules
161-
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
162-
sleep 60
163-
cd sdk/python && python -m unittest -v test.UnitTest
164-
# kill the process bound to the given port.
165-
-fuser -k 50005/tcp
166-
167-
python-integ-test: install_python_modules python-integ-test_CT python-integ-test_SF
168-
169-
python-integ-test_CT: export ROUTING = CutThrough
170-
python-integ-test_CT:
100+
python-integ-test: install_python_modules
171101
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
172102
sleep 60
173103
cd sdk/python && python destination.py &
@@ -176,75 +106,31 @@ python-integ-test_CT:
176106
-fuser -k 50005/tcp
177107
-fuser -k 50007/tcp
178108

179-
python-integ-test_SF: export ROUTING = Store&Forward
180-
python-integ-test_SF:
181-
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
182-
sleep 60
183-
cd sdk/python && python destination.py &
184-
sleep 5
185-
cd sdk/python && python -m unittest -v test.IntegTest.test_Invoke_XDT
186-
-fuser -k 50005/tcp
187-
-fuser -k 50007/tcp
188-
189-
python-timeout-test: install_python_modules python-timeout-test_CT python-timeout-test_SF
190-
191-
python-timeout-test_CT: export ROUTING = CutThrough
192-
python-timeout-test_CT:
193-
cd tests && go test ./integration_test.go -run TestPython_SDKTimeout $(GO_TEST_FLAGS) &
194-
sleep 60
195-
cd sdk/python && python -m unittest -v test.IntegTest.test_Timeout
196-
-fuser -k 50005/tcp
197-
198-
python-timeout-test_SF: export ROUTING = Store&Forward
199-
python-timeout-test_SF:
109+
python-timeout-test: install_python_modules
200110
cd tests && go test ./integration_test.go -run TestPython_SDKTimeout $(GO_TEST_FLAGS) &
201111
sleep 60
202112
cd sdk/python && python -m unittest -v test.IntegTest.test_Timeout
203113
-fuser -k 50005/tcp
204114

205115
python-get-put-test: install_python_modules
206-
python-get-put-test: export ROUTING = Store&Forward
207-
python-get-put-test:
208116
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
209117
sleep 60
210118
cd sdk/python && python -m unittest -v test.IntegTest.test_GetPut
211119
-fuser -k 50005/tcp
212120
-fuser -k 50007/tcp
213121

214-
python-broadcast-get-put-test: export ROUTING = Store&Forward
215-
python-broadcast-get-put-test:
122+
python-broadcast-get-put-test: install_python_modules
216123
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
217124
sleep 60
218125
cd sdk/python && python -m unittest -v test.IntegTest.test_Broadcast_GetPut
219126
-fuser -k 50005/tcp
220127
-fuser -k 50007/tcp
221128

222-
python-noCopy-get-put-test: export ROUTING = Store&Forward
223-
python-noCopy-get-put-test: export NO_COPY = true
224-
python-noCopy-get-put-test:
225-
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
226-
sleep 60
227-
cd sdk/python && python -m unittest -v test.IntegTest.test_GetPut
228-
-fuser -k 50005/tcp
229-
-fuser -k 50006/tcp
230-
-fuser -k 50007/tcp
129+
all-images-push:
130+
cd user-functions/fx && ko publish ./ -B
131+
cd user-functions/dQP && ko publish ./ -B
132+
cd user-functions/gx && ko publish ./ -B
231133

232-
python-noCopy-broadcast-get-put-test: export ROUTING = Store&Forward
233-
python-noCopy-broadcast-get-put-test: export NO_COPY = true
234-
python-noCopy-broadcast-get-put-test:
235-
cd tests && go test ./integration_test.go -run TestPython_SDK $(GO_TEST_FLAGS) &
236-
sleep 60
237-
cd sdk/python && python -m unittest -v test.IntegTest.test_Broadcast_GetPut
238-
-fuser -k 50005/tcp
239-
-fuser -k 50006/tcp
240-
-fuser -k 50007/tcp
241-
242-
docker-images-push:
243-
cd user-functions/fx && ko publish ./ -B --tags=capnp
244-
cd user-functions/dQP && ko publish ./ -B --tags=capnp
245-
cd user-functions/gx && ko publish ./ -B --tags=capnp
246-
247-
python-images-push:
248134
DOCKER_BUILDKIT=1 docker build \
249135
-t vhiveease/pyfx:latest \
250136
--target pyfx \
@@ -257,14 +143,12 @@ python-images-push:
257143
$(ROOT)
258144
docker push vhiveease/pygx:latest
259145
docker push vhiveease/pyfx:latest
260-
benchmark-XDT: export ROUTING = CutThrough
146+
261147
benchmark-XDT:
262148
cd tests && go test ./integration_test.go -run TestBenchmark_XDT -v
263149

264-
get-put-test: export ROUTING = Store&Forward
265150
get-put-test:
266151
cd tests && go test ./integration_test.go -run TestGet_Put $(GO_TEST_FLAGS)
267152

268-
broadcast-test: export ROUTING = Store&Forward
269153
broadcast-test:
270154
cd tests && go test ./integration_test.go -run TestBroadcast_GetPut $(GO_TEST_FLAGS)

queue-proxy/dQP/dQP.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ type crossXDTServer struct {
4242
}
4343

4444
// ServeBroadcastData is a gRPC server to serve data to the DstFn
45-
func (s crossXDTServer) ServeBroadcastData(ctx context.Context, req crossXDT.StreamData_serveBroadcastData) error {
45+
func (s crossXDTServer) ServeBroadcastData(_ context.Context, _ crossXDT.StreamData_serveBroadcastData) error {
4646
log.Fatal("[dqp] No op. Should not have reached here")
4747
return nil
4848
}
4949

5050
// ServeData is a gRPC server to serve data to the DstFn
51-
func (s crossXDTServer) ServeData(ctx context.Context, req crossXDT.StreamData_serveData) error {
51+
func (s crossXDTServer) ServeData(_ context.Context, req crossXDT.StreamData_serveData) error {
5252

5353
res, err := req.AllocResults() // allocate the results struct
5454
if err != nil {
@@ -93,7 +93,12 @@ func PullDataFromSrc(ctx context.Context) error {
9393
if err != nil {
9494
log.Fatal(err)
9595
}
96-
defer conn.Close()
96+
defer func(conn net.Conn) {
97+
err := conn.Close()
98+
if err != nil {
99+
log.Fatal(err)
100+
}
101+
}(conn)
97102
capconn := rpc.NewConn(rpc.NewStreamTransport(conn), nil)
98103
client := crossXDT.StreamData(capconn.Bootstrap(ctx))
99104

@@ -110,7 +115,10 @@ func PullDataFromSrc(ctx context.Context) error {
110115
// the RPC call and its results.
111116
// do release
112117
f, _ := client.ServeData(ctx, func(ps crossXDT.StreamData_serveData_Params) error {
113-
ps.SetKey(key)
118+
err := ps.SetKey(key)
119+
if err != nil {
120+
log.Fatal(err)
121+
}
114122
return nil
115123
})
116124

@@ -158,7 +166,10 @@ func StartServer(config utils.Config) {
158166
// Block until the connection terminates.
159167
select {
160168
case <-capnpconn.Done():
161-
capnpconn.Close()
169+
err := capnpconn.Close()
170+
if err != nil {
171+
log.Fatal(err)
172+
}
162173
return
163174
}
164175
}()

0 commit comments

Comments
 (0)