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
1386b148
Unverified
Commit
1386b148
authored
Jan 29, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73468 from randmonkey/issue73462_fix_testentry
fix TestEntry
parents
16000e3a
d1f85ffa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
ipset.go
pkg/util/ipset/ipset.go
+1
-1
ipset_test.go
pkg/util/ipset/ipset_test.go
+5
-5
No files found.
pkg/util/ipset/ipset.go
View file @
1386b148
...
@@ -330,7 +330,7 @@ func (runner *runner) DelEntry(entry string, set string) error {
...
@@ -330,7 +330,7 @@ func (runner *runner) DelEntry(entry string, set string) error {
// TestEntry is used to check whether the specified entry is in the set or not.
// TestEntry is used to check whether the specified entry is in the set or not.
func
(
runner
*
runner
)
TestEntry
(
entry
string
,
set
string
)
(
bool
,
error
)
{
func
(
runner
*
runner
)
TestEntry
(
entry
string
,
set
string
)
(
bool
,
error
)
{
if
out
,
err
:=
runner
.
exec
.
Command
(
IPSetCmd
,
"test"
,
set
,
entry
)
.
CombinedOutput
();
err
==
nil
{
if
out
,
err
:=
runner
.
exec
.
Command
(
IPSetCmd
,
"test"
,
set
,
entry
)
.
CombinedOutput
();
err
==
nil
{
reg
,
e
:=
regexp
.
Compile
(
"
NOT"
)
reg
,
e
:=
regexp
.
Compile
(
"
is NOT in set "
+
set
)
if
e
==
nil
&&
reg
.
MatchString
(
string
(
out
))
{
if
e
==
nil
&&
reg
.
MatchString
(
string
(
out
))
{
return
false
,
nil
return
false
,
nil
}
else
if
e
==
nil
{
}
else
if
e
==
nil
{
...
...
pkg/util/ipset/ipset_test.go
View file @
1386b148
...
@@ -461,14 +461,14 @@ func TestTestEntry(t *testing.T) {
...
@@ -461,14 +461,14 @@ func TestTestEntry(t *testing.T) {
Protocol
:
ProtocolTCP
,
Protocol
:
ProtocolTCP
,
SetType
:
HashIPPort
,
SetType
:
HashIPPort
,
}
}
setName
:=
"NOT"
fcmd
:=
fakeexec
.
FakeCmd
{
fcmd
:=
fakeexec
.
FakeCmd
{
CombinedOutputScript
:
[]
fakeexec
.
FakeCombinedOutputAction
{
CombinedOutputScript
:
[]
fakeexec
.
FakeCombinedOutputAction
{
// Success
// Success
func
()
([]
byte
,
error
)
{
return
[]
byte
(
"10.120.7.100,tcp:8080 is in set
FOOBAR
."
),
nil
},
func
()
([]
byte
,
error
)
{
return
[]
byte
(
"10.120.7.100,tcp:8080 is in set
"
+
setName
+
"
."
),
nil
},
// Failure
// Failure
func
()
([]
byte
,
error
)
{
func
()
([]
byte
,
error
)
{
return
[]
byte
(
"192.168.1.3,tcp:8080 is NOT in set
FOOBAR
."
),
&
fakeexec
.
FakeExitError
{
Status
:
1
}
return
[]
byte
(
"192.168.1.3,tcp:8080 is NOT in set
"
+
setName
+
"
."
),
&
fakeexec
.
FakeExitError
{
Status
:
1
}
},
},
},
},
}
}
...
@@ -480,14 +480,14 @@ func TestTestEntry(t *testing.T) {
...
@@ -480,14 +480,14 @@ func TestTestEntry(t *testing.T) {
}
}
runner
:=
New
(
&
fexec
)
runner
:=
New
(
&
fexec
)
// Success
// Success
ok
,
err
:=
runner
.
TestEntry
(
testEntry
.
String
(),
"FOOBAR"
)
ok
,
err
:=
runner
.
TestEntry
(
testEntry
.
String
(),
setName
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"expected success, got %v"
,
err
)
t
.
Errorf
(
"expected success, got %v"
,
err
)
}
}
if
fcmd
.
CombinedOutputCalls
!=
1
{
if
fcmd
.
CombinedOutputCalls
!=
1
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
}
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"ipset"
,
"test"
,
"FOOBAR"
,
"10.120.7.100,tcp:8080"
)
{
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
0
]
...
)
.
HasAll
(
"ipset"
,
"test"
,
setName
,
"10.120.7.100,tcp:8080"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
0
])
}
}
if
!
ok
{
if
!
ok
{
...
...
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