Skip to content

Commit

Permalink
tests, build: Use xerrors + parallelize tests + build against Go v1.13 (
Browse files Browse the repository at this point in the history
#18)

* tests: use t.Parallel()
* deps: use xerrors instead of errors/fmt.Errorf
* deps: update k8s dependencies
* build: use Go 1.13 in Docker + CircleCI
  • Loading branch information
elithrar authored Sep 15, 2019
1 parent fdd542f commit 9c96b38
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ workflows:
name: "latest"
v: "latest"
latest: true
- test:
name: "v1.13"
v: "1.13"
- test:
name: "v1.12"
v: "1.12"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.12 as build
FROM golang:1.13 as build

LABEL repo="https://github.com/elithrar/admission-control"
ARG GIT_COMMIT=""
Expand Down
13 changes: 7 additions & 6 deletions admit_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admissioncontrol

import (
"fmt"
"golang.org/x/xerrors"

admission "k8s.io/api/admission/v1beta1"
apps "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -83,7 +84,7 @@ func DenyIngresses(ignoredNamespaces []string) AdmitFunc {
}
}

return nil, fmt.Errorf("%s objects cannot be deployed to this cluster", kind)
return nil, xerrors.Errorf("%s objects cannot be deployed to this cluster", kind)
default:
resp.Allowed = true
return resp, nil
Expand Down Expand Up @@ -135,13 +136,13 @@ func DenyPublicLoadBalancers(ignoredNamespaces []string, provider CloudProvider)

expectedAnnotations, ok := ilbAnnotations[provider]
if !ok {
return resp, fmt.Errorf("internal load balancer annotations for the given provider (%q) are not supported", provider)
return resp, xerrors.Errorf("internal load balancer annotations for the given provider (%q) are not supported", provider)
}

// TODO(matt): If we're missing any annotations, provide them in the AdmissionResponse so
// the user can correct them.
if _, ok := ensureHasAnnotations(expectedAnnotations, service.ObjectMeta.Annotations); !ok {
return resp, fmt.Errorf("%s objects of type: LoadBalancer without an internal-only annotation cannot be deployed to this cluster", kind)
return resp, xerrors.Errorf("%s objects of type: LoadBalancer without an internal-only annotation cannot be deployed to this cluster", kind)
}

