# Verify!
# Must add newline at the end to match effect of print call
self.assertEquals(self.fake_stdout.make_string(), output + '\n')
+
+ def _verify_list_ports(self, network_id):
+ # Verification - get raw result from db
+ port_list = db.port_list(network_id)
+ ports = [dict(id=port.uuid, state=port.state)
+ for port in port_list]
+ # Fill CLI template
+ output = cli.prepare_output('list_ports', self.tenant_id,
+ dict(network_id=network_id,
+ ports=ports))
+ # Verify!
+ # Must add newline at the end to match effect of print call
+ self.assertEquals(self.fake_stdout.make_string(), output + '\n')
+
+ def _verify_create_port(self, network_id):
+ # Verification - get raw result from db
+ port_list = db.port_list(network_id)
+ if len(port_list) != 1:
+ self.fail("No port created")
+ port_id = port_list[0].uuid
+ # Fill CLI template
+ output = cli.prepare_output('create_port', self.tenant_id,
+ dict(network_id=network_id,
+ port_id=port_id))
+ # Verify!
+ # Must add newline at the end to match effect of print call
+ self.assertEquals(self.fake_stdout.make_string(), output + '\n')
+
+ def _verify_delete_port(self, network_id, port_id):
+ # Verification - get raw result from db
+ port_list = db.port_list(network_id)
+ if len(port_list) != 0:
+ self.fail("DB should not contain any port")
+ # Fill CLI template
+ output = cli.prepare_output('delete_port', self.tenant_id,
+ dict(network_id=network_id,
+ port_id=port_id))
+ # Verify!
+ # Must add newline at the end to match effect of print call
+ self.assertEquals(self.fake_stdout.make_string(), output + '\n')
+
+ def _verify_set_port_state(self, network_id, port_id):
+ # Verification - get raw result from db
+ port = db.port_get(port_id, network_id)
+ port_data = {'id': port.uuid, 'port-state': port.state}
+ # Fill CLI template
+ output = cli.prepare_output('set_port_state', self.tenant_id,
+ dict(network_id=network_id,
+ port=port_data))
+ # Verify!
+ # Must add newline at the end to match effect of print call
+ self.assertEquals(self.fake_stdout.make_string(), output + '\n')
+
+ def _verify_detail_port(self, network_id, port_id):
+ # Verification - get raw result from db
+ # TODO(salvatore-orlando): Must resolve this issue with
+ # attachment in separate bug fix.
+ port = db.port_get(port_id, network_id)
+ port_data = {'id': port.uuid, 'state': port.state,
+ 'attachment':'<unavailable>'}
+ # Fill CLI template
+ output = cli.prepare_output('detail_port', self.tenant_id,
+ dict(network_id=network_id,
+ port=port_data))
+ # Verify!
+ # Must add newline at the end to match effect of print call
+ self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def test_list_networks(self):
try:
db.network_create(self.tenant_id, self.network_name_2)
cli.list_nets(self.client, self.tenant_id)
- LOG.debug("Operation completed. Verifying result")
- LOG.debug(self.fake_stdout.content)
- self._verify_list_networks()
except:
LOG.exception("Exception caught: %s", sys.exc_info())
self.fail("test_list_networks failed due to an exception")
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_list_networks()
+
def test_create_network(self):
try:
cli.create_net(self.client, self.tenant_id, "test")
- LOG.debug("Operation completed. Verifying result")
- LOG.debug(self.fake_stdout.content)
- self._verify_create_network()
except:
LOG.exception("Exception caught: %s", sys.exc_info())
self.fail("test_create_network failed due to an exception")
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_create_network()
+
def test_delete_network(self):
try:
db.network_create(self.tenant_id, self.network_name_1)
network_id = db.network_list(self.tenant_id)[0]['uuid']
cli.delete_net(self.client, self.tenant_id, network_id)
- LOG.debug("Operation completed. Verifying result")
- LOG.debug(self.fake_stdout.content)
- self._verify_delete_network(network_id)
except:
LOG.exception("Exception caught: %s", sys.exc_info())
self.fail("test_delete_network failed due to an exception")
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_delete_network(network_id)
+
def test_detail_network(self):
# Load some data into the datbase
net = db.network_create(self.tenant_id, self.network_name_1)
network_id = net['uuid']
cli.rename_net(self.client, self.tenant_id,
network_id, self.network_name_2)
- self._verify_rename_network()
except:
LOG.exception("Exception caught: %s", sys.exc_info())
self.fail("test_rename_network failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_rename_network()
+
+ def test_list_ports(self):
+ try:
+ # Pre-populate data for testing using db api
+ net = db.network_create(self.tenant_id, self.network_name_1)
+ network_id = net['uuid']
+ db.port_create(network_id)
+ db.port_create(network_id)
+ cli.list_ports(self.client, self.tenant_id, network_id)
+ except:
+ LOG.exception("Exception caught: %s", sys.exc_info())
+ self.fail("test_list_ports failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_list_ports(network_id)
+
+ def test_create_port(self):
+ network_id = None
+ try:
+ # Pre-populate data for testing using db api
+ net = db.network_create(self.tenant_id, self.network_name_1)
+ network_id = net['uuid']
+ cli.create_port(self.client, self.tenant_id, network_id)
+ except:
+ LOG.exception("Exception caught: %s", sys.exc_info())
+ self.fail("test_create_port failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_create_port(network_id)
+
+ def test_delete_port(self):
+ network_id = None
+ port_id = None
+ try:
+ # Pre-populate data for testing using db api
+ net = db.network_create(self.tenant_id, self.network_name_1)
+ network_id = net['uuid']
+ port = db.port_create(network_id)
+ port_id = port['uuid']
+ cli.delete_port(self.client, self.tenant_id, network_id, port_id)
+ except:
+ LOG.exception("Exception caught: %s", sys.exc_info())
+ self.fail("test_delete_port failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_delete_port(network_id, port_id)
+
+ def test_set_port_state(self):
+ try:
+ net = db.network_create(self.tenant_id, self.network_name_1)
+ network_id = net['uuid']
+ port = db.port_create(network_id)
+ port_id = port['uuid']
+ # Default state is DOWN - change to ACTIVE.
+ cli.set_port_state(self.client, self.tenant_id, network_id,
+ port_id, 'ACTIVE')
+ except:
+ LOG.exception("Exception caught: %s", sys.exc_info())
+ self.fail("test_set_port_state failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_set_port_state(network_id, port_id)
+
+ def test_detail_port(self):
+ network_id = None
+ port_id = None
+ try:
+ # Pre-populate data for testing using db api
+ net = db.network_create(self.tenant_id, self.network_name_1)
+ network_id = net['uuid']
+ port = db.port_create(network_id)
+ port_id = port['uuid']
+ cli.detail_port(self.client, self.tenant_id, network_id, port_id)
+ except:
+ LOG.exception("Exception caught: %s", sys.exc_info())
+ self.fail("test_detail_port failed due to an exception")
+
+ LOG.debug("Operation completed. Verifying result")
+ LOG.debug(self.fake_stdout.content)
+ self._verify_detail_port(network_id, port_id)