mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Merge pull request #124494 from brianpursley/FixSlowUnitTest-TestForceApply
Improve performance of TestForceApply unit test (k8s.io/kubectl/pkg/cmd/apply)
This commit is contained in:
		| @@ -2087,6 +2087,9 @@ func TestForceApply(t *testing.T) { | |||||||
| 		"post":        1, | 		"post":        1, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// Set the patch retry back off period to something low, so the test can run more quickly | ||||||
|  | 	patchRetryBackOffPeriod = 1 * time.Millisecond | ||||||
|  |  | ||||||
| 	for _, testingOpenAPISchema := range testingOpenAPISchemas { | 	for _, testingOpenAPISchema := range testingOpenAPISchemas { | ||||||
| 		for _, openAPIFeatureToggle := range applyFeatureToggles { | 		for _, openAPIFeatureToggle := range applyFeatureToggles { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -49,8 +49,6 @@ import ( | |||||||
| const ( | const ( | ||||||
| 	// maxPatchRetry is the maximum number of conflicts retry for during a patch operation before returning failure | 	// maxPatchRetry is the maximum number of conflicts retry for during a patch operation before returning failure | ||||||
| 	maxPatchRetry = 5 | 	maxPatchRetry = 5 | ||||||
| 	// backOffPeriod is the period to back off when apply patch results in error. |  | ||||||
| 	backOffPeriod = 1 * time.Second |  | ||||||
| 	// how many times we can retry before back off | 	// how many times we can retry before back off | ||||||
| 	triesBeforeBackOff = 1 | 	triesBeforeBackOff = 1 | ||||||
| 	// groupVersionKindExtensionKey is the key used to lookup the | 	// groupVersionKindExtensionKey is the key used to lookup the | ||||||
| @@ -59,6 +57,9 @@ const ( | |||||||
| 	groupVersionKindExtensionKey = "x-kubernetes-group-version-kind" | 	groupVersionKindExtensionKey = "x-kubernetes-group-version-kind" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // patchRetryBackOffPeriod is the period to back off when apply patch results in error. | ||||||
|  | var patchRetryBackOffPeriod = 1 * time.Second | ||||||
|  |  | ||||||
| var createPatchErrFormat = "creating patch with:\noriginal:\n%s\nmodified:\n%s\ncurrent:\n%s\nfor:" | var createPatchErrFormat = "creating patch with:\noriginal:\n%s\nmodified:\n%s\ncurrent:\n%s\nfor:" | ||||||
|  |  | ||||||
| // Patcher defines options to patch OpenAPI objects. | // Patcher defines options to patch OpenAPI objects. | ||||||
| @@ -363,7 +364,7 @@ func (p *Patcher) Patch(current runtime.Object, modified []byte, source, namespa | |||||||
| 	} | 	} | ||||||
| 	for i := 1; i <= p.Retries && apierrors.IsConflict(err); i++ { | 	for i := 1; i <= p.Retries && apierrors.IsConflict(err); i++ { | ||||||
| 		if i > triesBeforeBackOff { | 		if i > triesBeforeBackOff { | ||||||
| 			p.BackOff.Sleep(backOffPeriod) | 			p.BackOff.Sleep(patchRetryBackOffPeriod) | ||||||
| 		} | 		} | ||||||
| 		current, getErr = p.Helper.Get(namespace, name) | 		current, getErr = p.Helper.Get(namespace, name) | ||||||
| 		if getErr != nil { | 		if getErr != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot