Skip to content

UserNotes:joebwan

Joseph F. Berghof III edited this page May 9, 2017 · 63 revisions

A simple vpn/firewall troubleshooting case: send a ping from an external network to my device:

$ cat onepingonly 
#!cmd alpine bash
#!/bin/bash
ping -c 1 $MYHOST

$ cat onepingonly | ssh [email protected] :create onepingonly
Creating command... done

$ ssh [email protected] :env onepingonly set MYHOST=www.google.com
Setting MYHOST on onepingonly... done

$ ssh [email protected] onepingonly 
PING www.google.com (172.217.3.36): 56 data bytes
64 bytes from 172.217.3.36: seq=0 ttl=47 time=1.648 ms

--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.648/1.648/1.648 ms

Try connecting on a specific port:

$ cat connectonport 
#!cmd alpine bash
#!/bin/bash
telnet $MYHOST $PORT <<HEREDOC
quit
HEREDOC
echo "no errors for connectonport" && exit 0

$ cat connectonport | ssh [email protected] :create connectonport
Creating command... done

$ ssh [email protected] :env connectonport set MYHOST=www.google.com
Setting MYHOST on connectonport... done

$ ssh [email protected] :env connectonport set PORT=80
Setting PORT on connectonport... done

$ ssh [email protected] :env connectonport
PORT:         80
MYHOST:   www.google.com

$ ssh [email protected] connectonport 
no errors for connectonport

How long can my script live?

$ cat sandsofthehourglass 
#!cmd alpine bash
#!/bin/bash
count="0"
while [ "1" -gt 0 ] 
do
 sleep 1;
 count=$[$count+1]
 echo -n "$count "
done

$ cat sandsofthehourglass | ssh [email protected] :create sandsofthehourglass 
Creating command... done

$ ssh [email protected] sandsofthehourglass 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 28 29 maximum runtime exceded

Dev Locally (for mac)

I'm new to 'go' but they're all the same right?

### prep
$ GLIDERLABS=~/go/src/github.com/gliderlabs
$ mkdir -p $GLIDERLABS && cd $GLIDERLABS
### clone the project
$ git clone [email protected]:gliderlabs/cmd.git && cd cmd
### get go, glide, etc.
$ brew tap && brew bundle
### get the go libs required for cmd.io
$ glide install -v
### build to verify sanity
$ make clean && make build

NOTE: Be sure to clone the cmd.git directory under the expected ~/go/src/github.com/gliderlabs location - until I did that I was plagued by missing packages.


https://github.com/gliderlabs/cmd/wiki/UserNotes%3Achief has good high-level info on all of the various auth0, git hub token... etc. deps for setting up your environment.


Now I want to write a test for a solution that addresses issue #142.

Testing locally - where are the tests?

$ grep -r Test app/* cmd/* hacks/* lib/* pkg/* | sort
app/core/core_test.go:func TestCmdPull(t *testing.T) {
app/core/core_test.go:func TestHasAccess(t *testing.T) {
app/core/core_test.go:func TestMakeBuildCtx(t *testing.T) {
app/core/core_test.go:func TestParseSource(t *testing.T) {
app/store/dynamodb/cmd_test.go:func TestCmdBackend(t *testing.T) {
app/store/dynamodb/migrations_test.go:func TestAllMigrations(t *testing.T) {
app/store/dynamodb/migrations_test.go:func TestMigrateApply(t *testing.T) {
app/store/dynamodb/migrations_test.go:func TestSchemaV2(t *testing.T) {
app/store/dynamodb/token_test.go:func TestTokenBackend(t *testing.T) {
lib/crypto/crypto_test.go:func TestCrypto(t *testing.T) {

Minor edits to TestCmdBackend show that the issue is rooted in create.go.


No test covers create.go yet - I'll follow popular convention and it to app/builtin/builtin_test.go

Clone this wiki locally