Skip to content

Commit

Permalink
Add go 1.17 as the baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
freeformz committed Aug 8, 2022
1 parent 5ed168c commit 77ebf52
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 5 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/signalsciences/sigsci-module-golang

go 1.18
go 1.17

require (
github.com/philhofer/fwd v1.0.0 // indirect
github.com/signalsciences/tlstext v1.2.0
github.com/tinylib/msgp v1.1.0
)

require github.com/philhofer/fwd v1.0.0 // indirect
5 changes: 5 additions & 0 deletions scripts/test-golang117/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM golang:1.17-alpine

# we will mount the current directory here
VOLUME [ "/go/src/github.com/signalsciences/sigsci-module-golang" ]
WORKDIR /go/src/github.com/signalsciences/sigsci-module-golang
15 changes: 15 additions & 0 deletions scripts/test-golang117/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"

services:
# this defines our webserver uses our sigsci-module
# we only define it so it is attached to our fake network
# it will be run a few times with different options manually
#
# The volumes spec is a bit weird.. this script is run in scripts/test but
# needs stuff in ../../examples. Consider moving.
web:
volumes:
- ../..:/go/src/github.com/signalsciences/sigsci-module-golang
command: [ "go", "run", "/go/src/github.com/signalsciences/sigsci-module-golang/examples/mtest/main.go" ]
environment:
- DEBUG=0
58 changes: 58 additions & 0 deletions scripts/test-golang117/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3"
networks:
mtest:

services:
# this defines our webserver uses our sigsci-module
# we only define it so it is attached to our fake network
# it will be run a few times with different options manually
#
#
web:
build:
context: .
dockerfile: Dockerfile
expose:
- "8085"
networks:
- mtest
depends_on:
- agent

# agent
agent:
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/sigsci-agent:latest
command: [ "-debug-log-web-inputs", "2", "-rpc-address", "9090", "-debug-rpc-test-harness", "-debug-standalone", "3" ]
expose:
- "9090"
- "12345"
networks:
- mtest

# punching bag
punchingbag:
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
networks:
- mtest
expose:
- "8086"
command: [ "/bin/punchingbag", "-addr", ":8086" ]

# mtest
#
mtest:
image: 803688608479.dkr.ecr.us-west-2.amazonaws.com/local-dev/module-testing:latest
networks:
- mtest
depends_on:
- web
- agent
- punchingbag
environment:
- DISABLE_HTTP_OPTIONS=1
- DISABLE_NOCOOKIE=1
- MTEST_BASEURL=web:8085
- MTEST_AGENT=agent:12345
- "MTEST_RUN_TEST_BLOCK_VIA_REDIRECT=true"
command: [ "/bin/wait-for", "web:8085", "--", "/bin/mtest", "-test.v" ]

41 changes: 41 additions & 0 deletions scripts/test-golang117/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e

DOCKERCOMPOSE="docker-compose"

# run at end no matter what
cleanup() {
echo "shutting down"
# capture log output
$DOCKERCOMPOSE logs --no-color agent >& agent.log
$DOCKERCOMPOSE logs --no-color web >& web.log
$DOCKERCOMPOSE logs --no-color mtest >& mtest.log
$DOCKERCOMPOSE logs --no-color punchingbag >& punchingbag.log

# delete everything
$DOCKERCOMPOSE down

# show output of module testing
cat mtest.log
}
trap cleanup 0 1 2 3 6

set -x

# attempt to clean up any leftover junk
$DOCKERCOMPOSE down

$DOCKERCOMPOSE pull --ignore-pull-failures

# start everything, run tests
#
# --no-color --> safe for ci
# --build --> alway build test server/module container
# --abort-on-container-exit --> without this, the other servers keep the process running
# --exit-code-from mtest --> make exit code be the result of module test
#
# > /dev/null --> output of all servers is mixed together and ugly
# we get the individual logs at end
#
$DOCKERCOMPOSE up --no-color --build --abort-on-container-exit --exit-code-from mtest > /dev/null

3 changes: 0 additions & 3 deletions scripts/test-golang118/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ $DOCKERCOMPOSE pull --ignore-pull-failures
# > /dev/null --> output of all servers is mixed together and ugly
# we get the individual logs at end
#
if [ -d "goroot" ]; then
rm -rf goroot
fi
$DOCKERCOMPOSE up --no-color --build --abort-on-container-exit --exit-code-from mtest > /dev/null

1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

set -ex

(cd ./scripts/test-golang117 && ./test.sh)
(cd ./scripts/test-golang118 && ./test.sh)
(cd ./scripts/test-golang119 && ./test.sh)

0 comments on commit 77ebf52

Please sign in to comment.