Skip to content

Commit

Permalink
ci: Drop --ginkgo.timeout and add --ginkgo.randomize-all CLI arg …
Browse files Browse the repository at this point in the history
…for Makefile target (#1008)
  • Loading branch information
jonathan-innis authored Feb 14, 2024
1 parent 42398a0 commit 0a5e3ce
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ presubmit: verify test licenses vulncheck ## Run all steps required for code to

install-kwok: ## Install kwok provider
UNINSTALL_KWOK=false ./hack/install-kwok.sh
uninstall-kwok: ## Install kwok provider

uninstall-kwok: ## Uninstall kwok provider
UNINSTALL_KWOK=true ./hack/install-kwok.sh

build: ## Build the Karpenter KWOK controller images using ko build
Expand Down Expand Up @@ -46,7 +47,7 @@ test: ## Run tests
-race \
-timeout 15m \
--ginkgo.focus="${FOCUS}" \
--ginkgo.timeout=15m \
--ginkgo.randomize-all \
--ginkgo.v \
-cover -coverprofile=coverage.out -outputdir=. -coverpkg=./...

Expand Down Expand Up @@ -94,4 +95,4 @@ download: ## Recursively "go mod download" on all directories where go.mod exist
toolchain: ## Install developer toolchain
./hack/toolchain.sh

.PHONY: help presubmit dev test verify toolchain
.PHONY: help presubmit install-kwok uninstall-kwok build apply delete test deflake vulncheck licenses verify download toolchain
2 changes: 1 addition & 1 deletion pkg/controllers/leasegarbagecollection/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *Controller) Reconcile(ctx context.Context, l *v1.Lease) (reconcile.Resu
err := c.kubeClient.Delete(ctx, l)
if err == nil {
logging.FromContext(ctx).Debug("found and delete leaked lease")
NodeLeaseDeletedCounter.Inc()
NodeLeaseDeletedCounter.WithLabelValues().Inc()
}

return reconcile.Result{}, client.IgnoreNotFound(err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/leasegarbagecollection/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ import (
)

var (
NodeLeaseDeletedCounter = prometheus.NewCounter(
NodeLeaseDeletedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "karpenter",
Subsystem: metrics.NodeSubsystem,
Name: "leases_deleted",
Help: "Number of deleted leaked leases.",
},
[]string{},
)
)

Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/leasegarbagecollection/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import (
"testing"
"time"

"github.com/samber/lo"
coordinationsv1 "k8s.io/api/coordination/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/samber/lo"

"sigs.k8s.io/karpenter/pkg/apis"
"sigs.k8s.io/karpenter/pkg/controllers/leasegarbagecollection"
"sigs.k8s.io/karpenter/pkg/operator/controller"
Expand Down Expand Up @@ -98,6 +97,10 @@ var _ = Describe("GarbageCollection", func() {
},
}
})
AfterEach(func() {
// Reset the metrics collectors
leasegarbagecollection.NodeLeaseDeletedCounter.Reset()
})
Context("Metrics", func() {
It("should fire the leaseDeletedCounter metric when deleting leases", func() {
ExpectApplied(ctx, env.Client, badLease)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/disruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ var _ = AfterSuite(func() {

var _ = BeforeEach(func() {
ctx = options.ToContext(ctx, test.Options(test.OptionsFields{FeatureGates: test.FeatureGates{Drift: lo.ToPtr(true)}}))
fakeClock.SetTime(time.Now())
})

var _ = AfterEach(func() {
fakeClock.SetTime(time.Now())
cp.Reset()
cluster.Reset()
ExpectCleanedUp(ctx, env.Client)
Expand Down
16 changes: 2 additions & 14 deletions pkg/operator/options/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func TestOptions(t *testing.T) {
}

var _ = Describe("Options", func() {
var envState map[string]string
var environmentVariables = []string{
"KARPENTER_SERVICE",
"DISABLE_WEBHOOK",
"WEBHOOK_PORT",
"METRICS_PORT",
"WEBHOOK_METRICS_PORT",
"HEALTH_PROBE_PORT",
"KUBE_CLIENT_QPS",
"KUBE_CLIENT_BURST",
"ENABLE_PROFILING",
"LEADER_ELECT",
Expand All @@ -62,15 +62,6 @@ var _ = Describe("Options", func() {
}

BeforeEach(func() {
envState = map[string]string{}
for _, ev := range environmentVariables {
val, ok := os.LookupEnv(ev)
if ok {
envState[ev] = val
}
os.Unsetenv(ev)
}

fs = &options.FlagSet{
FlagSet: flag.NewFlagSet("karpenter", flag.ContinueOnError),
}
Expand All @@ -80,10 +71,7 @@ var _ = Describe("Options", func() {

AfterEach(func() {
for _, ev := range environmentVariables {
os.Unsetenv(ev)
}
for ev, val := range envState {
os.Setenv(ev, val)
Expect(os.Unsetenv(ev)).To(Succeed())
}
})

Expand Down

0 comments on commit 0a5e3ce

Please sign in to comment.