Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
70ad4dff
Commit
70ad4dff
authored
Nov 21, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unit tests calling SetFeatureGateDuringTest incorrectly
parent
4dca07ef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
38 deletions
+36
-38
validation_test.go
pkg/apis/core/validation/validation_test.go
+1
-2
index_test.go
pkg/controller/volume/persistentvolume/index_test.go
+32
-30
helpers_linux_test.go
pkg/kubelet/cm/helpers_linux_test.go
+1
-2
helpers_linux_test.go
pkg/kubelet/kuberuntime/helpers_linux_test.go
+1
-2
helpers_test.go
pkg/kubelet/kuberuntime/helpers_test.go
+1
-2
No files found.
pkg/apis/core/validation/validation_test.go
View file @
70ad4dff
...
@@ -6383,8 +6383,7 @@ func TestValidatePodSpec(t *testing.T) {
...
@@ -6383,8 +6383,7 @@ func TestValidatePodSpec(t *testing.T) {
}
}
}
}
// original value will be restored by previous defer
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
PodShareProcessNamespace
,
false
)()
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
PodShareProcessNamespace
,
false
)
featuregatedCases
:=
map
[
string
]
core
.
PodSpec
{
featuregatedCases
:=
map
[
string
]
core
.
PodSpec
{
"set ShareProcessNamespace"
:
{
"set ShareProcessNamespace"
:
{
...
...
pkg/controller/volume/persistentvolume/index_test.go
View file @
70ad4dff
...
@@ -1161,19 +1161,20 @@ func TestVolumeModeCheck(t *testing.T) {
...
@@ -1161,19 +1161,20 @@ func TestVolumeModeCheck(t *testing.T) {
}
}
for
name
,
scenario
:=
range
scenarios
{
for
name
,
scenario
:=
range
scenarios
{
recover
:=
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
scenario
.
enableBlock
)
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
expectedMismatch
,
err
:=
checkVolumeModeMismatches
(
&
scenario
.
pvc
.
Spec
,
&
scenario
.
vol
.
Spec
)
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
scenario
.
enableBlock
)()
if
err
!=
nil
{
expectedMismatch
,
err
:=
checkVolumeModeMismatches
(
&
scenario
.
pvc
.
Spec
,
&
scenario
.
vol
.
Spec
)
t
.
Errorf
(
"Unexpected failure for checkVolumeModeMismatches: %v"
,
err
)
if
err
!=
nil
{
}
t
.
Errorf
(
"Unexpected failure for checkVolumeModeMismatches: %v"
,
err
)
// expected to match but either got an error or no returned pvmatch
}
if
expectedMismatch
&&
!
scenario
.
isExpectedMismatch
{
// expected to match but either got an error or no returned pvmatch
t
.
Errorf
(
"Unexpected failure for scenario, expected not to mismatch on modes but did: %s"
,
name
)
if
expectedMismatch
&&
!
scenario
.
isExpectedMismatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario, expected not to mismatch on modes but did: %s"
,
name
)
if
!
expectedMismatch
&&
scenario
.
isExpectedMismatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario, did not mismatch on mode when expected to mismatch: %s"
,
name
)
if
!
expectedMismatch
&&
scenario
.
isExpectedMismatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario, did not mismatch on mode when expected to mismatch: %s"
,
name
)
recover
()
}
})
}
}
}
}
...
@@ -1252,23 +1253,24 @@ func TestFilteringVolumeModes(t *testing.T) {
...
@@ -1252,23 +1253,24 @@ func TestFilteringVolumeModes(t *testing.T) {
}
}
for
name
,
scenario
:=
range
scenarios
{
for
name
,
scenario
:=
range
scenarios
{
recover
:=
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
scenario
.
enableBlock
)
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
pvmatch
,
err
:=
scenario
.
vol
.
findBestMatchForClaim
(
scenario
.
pvc
,
false
)
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
scenario
.
enableBlock
)()
// expected to match but either got an error or no returned pvmatch
pvmatch
,
err
:=
scenario
.
vol
.
findBestMatchForClaim
(
scenario
.
pvc
,
false
)
if
pvmatch
==
nil
&&
scenario
.
isExpectedMatch
{
// expected to match but either got an error or no returned pvmatch
t
.
Errorf
(
"Unexpected failure for scenario, no matching volume: %s"
,
name
)
if
pvmatch
==
nil
&&
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario, no matching volume: %s"
,
name
)
if
err
!=
nil
&&
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario: %s - %+v"
,
name
,
err
)
if
err
!=
nil
&&
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario: %s - %+v"
,
name
,
err
)
// expected to not match but either got an error or a returned pvmatch
}
if
pvmatch
!=
nil
&&
!
scenario
.
isExpectedMatch
{
// expected to not match but either got an error or a returned pvmatch
t
.
Errorf
(
"Unexpected failure for scenario, expected no matching volume: %s"
,
name
)
if
pvmatch
!=
nil
&&
!
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario, expected no matching volume: %s"
,
name
)
if
err
!=
nil
&&
!
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario: %s - %+v"
,
name
,
err
)
if
err
!=
nil
&&
!
scenario
.
isExpectedMatch
{
}
t
.
Errorf
(
"Unexpected failure for scenario: %s - %+v"
,
name
,
err
)
recover
()
}
})
}
}
}
}
...
...
pkg/kubelet/cm/helpers_linux_test.go
View file @
70ad4dff
...
@@ -274,8 +274,7 @@ func TestResourceConfigForPodWithCustomCPUCFSQuotaPeriod(t *testing.T) {
...
@@ -274,8 +274,7 @@ func TestResourceConfigForPodWithCustomCPUCFSQuotaPeriod(t *testing.T) {
tunedQuotaPeriod
:=
uint64
(
5
*
time
.
Millisecond
/
time
.
Microsecond
)
tunedQuotaPeriod
:=
uint64
(
5
*
time
.
Millisecond
/
time
.
Microsecond
)
tunedQuota
:=
int64
(
1
*
time
.
Millisecond
/
time
.
Microsecond
)
tunedQuota
:=
int64
(
1
*
time
.
Millisecond
/
time
.
Microsecond
)
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
pkgfeatures
.
CPUCFSQuotaPeriod
,
true
)
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
pkgfeatures
.
CPUCFSQuotaPeriod
,
true
)()
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
pkgfeatures
.
CPUCFSQuotaPeriod
,
false
)
minShares
:=
uint64
(
MinShares
)
minShares
:=
uint64
(
MinShares
)
burstableShares
:=
MilliCPUToShares
(
100
)
burstableShares
:=
MilliCPUToShares
(
100
)
...
...
pkg/kubelet/kuberuntime/helpers_linux_test.go
View file @
70ad4dff
...
@@ -89,8 +89,7 @@ func TestMilliCPUToQuota(t *testing.T) {
...
@@ -89,8 +89,7 @@ func TestMilliCPUToQuota(t *testing.T) {
}
}
func
TestMilliCPUToQuotaWithCustomCPUCFSQuotaPeriod
(
t
*
testing
.
T
)
{
func
TestMilliCPUToQuotaWithCustomCPUCFSQuotaPeriod
(
t
*
testing
.
T
)
{
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
CPUCFSQuotaPeriod
,
true
)
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
CPUCFSQuotaPeriod
,
true
)()
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
CPUCFSQuotaPeriod
,
false
)
for
_
,
testCase
:=
range
[]
struct
{
for
_
,
testCase
:=
range
[]
struct
{
msg
string
msg
string
...
...
pkg/kubelet/kuberuntime/helpers_test.go
View file @
70ad4dff
...
@@ -351,8 +351,7 @@ func TestNamespacesForPod(t *testing.T) {
...
@@ -351,8 +351,7 @@ func TestNamespacesForPod(t *testing.T) {
assert
.
Equal
(
t
,
test
.
expected
,
actual
)
assert
.
Equal
(
t
,
test
.
expected
,
actual
)
}
}
// Test ShareProcessNamespace feature disabled, feature gate restored by previous defer
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
PodShareProcessNamespace
,
false
)()
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
PodShareProcessNamespace
,
false
)
for
desc
,
test
:=
range
map
[
string
]
struct
{
for
desc
,
test
:=
range
map
[
string
]
struct
{
input
*
v1
.
Pod
input
*
v1
.
Pod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment