Skip to content

Commit

Permalink
Fix: integration test
Browse files Browse the repository at this point in the history
- uses an action to start the service
- puts all assertions into wait-for
- set explicit timeouts
- puts everything in one job (to avoid upload/download)
  • Loading branch information
till committed Nov 14, 2023
1 parent e88b79f commit 666b693
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
snapshot:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -38,19 +38,31 @@ jobs:
unbound:
image: klutchell/unbound:latest
ports:
- 5053:5053
- 5053:5053/tcp
- 5053:5053/udp
steps:
- uses: actions/download-artifact@v3
- uses: actions/checkout@v3
with:
name: dnsbl_exporter
- name: Allow running exporter
run: chmod +x ./dnsbl-exporter
- name: Start dnsbl_exporter
run: ./dnsbl-exporter --config.dns-resolver=0.0.0.0:5053 &
- name: Test "/" exists
run: curl -I http://127.0.0.1:9211/
- name: Test "/metrics" exists
run: curl -I http://127.0.0.1:9211/metrics
- name: Test "/metrics" with targets
run: curl -i http://127.0.0.1:9211/metrics
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: false
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --config ./.goreleaser.ci.yml --clean --snapshot
- run: cp targets.ini rbls.ini ./dist/dnsbl_exporter_linux_amd64_v1
- uses: JarvusInnovations/background-action@v1
with:
run: |
ls -lah && ./dnsbl-exporter --log.debug --config.dns-resolver=localhost:5053 &
wait-on: |
http-get://localhost:9211/
http-get://localhost:9211/metrics
http-get://localhost:9211/prober?target=github.com
tail: true # true = stderr,stdout
log-output-resume: stderr
wait-for: 1m
log-output: stderr,stdout
working-directory: ./dist/dnsbl_exporter_linux_amd64_v1
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func NewApp(name string, version string) DNSBLApp {
func (a *DNSBLApp) Bootstrap() {
a.App.Action = func(ctx *cli.Context) error {
// setup logging
fmt.Println("VERSION: " + appVersion)
handler := &slog.HandlerOptions{}
var writer io.Writer

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require github.com/prometheus/client_golang v1.17.0

require (
github.com/Luzilla/godnsbl v1.0.0
github.com/foxcpp/go-mockdns v1.0.0
github.com/miekg/dns v1.1.56
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
Expand Down
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down Expand Up @@ -49,14 +50,26 @@ golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
Expand Down
6 changes: 3 additions & 3 deletions pkg/dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func TestNew(t *testing.T) {
addr string
err bool
}{
{"0.0.0.0", false}, // assert the port gets added
{"0.0.0.0:53", false}, // standard input
{"0.0.0.0", false}, // assert the port gets added
{"0.0.0.0:53", false}, // standard input
{"unbound:5353", false}, // tests
} {
_, err := dns.New(new(x.Client), tc.addr, tests.CreateTestLogger(t))
assert.NoError(t, err, tc.addr)
}

}

0 comments on commit 666b693

Please sign in to comment.