mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #127643 from Jefftree/set-emulation-integration-test
Allow emulation version to be set in integration test
This commit is contained in:
commit
80941e3e87
@ -44,6 +44,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
serveroptions "k8s.io/apiserver/pkg/server/options"
|
||||
"k8s.io/apiserver/pkg/storage/storagebackend"
|
||||
@ -102,8 +103,11 @@ type TestServerInstanceOptions struct {
|
||||
// an apiserver version skew scenario where all apiservers use the same proxyCA to verify client connections.
|
||||
ProxyCA *ProxyCA
|
||||
// Set the BinaryVersion of server effective version.
|
||||
// Default to 1.31
|
||||
// If empty, effective version will default to version.DefaultKubeBinaryVersion.
|
||||
BinaryVersion string
|
||||
// Set the EmulationVersion of server effective version.
|
||||
// If empty, emulation version will default to the effective version.
|
||||
EmulationVersion string
|
||||
// Set non-default request timeout in the server.
|
||||
RequestTimeout time.Duration
|
||||
}
|
||||
@ -194,6 +198,9 @@ func StartTestServer(t ktesting.TB, instanceOptions *TestServerInstanceOptions,
|
||||
if instanceOptions.BinaryVersion != "" {
|
||||
effectiveVersion = utilversion.NewEffectiveVersion(instanceOptions.BinaryVersion)
|
||||
}
|
||||
if instanceOptions.EmulationVersion != "" {
|
||||
effectiveVersion.SetEmulationVersion(version.MustParse(instanceOptions.EmulationVersion))
|
||||
}
|
||||
// need to call SetFeatureGateEmulationVersionDuringTest to reset the feature gate emulation version at the end of the test.
|
||||
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, featureGate, effectiveVersion.EmulationVersion())
|
||||
utilversion.DefaultComponentGlobalsRegistry.Reset()
|
||||
|
@ -2234,7 +2234,8 @@ func Test_CostLimitForValidation(t *testing.T) {
|
||||
func Test_CostLimitForValidationWithFeatureDisabled(t *testing.T) {
|
||||
resetPolicyRefreshInterval := generic.SetPolicyRefreshIntervalForTests(policyRefreshInterval)
|
||||
defer resetPolicyRefreshInterval()
|
||||
server, err := apiservertesting.StartTestServer(t, nil, []string{
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.StrictCostEnforcementForVAP, false)
|
||||
server, err := apiservertesting.StartTestServer(t, &apiservertesting.TestServerInstanceOptions{EmulationVersion: "1.31"}, []string{
|
||||
"--enable-admission-plugins", "ValidatingAdmissionPolicy",
|
||||
}, framework.SharedEtcd())
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user