Merge pull request #121801 from danwinship/iptables-test-count
Fix "go test -count=2 ./pkg/proxy/iptables"
This commit is contained in:
		@@ -40,6 +40,7 @@ import (
 | 
			
		||||
	"k8s.io/apimachinery/pkg/util/sets"
 | 
			
		||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
			
		||||
	featuregatetesting "k8s.io/component-base/featuregate/testing"
 | 
			
		||||
	"k8s.io/component-base/metrics/legacyregistry"
 | 
			
		||||
	"k8s.io/component-base/metrics/testutil"
 | 
			
		||||
	"k8s.io/klog/v2"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/features"
 | 
			
		||||
@@ -6150,6 +6151,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
 | 
			
		||||
	ipt := iptablestest.NewFake()
 | 
			
		||||
	fp := NewFakeProxier(ipt)
 | 
			
		||||
	metrics.RegisterMetrics()
 | 
			
		||||
	defer legacyregistry.Reset()
 | 
			
		||||
 | 
			
		||||
	// Create initial state
 | 
			
		||||
	var svc2 *v1.Service
 | 
			
		||||
@@ -6677,11 +6679,11 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
 | 
			
		||||
	if fp.needFullSync {
 | 
			
		||||
		t.Fatalf("Proxier unexpectedly already needs a full sync?")
 | 
			
		||||
	}
 | 
			
		||||
	prFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
 | 
			
		||||
	partialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("Could not get partial restore failures metric: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	if prFailures != 0.0 {
 | 
			
		||||
	if partialRestoreFailures != 0.0 {
 | 
			
		||||
		t.Errorf("Already did a partial resync? Something failed earlier!")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -6711,12 +6713,12 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
 | 
			
		||||
	if !fp.needFullSync {
 | 
			
		||||
		t.Errorf("Proxier did not fail on previous partial resync?")
 | 
			
		||||
	}
 | 
			
		||||
	updatedPRFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
 | 
			
		||||
	updatedPartialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Errorf("Could not get partial restore failures metric: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	if updatedPRFailures != prFailures+1.0 {
 | 
			
		||||
		t.Errorf("Partial restore failures metric was not incremented after failed partial resync (expected %.02f, got %.02f)", prFailures+1.0, updatedPRFailures)
 | 
			
		||||
	if updatedPartialRestoreFailures != partialRestoreFailures+1.0 {
 | 
			
		||||
		t.Errorf("Partial restore failures metric was not incremented after failed partial resync (expected %.02f, got %.02f)", partialRestoreFailures+1.0, updatedPartialRestoreFailures)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// On retry we should do a full resync, which should succeed (and delete svc4)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user