mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +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"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/version"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
serveroptions "k8s.io/apiserver/pkg/server/options"
|
serveroptions "k8s.io/apiserver/pkg/server/options"
|
||||||
"k8s.io/apiserver/pkg/storage/storagebackend"
|
"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.
|
// an apiserver version skew scenario where all apiservers use the same proxyCA to verify client connections.
|
||||||
ProxyCA *ProxyCA
|
ProxyCA *ProxyCA
|
||||||
// Set the BinaryVersion of server effective version.
|
// Set the BinaryVersion of server effective version.
|
||||||
// Default to 1.31
|
// If empty, effective version will default to version.DefaultKubeBinaryVersion.
|
||||||
BinaryVersion string
|
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.
|
// Set non-default request timeout in the server.
|
||||||
RequestTimeout time.Duration
|
RequestTimeout time.Duration
|
||||||
}
|
}
|
||||||
@ -194,6 +198,9 @@ func StartTestServer(t ktesting.TB, instanceOptions *TestServerInstanceOptions,
|
|||||||
if instanceOptions.BinaryVersion != "" {
|
if instanceOptions.BinaryVersion != "" {
|
||||||
effectiveVersion = utilversion.NewEffectiveVersion(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.
|
// need to call SetFeatureGateEmulationVersionDuringTest to reset the feature gate emulation version at the end of the test.
|
||||||
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, featureGate, effectiveVersion.EmulationVersion())
|
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, featureGate, effectiveVersion.EmulationVersion())
|
||||||
utilversion.DefaultComponentGlobalsRegistry.Reset()
|
utilversion.DefaultComponentGlobalsRegistry.Reset()
|
||||||
|
@ -2234,7 +2234,8 @@ func Test_CostLimitForValidation(t *testing.T) {
|
|||||||
func Test_CostLimitForValidationWithFeatureDisabled(t *testing.T) {
|
func Test_CostLimitForValidationWithFeatureDisabled(t *testing.T) {
|
||||||
resetPolicyRefreshInterval := generic.SetPolicyRefreshIntervalForTests(policyRefreshInterval)
|
resetPolicyRefreshInterval := generic.SetPolicyRefreshIntervalForTests(policyRefreshInterval)
|
||||||
defer resetPolicyRefreshInterval()
|
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",
|
"--enable-admission-plugins", "ValidatingAdmissionPolicy",
|
||||||
}, framework.SharedEtcd())
|
}, framework.SharedEtcd())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user