Skip to content

Commit

Permalink
Modify tests to fail and exit on different response without timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
thevindu-w committed Aug 8, 2023
1 parent 0eec58c commit 6e726ad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
13 changes: 12 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,24 @@ RUN make install

ENV HOME="/home/ubuntu"
ENV JASMINEGRAPH_HOME="/home/ubuntu/software/jasminegraph"

RUN mkdir /home/ubuntu/software/jasminegraph
WORKDIR /home/ubuntu/software/jasminegraph

RUN pip install tensorflow==2.5.3
RUN pip install -U scikit-learn
COPY . .
COPY ./GraphSAGE ./GraphSAGE
RUN pip install -r ./GraphSAGE/requirements

COPY ./conf ./conf
COPY ./src ./src
COPY ./src_python ./src_python
COPY ./build.sh ./build.sh
COPY ./CMakeLists.txt ./CMakeLists.txt
COPY ./main.cpp ./main.cpp
COPY ./main.h ./main.h
COPY ./run-docker.sh ./run-docker.sh

RUN sh build.sh
ENTRYPOINT ["/home/ubuntu/software/jasminegraph/run-docker.sh"]
CMD ["bash"]
2 changes: 1 addition & 1 deletion test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while ! nc -zvn 127.0.0.1 7777 &>/dev/null; do
sleep .2
done

timeout 1800 python3 -u tests/integration/test.py |& tee "logs/${run_id}_test.txt"
timeout 600 python3 -u tests/integration/test.py |& tee "logs/${run_id}_test.txt"
exit_code="${PIPESTATUS[0]}"
rm -rf tests/integration/env
stop_and_remove_containers
Expand Down
30 changes: 16 additions & 14 deletions tests/integration/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,26 @@
DONE=b'done'
LINE_END=b'\r\n'

def recv_all(sock, n_bytes):
def expect_response(sock, expected):
global passedAll
buffer = bytearray()
read = 0
while read < n_bytes:
received = sock.recv(n_bytes - read)
expected_len = len(expected)
while read < expected_len:
received = sock.recv(expected_len - read)
received_len = len(received)
if received:
read += len(received)
if received != expected[read:read + received_len]:
buffer.extend(received)
data = bytes(buffer)
logging.warning(f'Output mismatch\nexpected : {expected}\nreceived : {data}')
passedAll = False
return False
read += received_len
buffer.extend(received)
return bytes(buffer)

def expect_response(sock, expected):
global passedAll
data = recv_all(sock, len(expected))
data = bytes(buffer)
print(data.decode('utf-8'), end='')
if data != expected:
logging.warning(f'Output mismatch\nexpected : {expected}\nreceived : {data}')
passedAll = False
return False
assert data == expected
return True

def send_and_expect_response(sock, testName, send, expected, exitOnFail=False):
Expand All @@ -60,7 +62,7 @@ def send_and_expect_response(sock, testName, send, expected, exitOnFail=False):
failedTests.append(testName)
if exitOnFail:
print()
logging.fatal('Failed some tests,', file=sys.stderr)
logging.fatal('Failed some tests,')
print(*failedTests, sep='\n', file=sys.stderr)
sys.exit(1)

Expand Down

0 comments on commit 6e726ad

Please sign in to comment.