Skip to content

Commit c2189c7

Browse files
committed
tests: Fix TestBGPAgentCRUD
Change our deployment so that we use the static scheduler, and rework the test to handle this. Instead of waiting for the speaker to be associated with an agent (which won't happen with the static scheduler) we now jump straight to assigning it. Signed-off-by: Stephen Finucane <[email protected]> Closes: gophercloud#3380
1 parent c295505 commit c2189c7

2 files changed

Lines changed: 5 additions & 55 deletions

File tree

‎.github/workflows/functional-networking.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
enable_plugin neutron-vpnaas https://github.com/openstack/neutron-vpnaas ${{ matrix.openstack_version }}
4747
enable_plugin networking-bgpvpn https://github.com/openstack/networking-bgpvpn.git ${{ matrix.openstack_version }}
4848
Q_ML2_PLUGIN_EXT_DRIVERS=qos,port_security,dns_domain_keywords
49+
BGP_SCHEDULER_DRIVER=neutron_dynamic_routing.services.bgp.scheduler.bgp_dragent_scheduler.StaticScheduler
4950
5051
[[post-config|\$NEUTRON_CONF]]
5152
[oslo_policy]

‎internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go‎

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -128,61 +128,10 @@ func TestBGPAgentCRUD(t *testing.T) {
128128
th.AssertNoErr(t, err)
129129
th.AssertIntGreaterOrEqual(t, len(bgpAgents), 1)
130130

131-
// List the BGP Agents that accommodate the BGP Speaker
132-
err = tools.WaitForTimeout(
133-
func(ctx context.Context) (bool, error) {
134-
flag := true
135-
for _, agt := range bgpAgents {
136-
t.Logf("BGP Speaker %s has been scheduled to agent %s", bgpSpeaker.ID, agt.ID)
137-
bgpAgent, err := agents.Get(ctx, client, agt.ID).Extract()
138-
th.AssertNoErr(t, err)
139-
numOfSpeakers := int(bgpAgent.Configurations["bgp_speakers"].(float64))
140-
flag = flag && (numOfSpeakers == 1)
141-
}
142-
return flag, nil
143-
}, timeout)
144-
th.AssertNoErr(t, err)
145-
146-
// List the BGP speakers on the first agent
147-
bgpAgent, err := agents.Get(context.TODO(), client, bgpAgents[0].ID).Extract()
148-
th.AssertNoErr(t, err)
149-
agentConf := bgpAgent.Configurations
150-
numOfSpeakers := int(agentConf["bgp_speakers"].(float64))
151-
t.Logf("Agent %s has %d speaker(s)", bgpAgents[0].ID, numOfSpeakers)
152-
153-
pages, err = agents.ListBGPSpeakers(client, bgpAgents[0].ID).AllPages(context.TODO())
154-
th.AssertNoErr(t, err)
155-
allSpeakers, err := agents.ExtractBGPSpeakers(pages)
156-
th.AssertNoErr(t, err)
157-
out := "Speakers:"
158-
for _, speaker := range allSpeakers {
159-
out += " " + speaker.ID
160-
}
161-
t.Log(out)
162-
163-
// Remove the BGP Speaker from the first agent
164-
err = agents.RemoveBGPSpeaker(context.TODO(), client, bgpAgents[0].ID, bgpSpeaker.ID).ExtractErr()
165-
th.AssertNoErr(t, err)
166-
t.Logf("BGP Speaker %s has been removed from agent %s", bgpSpeaker.ID, bgpAgents[0].ID)
167-
err = tools.WaitForTimeout(
168-
func(ctx context.Context) (bool, error) {
169-
bgpAgent, err := agents.Get(ctx, client, bgpAgents[0].ID).Extract()
170-
th.AssertNoErr(t, err)
171-
agentConf := bgpAgent.Configurations
172-
numOfSpeakers := int(agentConf["bgp_speakers"].(float64))
173-
t.Logf("Agent %s has %d speaker(s)", bgpAgent.ID, numOfSpeakers)
174-
return numOfSpeakers == 0, nil
175-
}, timeout)
176-
th.AssertNoErr(t, err)
177-
178-
// Remove all BGP Speakers from the agent
179-
pages, err = agents.ListBGPSpeakers(client, bgpAgents[0].ID).AllPages(context.TODO())
180-
th.AssertNoErr(t, err)
181-
allSpeakers, err = agents.ExtractBGPSpeakers(pages)
182-
th.AssertNoErr(t, err)
183-
for _, speaker := range allSpeakers {
184-
th.AssertNoErr(t, agents.RemoveBGPSpeaker(context.TODO(), client, bgpAgents[0].ID, speaker.ID).ExtractErr())
185-
}
131+
// FIXME(stephenfin): How can we ensure this only runs when the StaticScheduler is present
132+
// (or change our behavior depending on what's enabled)? This flag is not API discoverable.
133+
//
134+
// https://docs.openstack.org/neutron-dynamic-routing/latest/admin/agent-scheduler.html
186135

187136
// Schedule a BGP Speaker to an agent
188137
opts := agents.ScheduleBGPSpeakerOpts{

0 commit comments

Comments
 (0)