mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
implement fakeIPVS update virtual server
This commit is contained in:
parent
6a2ec70a2d
commit
8f6f382003
@ -77,11 +77,13 @@ func (f *FakeIPVS) AddVirtualServer(serv *utilipvs.VirtualServer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//UpdateVirtualServer is an empty implementation
|
||||
//UpdateVirtualServer is a fake implementation, it updates the VirtualServer in the cache store.
|
||||
func (f *FakeIPVS) UpdateVirtualServer(serv *utilipvs.VirtualServer) error {
|
||||
if serv == nil {
|
||||
return fmt.Errorf("Failed to update service, service can't be nil")
|
||||
}
|
||||
key := toServiceKey(serv)
|
||||
f.Services[key] = serv
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ func TestVirtualServer(t *testing.T) {
|
||||
Address: net.ParseIP("1.2.3.4"),
|
||||
Port: uint16(80),
|
||||
Protocol: string("TCP"),
|
||||
Flags: utilipvs.FlagHashed,
|
||||
}
|
||||
err := fake.AddVirtualServer(vs1)
|
||||
if err != nil {
|
||||
@ -44,6 +45,22 @@ func TestVirtualServer(t *testing.T) {
|
||||
if !vs1.Equal(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
|
||||
vs2 := &utilipvs.VirtualServer{
|
||||
Address: net.ParseIP("10::40"),
|
||||
|
Loading…
Reference in New Issue
Block a user