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 Jun 12, 2023
1 parent 6571bcc commit 6ba677d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 42 deletions.
61 changes: 23 additions & 38 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,37 @@ on:
pull_request:

jobs:
snapshot:
e2e:
runs-on: ubuntu-latest
services:
unbound:
image: klutchell/unbound:latest
ports:
- 5053:5053/tcp
- 5053:5053/udp
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --config ./.goreleaser.ci.yml --clean --snapshot
- name: Copy .ini files
run: cp targets.ini rbls.ini ./dist/dnsbl_exporter_linux_amd64_v1
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dnsbl_exporter
path: dist/dnsbl_exporter_linux_amd64_v1

integration:
runs-on: ubuntu-latest
needs:
- snapshot
services:
unbound:
image: klutchell/unbound:latest
ports:
- 5053:5053
- 5053:5053/udp
steps:
- uses: actions/download-artifact@v3
- run: cp targets.ini rbls.ini ./dist/dnsbl_exporter_linux_amd64_v1
- uses: JarvusInnovations/background-action@v1
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
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
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 6ba677d

Please sign in to comment.