Skip to content

Commit

Permalink
update:
Browse files Browse the repository at this point in the history
add agent and mscontext registry failback feature
  • Loading branch information
liangwei3 committed Oct 8, 2023
1 parent f2dd189 commit 37ffd07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 15 additions & 5 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,33 +768,43 @@ motan-service:
m := agent.GetRegistryStatus()
assert.Equal(t, len(m), 1)
for _, mm := range m[0] {
assert.Equal(t, mm.Status, core.NotRegister)
if mm.Service.Path == "helloService" {
assert.Equal(t, mm.Status, core.NotRegister)
}
}
agent.SetAllServicesAvailable()
m = agent.GetRegistryStatus()
for _, mm := range m[0] {
assert.Equal(t, mm.Status, core.RegisterFailed)
if mm.Service.Path == "helloService" {
assert.Equal(t, mm.Status, core.RegisterFailed)
}
}
setRegistryFailSwitcher(false)
time.Sleep(registry.DefaultFailbackInterval * time.Millisecond)
m = agent.GetRegistryStatus()
assert.Equal(t, len(m), 1)
for _, mm := range m[0] {
assert.Equal(t, mm.Status, core.RegisterSuccess)
if mm.Service.Path == "helloService" {
assert.Equal(t, mm.Status, core.RegisterSuccess)
}
}
setRegistryFailSwitcher(true)
agent.SetAllServicesUnavailable()
m = agent.GetRegistryStatus()
assert.Equal(t, len(m), 1)
for _, mm := range m[0] {
assert.Equal(t, mm.Status, core.UnregisterFailed)
if mm.Service.Path == "helloService" {
assert.Equal(t, mm.Status, core.UnregisterFailed)
}
}
setRegistryFailSwitcher(false)
time.Sleep(registry.DefaultFailbackInterval * time.Millisecond)
m = agent.GetRegistryStatus()
assert.Equal(t, len(m), 1)
for _, mm := range m[0] {
assert.Equal(t, mm.Status, core.UnregisterSuccess)
if mm.Service.Path == "helloService" {
assert.Equal(t, mm.Status, core.UnregisterSuccess)
}
}
}

Expand Down
20 changes: 15 additions & 5 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,45 @@ motan-service:
m := mscontext.GetRegistryStatus()
assert.Equal(len(m), 1)
for _, mm := range m[0] {
assert.Equal(mm.Status, motan.NotRegister)
if mm.Service.Path == "testpath" {
assert.Equal(mm.Status, motan.NotRegister)
}
}
setRegistryFailSwitcher(true)
mscontext.ServicesAvailable()
m = mscontext.GetRegistryStatus()
assert.Equal(len(m), 1)
for _, mm := range m[0] {
assert.Equal(mm.Status, motan.RegisterFailed)
if mm.Service.Path == "testpath" {
assert.Equal(mm.Status, motan.RegisterFailed)
}
}
setRegistryFailSwitcher(false)
time.Sleep(registry.DefaultFailbackInterval * time.Millisecond)
m = mscontext.GetRegistryStatus()
assert.Equal(len(m), 1)
for _, mm := range m[0] {
assert.Equal(mm.Status, motan.RegisterSuccess)
if mm.Service.Path == "testpath" {
assert.Equal(mm.Status, motan.RegisterSuccess)
}
}
setRegistryFailSwitcher(true)
mscontext.ServicesUnavailable()
m = mscontext.GetRegistryStatus()
assert.Equal(len(m), 1)
for _, mm := range m[0] {
assert.Equal(mm.Status, motan.UnregisterFailed)
if mm.Service.Path == "testpath" {
assert.Equal(mm.Status, motan.UnregisterFailed)
}
}
setRegistryFailSwitcher(false)
time.Sleep(registry.DefaultFailbackInterval * time.Millisecond)
m = mscontext.GetRegistryStatus()
assert.Equal(len(m), 1)
for _, mm := range m[0] {
assert.Equal(mm.Status, motan.UnregisterSuccess)
if mm.Service.Path == "testpath" {
assert.Equal(mm.Status, motan.UnregisterSuccess)
}
}
}

Expand Down

0 comments on commit 37ffd07

Please sign in to comment.