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
8f6f3820
Commit
8f6f3820
authored
Sep 28, 2017
by
m1093782566
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement fakeIPVS update virtual server
parent
6a2ec70a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
fake.go
pkg/util/ipvs/testing/fake.go
+3
-1
fake_test.go
pkg/util/ipvs/testing/fake_test.go
+17
-0
No files found.
pkg/util/ipvs/testing/fake.go
View file @
8f6f3820
...
@@ -77,11 +77,13 @@ func (f *FakeIPVS) AddVirtualServer(serv *utilipvs.VirtualServer) error {
...
@@ -77,11 +77,13 @@ func (f *FakeIPVS) AddVirtualServer(serv *utilipvs.VirtualServer) error {
return
nil
return
nil
}
}
//UpdateVirtualServer is a
n empty implementation
//UpdateVirtualServer is a
fake implementation, it updates the VirtualServer in the cache store.
func
(
f
*
FakeIPVS
)
UpdateVirtualServer
(
serv
*
utilipvs
.
VirtualServer
)
error
{
func
(
f
*
FakeIPVS
)
UpdateVirtualServer
(
serv
*
utilipvs
.
VirtualServer
)
error
{
if
serv
==
nil
{
if
serv
==
nil
{
return
fmt
.
Errorf
(
"Failed to update service, service can't be nil"
)
return
fmt
.
Errorf
(
"Failed to update service, service can't be nil"
)
}
}
key
:=
toServiceKey
(
serv
)
f
.
Services
[
key
]
=
serv
return
nil
return
nil
}
}
...
...
pkg/util/ipvs/testing/fake_test.go
View file @
8f6f3820
...
@@ -31,6 +31,7 @@ func TestVirtualServer(t *testing.T) {
...
@@ -31,6 +31,7 @@ func TestVirtualServer(t *testing.T) {
Address
:
net
.
ParseIP
(
"1.2.3.4"
),
Address
:
net
.
ParseIP
(
"1.2.3.4"
),
Port
:
uint16
(
80
),
Port
:
uint16
(
80
),
Protocol
:
string
(
"TCP"
),
Protocol
:
string
(
"TCP"
),
Flags
:
utilipvs
.
FlagHashed
,
}
}
err
:=
fake
.
AddVirtualServer
(
vs1
)
err
:=
fake
.
AddVirtualServer
(
vs1
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -44,6 +45,22 @@ func TestVirtualServer(t *testing.T) {
...
@@ -44,6 +45,22 @@ func TestVirtualServer(t *testing.T) {
if
!
vs1
.
Equal
(
got1
)
{
if
!
vs1
.
Equal
(
got1
)
{
t
.
Errorf
(
"Expect virtual server: %v, got: %v"
,
vs1
,
got1
)
t
.
Errorf
(
"Expect virtual server: %v, got: %v"
,
vs1
,
got1
)
}
}
// Update virtual server
vs12
:=
&
utilipvs
.
VirtualServer
{
Address
:
net
.
ParseIP
(
"1.2.3.4"
),
Port
:
uint16
(
80
),
Protocol
:
string
(
"TCP"
),
Flags
:
utilipvs
.
FlagPersistent
,
}
err
=
fake
.
UpdateVirtualServer
(
vs12
)
if
err
!=
nil
{
t
.
Errorf
(
"Fail to update virutal server, error: %v"
,
err
)
}
// Check the updated virtual server
got12
,
err
:=
fake
.
GetVirtualServer
(
vs1
)
if
!
got12
.
Equal
(
vs12
)
{
t
.
Errorf
(
"Expect virutal server: %v, got: %v"
,
vs12
,
got12
)
}
// Add another virtual server
// Add another virtual server
vs2
:=
&
utilipvs
.
VirtualServer
{
vs2
:=
&
utilipvs
.
VirtualServer
{
Address
:
net
.
ParseIP
(
"10::40"
),
Address
:
net
.
ParseIP
(
"10::40"
),
...
...
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