// No missing or invalid annotations; allow admission
Expand Down Expand Up @@ -219,7 +220,7 @@ func EnforcePodAnnotations(ignoredNamespaces []string, requiredAnnotations map[s
annotations = job.Spec.Template.GetAnnotations()
default:
// TODO(matt): except for whitelisted namespaces
return nil, fmt.Errorf("the submitted Kind is not supported by this admission handler: %s", kind)
return nil, xerrors.Errorf("the submitted Kind is not supported by this admission handler: %s", kind)
}

// Ignore objects in whitelisted namespaces.
Expand All @@ -237,7 +238,7 @@ func EnforcePodAnnotations(ignoredNamespaces []string, requiredAnnotations map[s
// value for a key does not match, admission is rejected.
for requiredKey, matchFunc := range requiredAnnotations {
if matchFunc == nil {
return resp, fmt.Errorf("cannot validate annotations (%s) with a nil matchFunc", requiredKey)
return resp, xerrors.Errorf("cannot validate annotations (%s) with a nil matchFunc", requiredKey)
}

if existingVal, ok := annotations[requiredKey]; !ok {
Expand All @@ -252,7 +253,7 @@ func EnforcePodAnnotations(ignoredNamespaces []string, requiredAnnotations map[s
}

if len(missing) > 0 {
return resp, fmt.Errorf("%s %v", podDeniedError, missing)
return resp, xerrors.Errorf("%s %v", podDeniedError, missing)
}

// No missing or invalid annotations; allow admission
Expand Down
6 changes: 6 additions & 0 deletions admit_funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func newTestAdmissionRequest(kind meta.GroupVersionKind, object []byte, expected
// TestDenyIngress validates that the DenyIngress AdmitFunc correctly rejects
// admission of Ingress objects to a cluster.
func TestDenyIngress(t *testing.T) {
t.Parallel()

var deniedIngressError = "Ingress objects cannot be deployed to this cluster"
var denyTests = []objectTest{
{
Expand Down Expand Up @@ -165,6 +167,8 @@ func TestDenyIngress(t *testing.T) {
// TestDenyPublicServices checks that the DenyPublicServices AdmitFunc correctly
// rejects non-internal load balancer admission to a cluster.
func TestDenyPublicLoadBalancers(t *testing.T) {
t.Parallel()

var missingLBAnnotationsMessage = "Service objects of type: LoadBalancer without an internal-only annotation cannot be deployed to this cluster"

var denyTests = []objectTest{
Expand Down Expand Up @@ -355,6 +359,8 @@ func TestDenyPublicLoadBalancers(t *testing.T) {
}

func TestEnforcePodAnnotations(t *testing.T) {
t.Parallel()

var denyTests = []objectTest{
{
testName: "Allow Pod with required annotations",
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@ require (
github.com/go-openapi/spec v0.19.2 // indirect
github.com/go-openapi/swag v0.19.4 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.3.0 // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/googleapis/gnostic v0.3.0 // indirect
github.com/gorilla/mux v1.7.3
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/json-iterator/go v1.1.7 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 // indirect
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 // indirect
golang.org/x/tools v0.0.0-20190802220118-1d1727260058 // indirect
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190803060717-3ce214556aa9
k8s.io/apimachinery v0.0.0-20190802060556-6fa4771c83b3
k8s.io/api v0.0.0-20190913080256-21721929cffa
k8s.io/apimachinery v0.0.0-20190913075813-344bcc0201c9
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect
k8s.io/klog v0.3.3 // indirect
k8s.io/kube-openapi v0.0.0-20190722073852-5e22f3d471e6 // indirect
sigs.k8s.io/structured-merge-diff v0.0.0-20190724202554-0c1d754dd648 // indirect
)
17 changes: 17 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
Expand All @@ -46,10 +47,13 @@ github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE=
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down Expand Up @@ -136,6 +140,9 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 h1:4dVFTC832rPn4pomLSz1vA+are2+dU19w1H8OngV7nc=
golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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=
Expand Down Expand Up @@ -165,6 +172,8 @@ golang.org/x/tools v0.0.0-20190724185037-8aa4eac1a7c1/go.mod h1:jcCCGcm9btYwXyDq
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190731214159-1e85ed8060aa/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190802220118-1d1727260058/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down Expand Up @@ -195,6 +204,8 @@ k8s.io/api v0.0.0-20190802060718-d0d4f3afa3ab h1:rIcOGLTF52ktddf7KTMbbCJQLnipzgL
k8s.io/api v0.0.0-20190802060718-d0d4f3afa3ab/go.mod h1:SgXHCRh94q+5GrRf9Dty2ZG8+wCVmqvQbZJXXcAswkw=
k8s.io/api v0.0.0-20190803060717-3ce214556aa9 h1:Gaj41zd82Oo4j8f8QGlOV6eDOKCk71D39H2+9ER5QIc=
k8s.io/api v0.0.0-20190803060717-3ce214556aa9/go.mod h1:SgXHCRh94q+5GrRf9Dty2ZG8+wCVmqvQbZJXXcAswkw=
k8s.io/api v0.0.0-20190913080256-21721929cffa h1:5HxstS7zbT60CcA8qiFOeJtUxIwenu0dVIR5Ne0BUI8=
k8s.io/api v0.0.0-20190913080256-21721929cffa/go.mod h1:jESdJL4e7Q+sDnEXOZ1ysc1WBxR4I34RbRh5QqGT9kQ=
k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 h1:uV4S5IB5g4Nvi+TBVNf3e9L4wrirlwYJ6w88jUQxTUw=
k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719/go.mod h1:I4A+glKBHiTgiEjQiCCQfCAIcIMFGt291SmsvcrFzJA=
k8s.io/apimachinery v0.0.0-20190620073744-d16981aedf33 h1:Lkd+QNFOB3DqrDyWo796aodJgFJautn/M+t9IGearPc=
Expand All @@ -209,17 +220,23 @@ k8s.io/apimachinery v0.0.0-20190731142807-035e418f1ad9 h1:RedGIevS9N0IS0QVL+kWS8
k8s.io/apimachinery v0.0.0-20190731142807-035e418f1ad9/go.mod h1:+ntn62igV2hyNj7/0brOvXSMONE2KxcePkSxK7/9FFQ=
k8s.io/apimachinery v0.0.0-20190802060556-6fa4771c83b3 h1:ov3gR/oGSdOkfEetREkvyrTMbEUDAADeF9WMoihPv0w=
k8s.io/apimachinery v0.0.0-20190802060556-6fa4771c83b3/go.mod h1:+ntn62igV2hyNj7/0brOvXSMONE2KxcePkSxK7/9FFQ=
k8s.io/apimachinery v0.0.0-20190913075812-e119e5e154b6/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4=
k8s.io/apimachinery v0.0.0-20190913075813-344bcc0201c9 h1:X3j64GFUkgT5sCzlgbirLbyqrqDXJ2DLmf5Yn2Muc/E=
k8s.io/apimachinery v0.0.0-20190913075813-344bcc0201c9/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.1 h1:RVgyDHY/kFKtLqh67NvEWIgkMneNoIrdkN0CxDSQc68=
k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.3 h1:niceAagH1tzskmaie/icWd7ci1wbG7Bf2c6YGcQv+3c=
k8s.io/klog v0.3.3/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ=
k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
k8s.io/kube-openapi v0.0.0-20190718094010-3cf2ea392886/go.mod h1:RZvgC8MSN6DjiMV6oIfEE9pDL9CYXokkfaCKZeHm3nc=
k8s.io/kube-openapi v0.0.0-20190722073852-5e22f3d471e6/go.mod h1:RZvgC8MSN6DjiMV6oIfEE9pDL9CYXokkfaCKZeHm3nc=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190724202554-0c1d754dd648/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA=
Expand Down
4 changes: 2 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package admissioncontrol

import (
"encoding/json"
"errors"
"fmt"
"golang.org/x/xerrors"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -124,7 +124,7 @@ func (ah *AdmissionHandler) handleAdmissionRequest(w http.ResponseWriter, r *htt
}

if incomingReview.Request == nil {
return errors.New("received invalid request: no AdmissionReview was found")
return xerrors.New("received invalid request: no AdmissionReview was found")
}

reviewResponse, err := ah.AdmitFunc(&incomingReview)
Expand Down
1 change: 1 addition & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func newTestAdmitFunc(allowed bool, returnError bool) AdmitFunc {
}

func TestAdmissionHandler(t *testing.T) {
t.Parallel()
var handlerTests = []struct {
testName string
admitFunc AdmitFunc
Expand Down
6 changes: 3 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package admissioncontrol

import (
"context"
"errors"
"fmt"
"golang.org/x/xerrors"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -45,11 +45,11 @@ func (as *AdmissionServer) shutdown(ctx context.Context, gracePeriod time.Durati
// only reachable over HTTPS (TLS), whether running in-cluster or externally.
func NewServer(srv *http.Server, logger log.Logger) (*AdmissionServer, error) {
if srv == nil {
return nil, errors.New("a non-nil *http.Server must be provided")
return nil, xerrors.New("a non-nil *http.Server must be provided")
}

if logger == nil {
return nil, errors.New("a non-nil log.Logger must be provided")
return nil, xerrors.New("a non-nil log.Logger must be provided")
}

if srv.TLSConfig == nil {
Expand Down
5 changes: 5 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func newTestServer(ctx context.Context, t *testing.T) *testServer {
// Test that we can start a minimal AdmissionServer and handle a request.
func TestAdmissionServer(t *testing.T) {
t.Run("AdmissionServer should return an error w/o a *http.Server", func(t *testing.T) {
t.Parallel()
_, err := NewServer(nil, &noopLogger{})
if err == nil {
t.Fatalf("nil *http.Server did not return an error")
Expand All @@ -95,6 +96,7 @@ func TestAdmissionServer(t *testing.T) {
})

t.Run("AdmissionServer should return an error w/o a log.Logger", func(t *testing.T) {
t.Parallel()
_, err := NewServer(&http.Server{}, nil)
if err == nil {
t.Fatalf("nil log.Logger did not return an error")
Expand All @@ -103,6 +105,7 @@ func TestAdmissionServer(t *testing.T) {
})

t.Run("AdmissionServer starts & accepts HTTP requests", func(t *testing.T) {
t.Parallel()
testSrv := newTestServer(context.TODO(), t)
defer testSrv.srv.Stop()
client := testSrv.client
Expand All @@ -122,6 +125,7 @@ func TestAdmissionServer(t *testing.T) {
})

t.Run("AdmissionServer.Stop() stops the server", func(t *testing.T) {
t.Parallel()
testSrv := newTestServer(context.TODO(), t)
testSrv.srv.GracePeriod = time.Microsecond * 1

Expand All @@ -138,6 +142,7 @@ func TestAdmissionServer(t *testing.T) {
})

t.Run("AdmissionServer handles a cancellation context and shuts down.", func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
testSrv := newTestServer(ctx, t)
testSrv.srv.GracePeriod = time.Microsecond * 1
Expand Down

0 comments on commit 9c96b38

Please sign in to comment.