Merge "Support py34 in Kuryr"
This commit is contained in:
commit
0918ab8741
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
@ -67,11 +66,11 @@ class TestKuryrJoinFailures(base.TestKuryrFailures):
|
||||
processutils.ProcessExecutionError)
|
||||
def test_join_veth_failures(self, GivenException):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_container_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, fake_docker_network_id)
|
||||
@ -115,10 +114,10 @@ class TestKuryrJoinFailures(base.TestKuryrFailures):
|
||||
|
||||
def test_join_bad_request(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
invalid_docker_endpoint_id = 'id-should-be-hexdigits'
|
||||
fake_container_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
response = self._invoke_join_request(
|
||||
fake_docker_network_id, invalid_docker_endpoint_id,
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
@ -60,7 +59,7 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_create_network(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
self.mox.StubOutWithMock(app.neutron, "create_network")
|
||||
fake_request = {
|
||||
"network": {
|
||||
@ -144,7 +143,7 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_create_network_wo_gw(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
self.mox.StubOutWithMock(app.neutron, "create_network")
|
||||
fake_request = {
|
||||
"network": {
|
||||
@ -226,7 +225,7 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_delete_network(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, docker_network_id)
|
||||
self.mox.StubOutWithMock(app.neutron, 'list_subnets')
|
||||
@ -249,9 +248,9 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_delete_network_with_subnets(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, docker_network_id)
|
||||
@ -300,9 +299,9 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_create_endpoint(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, docker_network_id)
|
||||
@ -383,9 +382,9 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_delete_endpoint(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
data = {
|
||||
'NetworkID': docker_network_id,
|
||||
'EndpointID': docker_endpoint_id,
|
||||
@ -400,11 +399,11 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_join(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_container_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, fake_docker_network_id)
|
||||
@ -466,9 +465,9 @@ class TestKuryr(base.TestKuryrBase):
|
||||
|
||||
def test_network_driver_leave(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, fake_docker_network_id)
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
@ -171,9 +170,9 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
|
||||
exceptions.NotFound, exceptions.ServiceUnavailable)
|
||||
def test_create_endpoint_port_failures(self, GivenException):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
fake_neutron_subnet_v4_id = str(uuid.uuid4())
|
||||
fake_neutron_subnet_v6_id = str(uuid.uuid4())
|
||||
@ -215,7 +214,7 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
|
||||
|
||||
def test_create_endpoint_bad_request(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
invalid_docker_endpoint_id = 'id-should-be-hexdigits'
|
||||
|
||||
response = self._invoke_create_request(
|
||||
@ -242,7 +241,7 @@ class TestKuryrEndpointDeleteFailures(TestKuryrEndpointFailures):
|
||||
|
||||
def test_delete_endpoint_bad_request(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
invalid_docker_endpoint_id = 'id-should-be-hexdigits'
|
||||
|
||||
response = self._invoke_delete_request(
|
||||
|
@ -13,7 +13,6 @@
|
||||
import ddt
|
||||
import hashlib
|
||||
from oslo_serialization import jsonutils
|
||||
import random
|
||||
import uuid
|
||||
|
||||
from kuryr.common import config
|
||||
@ -176,7 +175,7 @@ class TestKuryrIpam(base.TestKuryrBase):
|
||||
|
||||
# faking list_subnets
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
neutron_network_id = str(uuid.uuid4())
|
||||
subnet_v4_id = str(uuid.uuid4())
|
||||
fake_v4_subnet = self._get_fake_v4_subnet(
|
||||
@ -241,9 +240,9 @@ class TestKuryrIpam(base.TestKuryrBase):
|
||||
|
||||
# faking list_subnets
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
neutron_network_id = docker_network_id = str(uuid.uuid4())
|
||||
subnet_v4_id = str(uuid.uuid4())
|
||||
fake_v4_subnet = self._get_fake_v4_subnet(
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
|
||||
from ddt import data
|
||||
from ddt import ddt
|
||||
@ -20,6 +19,7 @@ from oslo_serialization import jsonutils
|
||||
|
||||
from kuryr import app
|
||||
from kuryr.tests.unit import base
|
||||
from kuryr import utils
|
||||
|
||||
|
||||
class TestKuryrNetworkCreateFailures(base.TestKuryrFailures):
|
||||
@ -64,7 +64,7 @@ class TestKuryrNetworkCreateFailures(base.TestKuryrFailures):
|
||||
|
||||
def test_create_network_unauthorized(self):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
self._create_network_with_exception(
|
||||
docker_network_id, exceptions.Unauthorized())
|
||||
|
||||
@ -122,9 +122,9 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
subnet_v6_id = "64dd4a98-3d7a-4bfd-acf4-91137a8d2f51"
|
||||
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_v4_subnet = self._get_fake_v4_subnet(
|
||||
docker_network_id, docker_endpoint_id, subnet_v4_id)
|
||||
@ -178,9 +178,9 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
subnet_v6_id = "64dd4a98-3d7a-4bfd-acf4-91137a8d2f51"
|
||||
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_v4_subnet = self._get_fake_v4_subnet(
|
||||
docker_network_id, docker_endpoint_id, subnet_v4_id)
|
||||
@ -218,7 +218,7 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
@data(exceptions.Unauthorized, exceptions.NotFound, exceptions.Conflict)
|
||||
def test_delete_network_failures(self, GivenException):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
self._delete_network_with_exception(
|
||||
docker_network_id, GivenException())
|
||||
|
||||
@ -244,7 +244,7 @@ class TestKuryrNetworkDeleteFailures(base.TestKuryrFailures):
|
||||
def test_delete_network_with_subnet_deletion_failures(self,
|
||||
GivenException):
|
||||
docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
self._delete_network_with_subnet_exception(
|
||||
docker_network_id, GivenException())
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
@ -58,9 +57,9 @@ class TestKuryrLeaveFailures(base.TestKuryrFailures):
|
||||
processutils.ProcessExecutionError)
|
||||
def test_leave_unbinding_failure(self, GivenException):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
|
||||
fake_neutron_network_id = str(uuid.uuid4())
|
||||
self._mock_out_network(fake_neutron_network_id, fake_docker_network_id)
|
||||
@ -94,7 +93,7 @@ class TestKuryrLeaveFailures(base.TestKuryrFailures):
|
||||
|
||||
def test_leave_bad_request(self):
|
||||
fake_docker_network_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
invalid_docker_endpoint_id = 'id-should-be-hexdigits'
|
||||
|
||||
response = self._invoke_leave_request(
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
|
||||
import ddt
|
||||
from oslo_config import cfg
|
||||
@ -24,8 +23,8 @@ from kuryr import utils
|
||||
class TestKuryrUtils(base.TestKuryrBase):
|
||||
"""Unit tests for utilities."""
|
||||
|
||||
@ddt.data(hashlib.sha256(str(random.getrandbits(256))).hexdigest(),
|
||||
'51c75a2515d4' '51c75a')
|
||||
@ddt.data(hashlib.sha256(utils.getrandbits(
|
||||
256)).hexdigest(), '51c75a2515d4' '51c75a')
|
||||
def test_get_sandbox_key(self, fake_container_id):
|
||||
sandbox_key = utils.get_sandbox_key(fake_container_id)
|
||||
expected = '/'.join([utils.DOCKER_NETNS_BASE, fake_container_id[:12]])
|
||||
@ -33,7 +32,7 @@ class TestKuryrUtils(base.TestKuryrBase):
|
||||
|
||||
def test_get_port_name(self):
|
||||
fake_docker_endpoint_id = hashlib.sha256(
|
||||
str(random.getrandbits(256))).hexdigest()
|
||||
utils.getrandbits(256)).hexdigest()
|
||||
generated_neutron_port_name = utils.get_neutron_port_name(
|
||||
fake_docker_endpoint_id)
|
||||
self.assertIn(utils.PORT_POSTFIX, generated_neutron_port_name)
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
import sys
|
||||
import traceback
|
||||
@ -80,7 +81,7 @@ def make_json_app(import_name, **kwargs):
|
||||
response.headers['Content-Type'] = content_type
|
||||
return response
|
||||
|
||||
for code in w_exceptions.default_exceptions.iterkeys():
|
||||
for code in w_exceptions.default_exceptions:
|
||||
app.error_handler_spec[None][code] = make_json_error
|
||||
|
||||
return app
|
||||
@ -138,3 +139,7 @@ def get_dict_format_fixed_ips_from_kv_format(fixed_ips):
|
||||
new_fixed_ips.append({'subnet_id': subnet_id,
|
||||
'ip_address': ip})
|
||||
return new_fixed_ips
|
||||
|
||||
|
||||
def getrandbits(bit_size=256):
|
||||
return str(random.getrandbits(bit_size)).encode('utf-8')
|
||||
|
Loading…
Reference in New Issue
Block a user