diff --git a/.luacheckrc b/.luacheckrc index 62aeb1703e..cc11828494 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,2 +1,3 @@ std = 'ngx_lua' globals = {'_'} +exclude_files = {'./rootfs/etc/nginx/lua/test/*.lua'} diff --git a/.travis.yml b/.travis.yml index 2a44103bfb..80d475b907 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ env: - KUBERNETES_VERSION=v1.9.4 - DOCKER=docker - TRAVIS_TIMEOUT=240 + - BUSTED_VERSION=2.0.rc12 - secure: LIS2XpZufWTcJ53jiRsSZy2Gi1EUJ1XmLg7z3f2ZHeMnyG2Jhk3GW4vod1FNru+PY4PWgddLdCdIl+jqOYXndFlbdAWF3/Oy5fEkYLXdYV7tdlHcPWDkqNFrfiyZ4guChN+b2Nk6FqU7o5fsZAIR7VAbgqNRF5XMo9Mhn/vhDCQRcnbXy7uq7JTrYUkqDbQoyYvT6b480GCY5gags1zp/xZfPDNZEe936o8i5IPTyiykRyNOXN/AH6kd3pR5e1xYgcvJ9KpSVPghcwFE7kJ4fOVMRhRG5ML+IyML+xD0jX43EMNoqRKZ/HS42kIMCInFbJEcxVde7DPNBZ7Y3GAqh7HO6qrE70Dn3ha6DID6zCoH2ArW39BxG4zempjn2VxYoMRGREyZszWQb++dwGoHmo5FHt6zvIrYBG0dA0H8ja9VkZkjFwtYTGHU1ooPzUfJK4O4VBayV8LqZibyZQR+GrmyQc0aagUY7J/fe4A2PJyI4DbkeZ7GX1ELj0ciDz4urQSzUc8l/T3aU3X+FuJItjgYtMLPmqcjA5uifDCtutE8Z9L2gSpanqUdvLSOozuxPho/KNl+2YlF7fXqPW3LnRf5mHD+NbOff306pvKlHJOb2Vmth+HBQ1XDzt/Cy5+sfwS3E0Vmh6UTq/NtkUXxwH10BDMF7FMVlQ4zdHQvyZ0= - secure: rKDoy9IYYYy0fYBs4+9mwuBVq/TcxfFwMfE0ywYWhUUdgzrUYSJAwpoe/96EQ4YmESUefwC2nDNq4G3XzJKYOWf83PaIveb9Z//zmMrCQXjDuDBDLpwV3sXSh7evXiVDohJz4ogBCeMRUCMKYsyKBM9yWfa/iu+yI92dbphpK9peOKW6yBc0uspJlln4swN3GS2WT9LVuPY2Azv9U2UqrXufOPDKG/qEb/Vrn4yZ2lR/50r2k45e9nSvDoByvr10V8ubM5Zc0iP0vBuAUVRdByv6N53Q4gaBGapY6SxhIjIPC/h0rNnuT9EXp7MWaPT5FmBxLt9wnyleT9QhZJnFyaBYqFgcz/DKifYQkryY4M5dLMo/Rt3yATyAy8Y0df1TOoV2dKdqwOOwQ8bXB1wDfyrGxmQj9HY4Ffnphx3wPE1a+Sjuh+S5Epm7XJbPx5pZJqNO2hd4sTbk0Xp3gpPbihny2r/jtNwHl0wpFCfOM68RNrsVRlIwG3UhzbZvblbQ/M/mmWCdgzINjt07I2SGCJxfKG0e98Q49SKUoDoOgQTTRDqTC9IgOEDxyfAkT0Vr6BtlP88Nsgnf6kmboyigBrRAiaDQGTxn3SP6LnQI3CeopaRDYvFZe/rTwPXE9XlKoTn9FTWnAqF3MuWaLslDcDKYEh7OaYJjF01piu6g4Nc= - secure: qCCk7HIEnOph2q8mQ55MKS2MM0RSpCbwDZx7csF6NHRr5khVRyhg2r8jN0iUW+peoAChRYV91YOnl5v8K49O38IEQpzgADixiLu4VPFcYddwKrtTJF+AGvFGzBKtqDksRuUTqfJ+PdxGnO9iNkS0MFzF1ImSQGp1QfkegC8wSrZF8svAedjNOC9XV+FX0tTyj14eTSy3KUYafIyuhjG+nSjhlQxAI1Tq4EClcTZOzAIYNhkeZ4Gcu1nHPQMTQT5AQgRAhG8i7rNKfghqX8OccKNWUhvFB3eOFFf4dlb02IA2L/b8Fl4NnZpyAWcwF+CBZrzQoFARBE1xIvGfaNa9i6noyrpJ/g+0g7EyKgTsixaQInBmZ7ECVpQkSO+/3leWfwssZs7H4cqy2HeXH6dkE+JUeI0WDjYV7YwdVNoFm8wXszDu+MCQTGXJ4moO4F/jMvY4w+tNo8ISJiNZ/+uQaIlPaijCdwu9FPvAY59lJXORGVHd1Fq2pKkGkNjQVHtu9BH7ufO1fX5a6FtYbclMwm7w9BE5jnJNoP+y8Yq0bVwbGONSUFTyMWCbSCYDsyUPzmaZLkFpZPbnJua5y9c1x0/OYijNizBW0UVQDZauortsTPzwYlZ1J7TywVtpUEoI8CGuUb2QEWh+O/IwrogtiKvFtPrrYakIwV/lr7mO294= @@ -42,6 +43,11 @@ jobs: - go get github.com/golang/lint/golint - go get -u github.com/jteeuwen/go-bindata/... - make verify-all + - stage: Lua Unit Test + before_script: + - rootfs/etc/nginx/lua/test/up.sh + script: + - make lua-test - stage: Coverage before_script: # start minikube diff --git a/Makefile b/Makefile index 5419955841..f0789ea6d5 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,8 @@ ALL_ARCH = amd64 arm arm64 ppc64le s390x QEMUVERSION=v2.9.1-1 +BUSTED_ARGS=-v --pattern=_test + IMGNAME = nginx-ingress-controller IMAGE = $(REGISTRY)/$(IMGNAME) MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) @@ -151,6 +153,10 @@ verify-all: test: @go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PKG}/... | grep -v vendor | grep -v '/test/e2e') +.PHONY: lua-test +lua-test: + @busted $(BUSTED_ARGS) ./rootfs/etc/nginx/lua/test; + .PHONY: e2e-image e2e-image: sub-container-amd64 TAG=$(TAG) IMAGE=$(MULTI_ARCH_IMG) docker tag $(IMAGE):$(TAG) $(IMAGE):test diff --git a/docs/development.md b/docs/development.md index 4cc91f6c0b..836c2c2d35 100644 --- a/docs/development.md +++ b/docs/development.md @@ -99,6 +99,16 @@ $ cd $GOPATH/src/k8s.io/ingress-nginx $ make e2e-test ``` +To run unit-tests for lua code locally, run: + +```console +$ cd $GOPATH/src/k8s.io/ingress-nginx +$ ./rootfs/etc/nginx/lua/test/up.sh +$ make lua-test +``` + +Lua tests are located in `$GOPATH/src/k8s.io/ingress-nginx/rootfs/etc/nginx/lua/test`. When creating a new test file it must follow the naming convention `_test.lua` or it will be ignored. + ## Releasing All Makefiles will produce a release binary, as shown above. To publish this diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh index 3f5cfb72e8..ff7a0eef16 100755 --- a/hack/verify-golint.sh +++ b/hack/verify-golint.sh @@ -26,7 +26,7 @@ GOLINT=${GOLINT:-"golint"} PACKAGES=($(go list ./... | grep -v /vendor/)) bad_files=() for package in "${PACKAGES[@]}"; do - out=$("${GOLINT}" -min_confidence=0.9 "${package}" | grep -v 'should not use dot imports' || :) + out=$("${GOLINT}" -min_confidence=0.9 "${package}" | grep -v -E '(should not use dot imports|internal/file/bindata.go)' || :) if [[ -n "${out}" ]]; then bad_files+=("${out}") fi diff --git a/internal/file/bindata.go b/internal/file/bindata.go index 4ff966a4fe..fee9ece4a5 100644 --- a/internal/file/bindata.go +++ b/internal/file/bindata.go @@ -4,6 +4,8 @@ // rootfs/etc/nginx/lua/balancer.lua // rootfs/etc/nginx/lua/configuration.lua // rootfs/etc/nginx/lua/sticky.lua +// rootfs/etc/nginx/lua/test/balancer_test.lua +// rootfs/etc/nginx/lua/test/up.sh // rootfs/etc/nginx/lua/util.lua // rootfs/etc/nginx/nginx.conf // rootfs/etc/nginx/template/nginx.tmpl @@ -156,6 +158,46 @@ func etcNginxLuaStickyLua() (*asset, error) { return a, nil } +var _etcNginxLuaTestBalancer_testLua = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4a\x49\x2d\x4e\x2e\xca\x4c\x4a\xd5\x50\x8a\x4e\x4a\xcc\x49\xcc\x4b\x4e\x2d\x8a\x2f\x49\x2d\x2e\x89\x55\xd2\x51\x48\x2b\xcd\x4b\x2e\xc9\xcc\xcf\xd3\xd0\xe4\x52\x50\xd0\xd5\x55\x08\xf1\x77\xf1\xb7\x52\x28\x2f\xca\x2c\x49\x55\x00\xa9\x29\x56\xe0\x4a\xcd\x4b\xd1\xe4\x02\x04\x00\x00\xff\xff\xa5\x22\x75\xe9\x44\x00\x00\x00") + +func etcNginxLuaTestBalancer_testLuaBytes() ([]byte, error) { + return bindataRead( + _etcNginxLuaTestBalancer_testLua, + "etc/nginx/lua/test/balancer_test.lua", + ) +} + +func etcNginxLuaTestBalancer_testLua() (*asset, error) { + bytes, err := etcNginxLuaTestBalancer_testLuaBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "etc/nginx/lua/test/balancer_test.lua", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _etcNginxLuaTestUpSh = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x92\x41\x6f\x9b\x4c\x10\x86\xef\xfb\x2b\xde\xcf\x7c\x87\x56\xb2\x21\xcd\xa9\xaa\x4f\x24\x71\x55\x94\x08\x4b\xc6\x49\x94\x53\xb5\xc0\x00\xa3\xac\x77\x37\xbb\x4b\x88\xa5\xfe\xf8\x6a\x1d\x3b\x6d\x5a\x95\x23\xf3\xbc\xc3\x33\x33\x24\xff\x65\xa3\x77\x59\xcd\x3a\x23\xfd\x8c\x5a\xfa\x41\x88\x04\x97\xc6\xee\x1d\xf7\x43\xc0\xf9\xd9\xa7\xcf\xd8\x0e\x84\xeb\xb1\x26\xa7\x29\x90\x47\x3e\x86\xc1\x38\x9f\x8a\x44\x24\xb8\xe1\x86\xb4\xa7\x16\xa3\x6e\xc9\x21\x0c\x84\xdc\xca\x66\xa0\x53\x65\x8e\x3b\x72\x9e\x8d\xc6\x79\x7a\x86\x0f\x11\x98\x1d\x4b\xb3\x8f\x4b\x91\x60\x6f\x46\xec\xe4\x1e\xda\x04\x8c\x9e\x10\x06\xf6\xe8\x58\x11\xe8\xa5\x21\x1b\xc0\x1a\x8d\xd9\x59\xc5\x52\x37\x84\x89\xc3\x70\xf8\xcc\xb1\x49\x2a\x12\x3c\x1c\x5b\x98\x3a\x48\xd6\x90\x68\x8c\xdd\xc3\x74\xbf\x73\x90\xe1\x20\x1c\x9f\x21\x04\xfb\x25\xcb\xa6\x69\x4a\xe5\x41\x36\x35\xae\xcf\xd4\x2b\xe8\xb3\x9b\xe2\x72\x55\x56\xab\xc5\x79\x7a\x76\x88\xdc\x6a\x45\xde\xc3\xd1\xd3\xc8\x8e\x5a\xd4\x7b\x48\x6b\x15\x37\xb2\x56\x04\x25\x27\x18\x07\xd9\x3b\xa2\x16\xc1\x44\xdf\xc9\x71\x60\xdd\xcf\xe1\x4d\x17\x26\xe9\x48\x24\x68\xd9\x07\xc7\xf5\x18\xde\x2d\xeb\x64\xc7\xfe\x1d\x60\x34\xa4\xc6\x2c\xaf\x50\x54\x33\x5c\xe4\x55\x51\xcd\x45\x82\xfb\x62\xfb\x6d\x7d\xbb\xc5\x7d\xbe\xd9\xe4\xe5\xb6\x58\x55\x58\x6f\x70\xb9\x2e\xaf\x8a\x6d\xb1\x2e\x2b\xac\xbf\x22\x2f\x1f\x70\x5d\x94\x57\x73\x10\x87\x81\x1c\xe8\xc5\xba\xe8\x6f\x1c\x38\xae\x91\xda\xb8\xb3\x8a\xe8\x9d\x40\x67\x5e\x85\xbc\xa5\x86\x3b\x6e\xa0\xa4\xee\x47\xd9\x13\x7a\xf3\x4c\x4e\xb3\xee\x61\xc9\xed\xd8\xc7\x63\x7a\x48\xdd\x8a\x04\x8a\x77\x1c\x64\x38\xbc\xf9\x6b\xa8\x54\x08\xee\xa0\x46\xe9\x4c\xf3\xe8\xa1\xd8\x07\x2c\x16\xd6\xb8\x86\x54\xbc\x53\x3d\xfa\x38\xeb\xff\x17\xb7\xd5\x76\x75\xf5\xfd\x6e\xb5\xa9\x8a\x75\x89\x1f\xe8\x1d\x59\x2c\x9e\x30\x63\xed\x83\x54\x8a\xda\xd9\x32\x36\xd6\x02\xa0\x66\x30\xa7\xa4\x54\x8e\x64\xbb\xc7\x1b\x36\x87\x7f\x64\x6b\xa3\xeb\x52\x90\xf2\xf4\x47\x20\xfe\x63\x9d\x19\x75\x3b\x3f\x65\x22\xfa\xcc\xf2\xcd\x32\x4d\xd3\xa5\x00\xfc\xd8\x9a\x5f\xe6\x47\xf6\x1f\xc2\x4b\xd1\xb1\xf8\x19\x00\x00\xff\xff\x2f\x96\xf5\x17\x4a\x03\x00\x00") + +func etcNginxLuaTestUpShBytes() ([]byte, error) { + return bindataRead( + _etcNginxLuaTestUpSh, + "etc/nginx/lua/test/up.sh", + ) +} + +func etcNginxLuaTestUpSh() (*asset, error) { + bytes, err := etcNginxLuaTestUpShBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "etc/nginx/lua/test/up.sh", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _etcNginxLuaUtilLua = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x55\x4b\x6f\xa4\x46\x10\xbe\xf3\x2b\x4a\xb6\xa2\xb5\xb5\x63\x5e\x33\x5e\xc7\x48\x73\xb0\x36\x91\x72\x88\x4f\x59\xed\x65\xe4\xa0\x1e\x28\x98\xce\x34\xdd\xa4\xbb\xc0\xb6\xf2\xf8\xed\x51\x35\x30\x30\x1b\x6f\x72\xd8\x39\x0c\x50\x7c\xf5\xd5\xeb\xeb\x42\x99\x42\x28\xc8\x1f\x61\x0b\x7f\xfc\x15\x0c\x4f\x8e\xac\xd4\x75\xae\x50\xc3\x76\x7c\x08\x15\xea\x20\xb8\xb9\x01\x3a\x48\x07\xb2\x69\x15\x36\xa8\x49\x90\x34\x1a\xa4\x03\x12\x47\xd4\x50\x59\xd3\x30\xe8\x40\xd4\xba\x2c\x8a\x9e\x71\x1f\x0a\x5b\x1c\x64\x8f\xa1\xb1\x35\x3f\x47\x69\x9c\xac\x93\x34\xbd\x8d\xef\xe2\xcd\x7a\x13\x31\x34\x8b\x22\xa7\x65\xdb\x22\xb9\x50\x75\xa2\x30\xe5\x00\x9f\x8c\xd1\x0f\x88\x6d\xfe\xd1\x34\xad\xb0\xd2\x19\x9d\x9b\x2a\xff\xf4\x6c\xf2\xcf\x42\x75\xe8\xf2\x35\x87\x14\xba\x84\xc6\x94\xb2\x92\x58\x42\x65\x2c\x74\x0e\x41\xea\x21\xdf\xd6\x9a\xdf\xb0\xa0\xb1\xbc\xaa\xd3\x85\xcf\xbb\x64\xda\xc2\xd3\xe2\x15\x25\x2b\xa0\x74\x05\xb2\xd6\xc6\x62\xde\xd0\x75\x00\x30\x38\xd0\x6b\x02\x5b\xa0\xd7\x96\x51\x4b\x73\x7a\x32\xa7\x6c\x96\x95\x87\xfe\xbd\xf5\xaf\xe8\x80\x1a\x2c\x52\x67\x35\x54\x42\x39\x04\xd4\x65\x00\x70\x73\x03\xda\xe8\x1b\x12\x7b\x85\xde\xdb\x41\x21\x34\xec\x11\x4a\x69\xb1\x20\xf5\x0a\x63\x4e\xe5\x19\xe7\x3b\xef\xf1\xce\x57\xca\xfc\x0b\xd3\x32\x14\x25\xb0\xdd\x02\xa5\x73\x34\xe1\xe0\x19\x95\xe2\xab\xc7\x3b\x78\x3e\xc8\xe2\x00\x07\xd1\x23\xbb\x42\x83\x24\x1a\xa4\x83\x29\x21\xcf\xf1\xf7\x53\x81\x0d\xc1\x16\x6a\x24\x7e\xef\x3d\xc7\xf2\x65\x05\xda\xd0\xdc\xa9\xa1\xf9\xd3\x25\x64\x8e\xff\x4a\x89\xa7\x73\x4c\x56\x7d\xc2\xf3\x69\x85\xb4\x8e\x79\xa1\x34\x01\xc0\x14\xba\xf7\xad\x4d\x77\xc7\xe4\xc9\x5b\x65\xe5\x4d\x5b\xd0\x52\x81\xb1\x3e\xfe\xd9\xf8\xfa\x64\xd5\xa7\xd7\x5f\x6d\xfa\x22\x72\xba\xea\xd3\x45\xe4\xf4\xcb\xc8\x7e\xd6\xc9\xee\x98\xce\x91\x93\x6f\x8e\x3c\x75\xc2\x76\x18\xb0\x25\x7f\x0c\x97\x24\xb0\x3d\xe3\x0c\x82\x93\x46\xf3\xc7\x50\xba\x7c\xaf\x84\x3e\x5e\x39\xb2\xd7\x33\x97\x23\xbb\x48\x6b\x3e\xb3\x1e\xc6\x6f\x62\x1f\x69\x3a\x8f\x59\x14\xe9\x5a\xea\x17\x7f\xb2\x50\x47\xa5\x29\x9c\x3f\x7d\x91\xae\x5f\x72\xbe\xc9\xbb\xd6\x91\x45\xd1\xe4\x8d\x29\x3b\x85\xe1\x81\x1a\x75\x89\x2f\x82\x4f\x3b\xd3\x7c\x7c\xf8\xfc\xe3\xc3\xa7\x0c\x3c\x0f\x9f\xfa\x5a\xf6\x52\xd7\x60\x3a\x82\x0c\xa4\x76\x84\xa2\x04\x53\xc1\x0a\x9c\xf1\xca\xe2\x20\xc0\xf5\x3d\x5b\xa3\x6b\xe6\x48\xd2\xbb\x30\x0e\xe3\x30\xc9\xd2\x0f\xc9\xed\x1d\x64\xff\xb2\xac\x40\xd7\x2f\x61\x2f\x6c\x78\xca\x47\x94\xa5\x65\xe7\x34\x8e\x21\xf3\xff\x6f\x80\x1c\x09\xea\x1c\xc3\xe2\xd0\xe3\xf8\xf2\x06\xce\xa2\x6b\x8d\x76\x98\x93\x6c\xf0\xac\xd1\xae\x55\x92\xe6\x2e\xf4\xc2\x5e\xf5\xc2\x2e\x14\xdf\x0b\xeb\xe7\xec\x85\x31\x8e\x41\x4b\xb5\xe2\xbf\xd3\xa8\xc7\xe5\x30\x2c\xd4\x41\x73\x3d\xeb\xad\x17\x36\xab\x1b\x41\xc5\xe1\xea\x62\xf7\xeb\x77\xee\xcf\xd5\xd3\xfb\x8b\x93\xf8\x58\x66\x7c\xa4\x2f\xb2\x8b\x39\x04\x00\xed\x2e\xe9\x7d\xf2\x04\x5b\xe8\xbd\xe5\x2d\x4d\x0d\x63\x5e\x16\x52\x23\xe5\x95\xb4\x8e\xf2\x9e\x57\xe4\x54\xc5\x9c\xd9\xd7\x8b\x65\x2d\xf9\xbc\x65\x05\x97\xe4\x65\x74\x26\x6d\x96\xdb\x79\xf8\x5d\xf2\x74\x12\xda\xff\x7e\x1d\xb2\xe5\xe7\xa1\x96\x74\xe8\xf6\x61\x61\x9a\x48\x75\xa2\xea\xf4\x74\xd9\x2b\xb3\x8f\x1a\xe1\x08\x6d\x54\x75\x9a\x3f\x0a\x97\x3f\xaf\xfd\x9e\xff\xe5\xa7\x87\x0c\xe2\x4d\x71\x7f\x5f\xdd\x17\xeb\xfb\x35\xde\x6e\xc4\x87\x78\x23\xca\x12\x37\xfb\xf4\x76\x7f\x77\xbf\xa9\x36\xdf\x27\xf1\x06\xe3\x32\x7e\x6b\xe1\x17\xa6\x7d\xbd\x32\x56\xd6\x73\x47\xf8\x29\xe7\x4d\x3c\xad\xf3\xf3\xd7\xec\x31\x34\x64\x01\x3c\x5f\xbe\xe3\xb4\x18\x39\xcd\x9d\x7f\x3c\x7b\xef\x73\xc4\xd7\xd5\x70\xe7\x07\xc2\x72\xd0\xf8\x42\x83\xcd\xcb\x67\xd2\xc1\x4c\xb4\x3b\xcb\x96\x29\xae\x9f\xc6\x3d\x31\x5b\x3d\xdd\xf5\xe8\x39\x8a\x43\x39\x3c\xcf\x87\x91\x5f\xaa\xc6\x17\xb5\xd8\x44\x23\x74\xba\x0d\x82\x11\x97\x3f\x06\xff\x04\x00\x00\xff\xff\xc6\xa6\x46\xf4\x23\x08\x00\x00") func etcNginxLuaUtilLuaBytes() ([]byte, error) { @@ -312,6 +354,8 @@ var _bindata = map[string]func() (*asset, error){ "etc/nginx/lua/balancer.lua": etcNginxLuaBalancerLua, "etc/nginx/lua/configuration.lua": etcNginxLuaConfigurationLua, "etc/nginx/lua/sticky.lua": etcNginxLuaStickyLua, + "etc/nginx/lua/test/balancer_test.lua": etcNginxLuaTestBalancer_testLua, + "etc/nginx/lua/test/up.sh": etcNginxLuaTestUpSh, "etc/nginx/lua/util.lua": etcNginxLuaUtilLua, "etc/nginx/nginx.conf": etcNginxNginxConf, "etc/nginx/template/nginx.tmpl": etcNginxTemplateNginxTmpl, @@ -368,6 +412,10 @@ var _bintree = &bintree{nil, map[string]*bintree{ "balancer.lua": &bintree{etcNginxLuaBalancerLua, map[string]*bintree{}}, "configuration.lua": &bintree{etcNginxLuaConfigurationLua, map[string]*bintree{}}, "sticky.lua": &bintree{etcNginxLuaStickyLua, map[string]*bintree{}}, + "test": &bintree{nil, map[string]*bintree{ + "balancer_test.lua": &bintree{etcNginxLuaTestBalancer_testLua, map[string]*bintree{}}, + "up.sh": &bintree{etcNginxLuaTestUpSh, map[string]*bintree{}}, + }}, "util.lua": &bintree{etcNginxLuaUtilLua, map[string]*bintree{}}, }}, "nginx.conf": &bintree{etcNginxNginxConf, map[string]*bintree{}}, diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua new file mode 100644 index 0000000000..a3257249f8 --- /dev/null +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -0,0 +1,3 @@ +describe("[balancer_test]", function() + -- TODO: write tests +end) diff --git a/rootfs/etc/nginx/lua/test/up.sh b/rootfs/etc/nginx/lua/test/up.sh new file mode 100755 index 0000000000..c69f8cea10 --- /dev/null +++ b/rootfs/etc/nginx/lua/test/up.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Copyright 2018 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if luarocks list --porcelain busted $BUSTED_VERSION | grep -q "installed"; then + echo busted already installed, skipping ; +else + echo busted not found, installing via luarocks...; + sudo luarocks install busted $BUSTED_VERSION; +fi