-
Notifications
You must be signed in to change notification settings - Fork 4
UserNotes:joebwan
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
I'm new to 'go' but they're all the same right?
### pre clone prep
$ GLIDERLABS=~/go/src/github.com/gliderlabs
$ mkdir -p $GLIDERLABS && cd $GLIDERLABS
### clone the project
$ git clone [email protected]:gliderlabs/cmd.git && cd cmd
### these were required just once before make-dev
$ brew bundle
$ make test-env
$ make setup
### build to check 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.
UserNotes:chief 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.
Don't forget to read these notes from golang.org
$ 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 - cobra_test.go has good examples for testing commands that I'll borrow from.
Until then I can use make dev
to run functional tests locally:
$ make dev
docker-compose -f dev/services.yml up -d
dev_dynamodb_1 is up-to-date
./dev/deps.sh
comlab dev
make: comlab: No such file or directory
make: *** [dev] Error 1
... Fix this error by including GOPATH/bin in your PATH:
$ export PATH="$PATH:$GOPATH/bin"
$ make dev
docker-compose -f dev/services.yml up -d
dev_dynamodb_1 is up-to-date
./dev/deps.sh
comlab dev
2017/05/10 08:53:35 New build: 13.091301775s
08:53:35.331 [docker] using env client
08:53:36.032 [dynamodb] skipping unsupported dynamodb-local operation operation=setTableVersion
08:53:36.087 [dynamodb] applying migrations to dynamodb-local
08:53:36.170 [dynamodb] migrating items=0
08:53:36.170 [dynamodb] skipping unsupported dynamodb-local operation operation=setTableVersion
08:53:36.170 [web] listening on 127.0.0.1:8080
08:53:36.172 [ssh] listening on 127.0.0.1:2223
Issue #153 lets you get past these checks:
09:23:05.044 [console] check
09:23:05.044 [cmd] first time login sess.user=joebwan sess.remoteaddr=127.0.0.1:51386 sess.command=:ls cmd.user= cmd.name= dur=0
09:23:17.569 [console] check
09:23:17.570 [cmd] first time login sess.user=joebwan sess.remoteaddr=127.0.0.1:51390 sess.command=:ls cmd.user= cmd.name= dur=0
The .env.example file says to rename it to .env. My clone has a .env directory that had to be removed first. Afterward I was able to run builtin commands locally without issue:
$ rm -rf .env && cp .env.example .env
$ grep -v "^#" .env
export ACCESS_ENABLED=false
export CONSOLE_ENABLED=false
$ make dev ### then proceed with ssh localhost... :create, etc.
New to go? I found this very useful Effective Go