Skip to content

Commit

Permalink
e2e_tests: improve logging for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pahaz committed May 12, 2023
1 parent 3c2502d commit 978bc32
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Docker compose up databases and ssh-server
run: cd e2e_tests && docker-compose up -d
run: |
cd e2e_tests && docker-compose up -d
docker exec openssh-server chmod 600 /etc/ssh/ssh_host_ecdsa_key
docker exec openssh-server chmod 600 /etc/ssh/ssh_host_ed25519_key
docker exec openssh-server chmod 600 /etc/ssh/ssh_host_rsa_key
docker exec openssh-server chmod 600 /etc/ssh/ssh_host_dsa_key
- name: Install dependencies
run: |
uname -a
Expand All @@ -28,12 +34,36 @@ jobs:
${{ matrix.python }} get-pip.py
${{ matrix.python }} -m pip install --upgrade pip
${{ matrix.python }} -m pip install .
${{ matrix.python }} -m pip install psycopg2-binary pymysql pymongo
${{ matrix.python }} -m pip install psycopg2-binary>=2.9.6 pymysql>=1.0.3 pymongo>=4.3.3
chmod 600 ./e2e_tests/ssh-server-config/ssh_host_rsa_key
ssh -o "StrictHostKeyChecking=no" linuxserver@127.0.0.1 -p 2223 -i ./e2e_tests/ssh-server-config/ssh_host_rsa_key -v "uname -a"
# cd e2e_tests && docker-compose logs ssh; cd ..
# cd e2e_tests && docker-compose exec ssh cat /config/logs/openssh/current; cd ..
chmod 600 ./e2e_tests/ssh-server-config/ssh_host_rsa_key
# ssh -o "StrictHostKeyChecking=no" linuxserver@127.0.0.1 -p 2223 -i ./e2e_tests/ssh-server-config/ssh_host_rsa_key -v "uname -a"
# docker exec openssh-server tail -f /config/logs/openssh/current
- name: Run db tests ${{ matrix.python }}
run: ${{ matrix.python }} e2e_tests/run_docker_e2e_db_tests.py

- name: Run hungs tests ${{ matrix.python }}
run: timeout 10s ${{ matrix.python }} e2e_tests/run_docker_e2e_hangs_tests.py

- name: Collect openssh-server logs from docker container
if: failure()
run: docker exec -it openssh-server cat /config/logs/openssh/current > openssh-server.log

- name: Collect docker stdout logs
if: failure()
uses: jwalton/gh-docker-logs@v1
with:
dest: './docker-logs'

- name: Upload log artifact on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: logs
path: |
e2e_tests/*.log
./docker-logs
*.log
retention-days: 30
2 changes: 1 addition & 1 deletion e2e_tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- PASSWORD_ACCESS=false
- USER_NAME=linuxserver
volumes:
- ./ssh-server-config:/config/ssh_host_keys:ro
- ./ssh-server-config:/config/ssh_host_keys
ports:
- "127.0.0.1:2223:2222"
networks:
Expand Down
2 changes: 2 additions & 0 deletions e2e_tests/run_docker_e2e_db_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
sshtunnel.DEFAULT_LOGLEVEL = 1
logging.basicConfig(
format='%(asctime)s| %(levelname)-4.3s|%(threadName)10.9s/%(lineno)04d@%(module)-10.9s| %(message)s', level=1)
logger = logging.root

SSH_SERVER_ADDRESS = ('127.0.0.1', 2223)
SSH_SERVER_USERNAME = 'linuxserver'
Expand Down Expand Up @@ -142,6 +143,7 @@ def create_tunnel():
SSH_SERVER_REMOTE_SIDE_ADDRESS_PG, SSH_SERVER_REMOTE_SIDE_ADDRESS_MYSQL,
SSH_SERVER_REMOTE_SIDE_ADDRESS_MONGO,
],
logger=logger,
)
return tunnel

Expand Down

0 comments on commit 978bc32

Please sign in to comment.