forked from kentik/terraform-provider-kentik-cloudexport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (32 loc) · 1.83 KB
/
Makefile
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
HOSTNAME = kentik
NAMESPACE = automation
NAME = kentik-cloudexport
BINARY = terraform-provider-${NAME}
VERSION := $(shell echo `git tag --list 'v*' | tail -1 | cut -d v -f 2`)
OS_ARCH := $(shell printf "%s_%s" `go env GOHOSTOS` `go env GOHOSTARCH`)
# apiserver address for the provider under test to talk to (for testing purposes)
APISERVER_ADDR=localhost:9955
default: install
build:
go build -o ${BINARY}
install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
test:
# build localhost_apiserver for the provider under test to talk to
go build github.com/kentik/community_sdk_golang/apiv6/localhost_apiserver
# run localhost_apiserver; serve predefined data from json file
./localhost_apiserver -addr ${APISERVER_ADDR} -cloudexport internal/provider/CloudExportTestData.json &
# give the server some warm up time
sleep 1
# run tests:
# - set KTAPI_URL to our localhost_apiserver url - otherwise the provider will try to connect to live kentik server
# - set KTAPI_AUTH_EMAIL and KTAPI_AUTH_TOKEN to dummy values - they are required by provider, but not actually used by localhost_apiserver
# - set no test caching (-count=1) - beside the provider itself, the tests also depend on the used localhost_apiserver and test data
KTAPI_URL="http://${APISERVER_ADDR}" KTAPI_AUTH_EMAIL="[email protected]" KTAPI_AUTH_TOKEN="dummy" \
go test ./... $(TESTARGS) -run="." -timeout=5m -count=1 || (pkill -f localhost_apiserver && exit 1) # stop server on error
# finally, stop the server
pkill -f localhost_apiserver
testacc:
echo "Currently no acceptance tests that run against live apiserver are available. You can run tests against local apiserver with: make test"
# TF_ACC=1 go test ./... $(TESTARGS) -run "." -timeout 5m