Skip to content

Commit

Permalink
Add Travis debugging instructions
Browse files Browse the repository at this point in the history
In case someone else wants to debug Travis builds
  • Loading branch information
JanKanis committed Jun 1, 2017
1 parent f1d7f86 commit cc2386f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
25 changes: 25 additions & 0 deletions travis_debug/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Debugging Travis
================

Debugging Travis tests is not very straightforward. They run your tests in their own environment, but as far as I know they don't make an image of that environment available for local debugging. These tools you to set up a connection with the test environment when the tests run, and debug the tests.

The script consists of two steps: first it creates an SSH connection to your machine, then it forwards a port from your machine to the test VM. The second step is to have a bash shell listening on that port in the test VM, giving you shell access to the live test environment. This uses the `socat` command which is installed by default on Travis. (If not install it with apt.)

To debug Travis:
Setup:
- Add the public key in this directory to your ~/.ssh/authorized_keys, or better yet, create a new user and add the key to its authorized_keys. NB: as the private key of this is publicly visible on Github, anyone can now connect to your account.
- Make sure there is a port to your machine (or whatever machine you want to use to receive the connection) visible from the internet
- Adjust the parameters in travis_debug/shellserver.sh to reflect the address and port that Travis should connect to, and optionally the ports that are forwarded
- Adjust .travis.yml to include a `sh -c travis_debug/shellserver.sh` command so that it will run the shellserver.
- Push the commit to github and let Travis build the tests

Debug:
- Wait for travis to connect to your machine
- The SSH connection will forward a port (by default 34567) to the Travis test machine
- execute `nc localhost 34567` on your local machine. This will connect to Travis and show a bash prompt
- Debug
- Exit the connection for Travis to continue with the rest of the tests

To debug the JVM process, adjust the shellserver.sh to background itself and adjust the Grails test run to include a `--debug-jvm` flag. By default the debugging port 5005 is also forwarded, so you can connect to it from your debugger.

Important! When you are done, remove the public key from your authorized_keys file, otherwise anyone on the internet who finds the test key on Github will be able to log in to your machine!
27 changes: 27 additions & 0 deletions travis_debug/id_rsa_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA4ivqzSoH1Hr80GTYjYaPqweV75bMt2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9siWkvuhiuB8cYjwqtrVYxBYHqhes7M/U6Y3ahqA8pz
/wknfpjzEqsSeHCY1u1hTvcoGMadmlxgBlG3ti1jEaXdBtbNyaIhh6g3qo4ukHGu
3OtsIMWKh6Uny2cFU4WDhQKBgF7MiaPjupdss/Ffwgb1vDAzBXy/Vp8Jq1lhTmAH
i5rcJDTrtW1m7rlhT7/50x1iiR4tQGek1cbewwAzaSpmQlks7NIv3bGc7/iQKoZ2
12X4sI5cfVAYskGMZmoEmtXvrxlqMHg48APuWpMVIeNOnbS0h2UMU6MTzTAexfoL
mtw1AoGAcH9UiqGtcXq4fw8maUEaG6RWakqE7MeMP8abqgx46CZBbpTxO92q2sQW
YyZvmcz9ywPM/ZqNAsjnnle65EiiknrA+tZw8IFv8lOTRPAVasIWYoW5o7RURf3G
Mf4CjVgKwiFzb8RLhP7Qi4CPWPbWRnoLsUIM+0Ft6DHxBSlBepk=
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions travis_debug/id_rsa_test.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiK+rNKgfUevzQZNiNho+rB5Xvlsy3ZO5fAV0CMkUrCEGbPJ9zObwur3j4XMoIY3i8MZk2IwhK7koHONYgRXwl8+UpQnA9soyQKQDTkje7EJNRT+kC2kERuFy3XEnmXE9VP3gLPv1u54Z6aOHH/7DkXNsXkzeCYpKwApZKSfGcEsLNHv/H7x3U/d44UwYx9YfuQ1B0grT+vP5dwJ4mJkqi6WyCN/GvuRIkrsdV33nudz4yXCrnH5VaDf5lAE8TFIVHdDAVXdw6ZZHRT58ggPb/s+knGlZ9mHSBb5Sef6nvVvEKyPIGopHGXWqk+4A5Ivg8z/LNNzVaRbKFNarugQqx jan-test@jan-hyve
15 changes: 15 additions & 0 deletions travis_debug/shellserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

LOCAL_USER=jan
LOCAL_ADDRESS=office.thehyve.net
LOCAL_PORT=34122
FORWARD_PORT1=34567
FORWARD_PORT2=5005

ls debug
chmod go-rwx travis_debug/id_rsa_test
ssh -N -o StrictHostKeyChecking=no -i ./travis_debug/id_rsa_test "$LOCAL_USER:$LOCAL_ADDRESS" -p $LOCAL_PORT -R $FORWARD_PORT1:localhost:$FORWARD_PORT1 -R $FORWARD_PORT2:localhost:$FORWARD_PORT2 &
SSH_PID=$!
socat TCP-LISTEN:$FORWARD_PORT1 EXEC:"bash -li",stderr
kill $SSH_PID

0 comments on commit cc2386f

Please sign in to comment.