Merge "Add delete_agent to AgentsClient"
diff --git a/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
new file mode 100644
index 0000000..21068ec
--- /dev/null
+++ b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - |
+ Adds the new method to AgentsClient that implements agent deletion
+ according to the API [0].
+ [0] https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
+
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index 5068fc4..30ed176 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -15,7 +15,9 @@
from tempest.api.network import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common import utils
+from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
class AgentManagementTestJSON(base.BaseAdminNetworkTest):
@@ -86,3 +88,11 @@
origin_agent = {'description': description}
self.admin_agents_client.update_agent(agent_id=self.agent['id'],
agent=origin_agent)
+
+ @decorators.idempotent_id('b33af888-b6ac-4e68-a0ca-0444c2696cf9')
+ @decorators.attr(type=['negative'])
+ def test_delete_agent_negative(self):
+ non_existent_id = data_utils.rand_uuid()
+ self.assertRaises(
+ lib_exc.NotFound,
+ self.agents_client.delete_agent, non_existent_id)
diff --git a/tempest/lib/services/network/agents_client.py b/tempest/lib/services/network/agents_client.py
index 5068121..9fa4672 100644
--- a/tempest/lib/services/network/agents_client.py
+++ b/tempest/lib/services/network/agents_client.py
@@ -37,6 +37,16 @@
uri = '/agents/%s' % agent_id
return self.show_resource(uri, **fields)
+ def delete_agent(self, agent_id):
+ """Delete agent.
+
+ For a full list of available parameters, please refer to the official
+ API reference:
+ https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
+ """
+ uri = '/agents/%s' % agent_id
+ return self.delete_resource(uri)
+
def list_agents(self, **filters):
"""List all agents.
diff --git a/tempest/tests/lib/services/network/test_agents_client.py b/tempest/tests/lib/services/network/test_agents_client.py
new file mode 100644
index 0000000..aabc6ce
--- /dev/null
+++ b/tempest/tests/lib/services/network/test_agents_client.py
@@ -0,0 +1,37 @@
+# Copyright 2018 AT&T Corporation.
+# All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.lib.services.network import agents_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestAgentsClient(base.BaseServiceTest):
+
+ FAKE_AGENT_ID = "d32019d3-bc6e-4319-9c1d-6123f4135a88"
+
+ def setUp(self):
+ super(TestAgentsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.agents_client = agents_client.AgentsClient(
+ fake_auth, "network", "regionOne")
+
+ def test_delete_agent(self):
+ self.check_service_client_function(
+ self.agents_client.delete_agent,
+ "tempest.lib.common.rest_client.RestClient.delete",
+ {},
+ status=204,
+ agent_id=self.FAKE_AGENT_ID)