diff --git a/hazelcast/serialization/api.py b/hazelcast/serialization/api.py
index 6b9489fb21..2219594031 100644
--- a/hazelcast/serialization/api.py
+++ b/hazelcast/serialization/api.py
@@ -4,6 +4,7 @@
import abc
import datetime
import decimal
+import enum
import typing
from hazelcast.serialization.portable.classdef import FieldType
@@ -1381,7 +1382,7 @@ class CompactReader(abc.ABC):
"""
@abc.abstractmethod
- def get_field_kind(self, field_name):
+ def get_field_kind(self, field_name: str) -> "FieldKind":
"""Returns the FieldKind for the given field.
Args:
@@ -2593,3 +2594,61 @@ def get_type_name(self) -> str:
Returns:
The type name.
"""
+
+
+class FieldKind(enum.IntEnum):
+ """
+ Represents the types of the fields used in the Compact serialization.
+ """
+
+ NOT_AVAILABLE = 0
+ """
+ Represents fields that do not exist.
+ """
+
+ BOOLEAN = 1
+ ARRAY_OF_BOOLEAN = 2
+ INT8 = 3
+ ARRAY_OF_INT8 = 4
+ CHAR = 5
+ ARRAY_OF_CHAR = 6
+ INT16 = 7
+ ARRAY_OF_INT16 = 8
+ INT32 = 9
+ ARRAY_OF_INT32 = 10
+ INT64 = 11
+ ARRAY_OF_INT64 = 12
+ FLOAT32 = 13
+ ARRAY_OF_FLOAT32 = 14
+ FLOAT64 = 15
+ ARRAY_OF_FLOAT64 = 16
+ STRING = 17
+ ARRAY_OF_STRING = 18
+ DECIMAL = 19
+ ARRAY_OF_DECIMAL = 20
+ TIME = 21
+ ARRAY_OF_TIME = 22
+ DATE = 23
+ ARRAY_OF_DATE = 24
+ TIMESTAMP = 25
+ ARRAY_OF_TIMESTAMP = 26
+ TIMESTAMP_WITH_TIMEZONE = 27
+ ARRAY_OF_TIMESTAMP_WITH_TIMEZONE = 28
+ COMPACT = 29
+ ARRAY_OF_COMPACT = 30
+ PORTABLE = 31
+ ARRAY_OF_PORTABLE = 32
+ NULLABLE_BOOLEAN = 33
+ ARRAY_OF_NULLABLE_BOOLEAN = 34
+ NULLABLE_INT8 = 35
+ ARRAY_OF_NULLABLE_INT8 = 36
+ NULLABLE_INT16 = 37
+ ARRAY_OF_NULLABLE_INT16 = 38
+ NULLABLE_INT32 = 39
+ ARRAY_OF_NULLABLE_INT32 = 40
+ NULLABLE_INT64 = 41
+ ARRAY_OF_NULLABLE_INT64 = 42
+ NULLABLE_FLOAT32 = 43
+ ARRAY_OF_NULLABLE_FLOAT32 = 44
+ NULLABLE_FLOAT64 = 45
+ ARRAY_OF_NULLABLE_FLOAT64 = 46
diff --git a/hazelcast/serialization/compact.py b/hazelcast/serialization/compact.py
index a0ca94344a..654552233b 100644
--- a/hazelcast/serialization/compact.py
+++ b/hazelcast/serialization/compact.py
@@ -2,7 +2,6 @@
import collections
import datetime
import decimal
-import enum
import typing
from hazelcast.errors import HazelcastError, HazelcastSerializationError, IllegalStateError
@@ -24,6 +23,7 @@
CompactWriter,
CompactReader,
ObjectDataInput,
+ FieldKind,
)
from hazelcast.serialization.input import _ObjectDataInput
from hazelcast.serialization.output import _ObjectDataOutput
@@ -1762,8 +1762,6 @@ def _init(self):
for field in self.fields_list:
kind = field.kind
- if kind < 0 or kind >= FieldKind.NOT_AVAILABLE:
- raise HazelcastSerializationError(f"Invalid field kind: {kind}")
if FIELD_OPERATIONS[field.kind].is_var_sized():
var_sized_fields.append(field)
elif FieldKind.BOOLEAN == kind:
@@ -2004,52 +2002,6 @@ def read(self, inp: _ObjectDataInput, start_position: int, index: int) -> int:
_INT32_POSITION_READER_INSTANCE = Int32PositionReader()
-class FieldKind(enum.IntEnum):
- BOOLEAN = 0
- ARRAY_OF_BOOLEAN = 1
- INT8 = 2
- ARRAY_OF_INT8 = 3
- INT16 = 6
- ARRAY_OF_INT16 = 7
- INT32 = 8
- ARRAY_OF_INT32 = 9
- INT64 = 10
- ARRAY_OF_INT64 = 11
- FLOAT32 = 12
- ARRAY_OF_FLOAT32 = 13
- FLOAT64 = 14
- ARRAY_OF_FLOAT64 = 15
- STRING = 16
- ARRAY_OF_STRING = 17
- DECIMAL = 18
- ARRAY_OF_DECIMAL = 19
- TIME = 20
- ARRAY_OF_TIME = 21
- DATE = 22
- ARRAY_OF_DATE = 23
- TIMESTAMP = 24
- ARRAY_OF_TIMESTAMP = 25
- TIMESTAMP_WITH_TIMEZONE = 26
- ARRAY_OF_TIMESTAMP_WITH_TIMEZONE = 27
- COMPACT = 28
- ARRAY_OF_COMPACT = 29
- NULLABLE_BOOLEAN = 32
- ARRAY_OF_NULLABLE_BOOLEAN = 33
- NULLABLE_INT8 = 34
- ARRAY_OF_NULLABLE_INT8 = 35
- NULLABLE_INT16 = 36
- ARRAY_OF_NULLABLE_INT16 = 37
- NULLABLE_INT32 = 38
- ARRAY_OF_NULLABLE_INT32 = 39
- NULLABLE_INT64 = 40
- ARRAY_OF_NULLABLE_INT64 = 41
- NULLABLE_FLOAT32 = 42
- ARRAY_OF_NULLABLE_FLOAT32 = 43
- NULLABLE_FLOAT64 = 44
- ARRAY_OF_NULLABLE_FLOAT64 = 45
- NOT_AVAILABLE = 46
-
-
class FieldKindOperations(abc.ABC):
_VAR_SIZE = -1
@@ -2236,6 +2188,7 @@ class ArrayOfNullableFloat64Operations(FieldKindOperations):
FIELD_OPERATIONS: typing.List[typing.Optional[FieldKindOperations]] = [
+ None,
BooleanOperations(),
ArrayOfBooleanOperations(),
Int8Operations(),
@@ -2282,5 +2235,4 @@ class ArrayOfNullableFloat64Operations(FieldKindOperations):
ArrayOfNullableFloat32Operations(),
NullableFloat64Operations(),
ArrayOfNullableFloat64Operations(),
- None,
]
diff --git a/start_rc.py b/start_rc.py
index 173a9ba320..f5eb87fdae 100644
--- a/start_rc.py
+++ b/start_rc.py
@@ -3,7 +3,7 @@
import sys
from os.path import isfile
-SERVER_VERSION = "5.1"
+SERVER_VERSION = "5.2.2"
RC_VERSION = "0.8-SNAPSHOT"
RELEASE_REPO = "https://repo1.maven.apache.org/maven2"
@@ -74,15 +74,10 @@ def start_rc(stdout=None, stderr=None):
if enterprise_key:
server = download_if_necessary(ENTERPRISE_REPO, "hazelcast-enterprise", SERVER_VERSION)
- ep_tests = download_if_necessary(
- ENTERPRISE_REPO, "hazelcast-enterprise", SERVER_VERSION, True
- )
-
- artifacts.append(server)
- artifacts.append(ep_tests)
else:
server = download_if_necessary(REPO, "hazelcast", SERVER_VERSION)
- artifacts.append(server)
+
+ artifacts.append(server)
class_path = CLASS_PATH_SEPARATOR.join(artifacts)
diff --git a/tests/integration/backward_compatible/serialization/compact_compatibility/compact_compatibility_test.py b/tests/integration/backward_compatible/serialization/compact_compatibility/compact_compatibility_test.py
index 7ed5485cc7..b5f5d8ba0c 100644
--- a/tests/integration/backward_compatible/serialization/compact_compatibility/compact_compatibility_test.py
+++ b/tests/integration/backward_compatible/serialization/compact_compatibility/compact_compatibility_test.py
@@ -48,6 +48,9 @@ def __eq__(self, o: object) -> bool:
def __hash__(self) -> int:
return hash(self.string_field)
+ def __repr__(self):
+ return f"InnerCompact(string_field={self.string_field})"
+
class OuterCompact:
def __init__(self, int_field: int, inner_field: InnerCompact):
@@ -64,6 +67,9 @@ def __eq__(self, o: object) -> bool:
def __hash__(self) -> int:
return hash((self.int_field, self.inner_field))
+ def __repr__(self):
+ return f"OuterCompact(int_field={self.int_field}, inner_field={self.inner_field})"
+
class InnerSerializer(CompactSerializer[InnerCompact]):
def read(self, reader: CompactReader) -> InnerCompact:
@@ -272,7 +278,7 @@ def get_class(self):
@unittest.skipIf(
- compare_client_version("5.1") < 0, "Tests the features added in 5.1 version of the client"
+ compare_client_version("5.2") < 0, "Tests the features added in 5.2 version of the client"
)
class CompactCompatibilityBase(HazelcastTestCase):
rc = None
@@ -282,24 +288,15 @@ class CompactCompatibilityBase(HazelcastTestCase):
@classmethod
def setUpClass(cls) -> None:
cls.rc = cls.create_rc()
- if compare_server_version_with_rc(cls.rc, "5.1") < 0:
+ if compare_server_version_with_rc(cls.rc, "5.2") < 0:
cls.rc.exit()
- raise unittest.SkipTest("Compact serialization requires 5.1 server")
-
- if compare_server_version_with_rc(cls.rc, "5.2") >= 0 and compare_client_version("5.2") < 0:
- cls.rc.exit()
- raise unittest.SkipTest(
- "Compact serialization 5.2 server is not compatible with clients older than 5.2"
- )
+ raise unittest.SkipTest("Compact serialization requires 5.2 server")
config = f"""
-
-
-
+ http://www.hazelcast.com/schema/config/hazelcast-config-5.2.xsd">
"""
@@ -1777,6 +1774,6 @@ def _put_from_another_client(self, key, value):
class PartitionServiceCompactCompatibilityTest(CompactCompatibilityBase):
def test_partition_service(self):
self.assertEqual(
- 268,
+ 267,
self.client.partition_service.get_partition_id(OUTER_COMPACT_INSTANCE),
)
diff --git a/tests/integration/backward_compatible/serialization/compact_test.py b/tests/integration/backward_compatible/serialization/compact_test.py
index 9ce16a8283..465127459a 100644
--- a/tests/integration/backward_compatible/serialization/compact_test.py
+++ b/tests/integration/backward_compatible/serialization/compact_test.py
@@ -25,8 +25,9 @@
CompactSerializer,
CompactReader,
CompactWriter,
+ FieldKind,
)
- from hazelcast.serialization.compact import FIELD_OPERATIONS, FieldKind
+ from hazelcast.serialization.compact import FIELD_OPERATIONS
_COMPACT_AVAILABLE = True
except ImportError:
@@ -91,7 +92,7 @@ class FieldKind(enum.Enum):
@unittest.skipIf(
- compare_client_version("5.1") < 0, "Tests the features added in 5.1 version of the client"
+ compare_client_version("5.2") < 0, "Tests the features added in 5.2 version of the client"
)
class CompactTestBase(HazelcastTestCase):
rc = None
@@ -101,28 +102,11 @@ class CompactTestBase(HazelcastTestCase):
@classmethod
def setUpClass(cls) -> None:
cls.rc = cls.create_rc()
- if compare_server_version_with_rc(cls.rc, "5.1") < 0:
+ if compare_server_version_with_rc(cls.rc, "5.2") < 0:
cls.rc.exit()
- raise unittest.SkipTest("Compact serialization requires 5.1 server")
+ raise unittest.SkipTest("Compact serialization requires 5.2 server")
- if compare_server_version_with_rc(cls.rc, "5.2") >= 0 and compare_client_version("5.2") < 0:
- cls.rc.exit()
- raise unittest.SkipTest(
- "Compact serialization 5.2 server is not compatible with clients older than 5.2"
- )
-
- config = """
-
-
-
-
-
- """
-
- cls.cluster = cls.create_cluster(cls.rc, config)
+ cls.cluster = cls.create_cluster(cls.rc, None)
cls.member = cls.cluster.start_member()
@classmethod
diff --git a/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-optional.xml b/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-optional.xml
index 9d808eb8e9..a723363105 100644
--- a/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-optional.xml
+++ b/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-optional.xml
@@ -5,13 +5,12 @@
- com.hazelcast.nio.ssl.ClasspathSSLContextFactory
+ com.hazelcast.nio.ssl.BasicSSLContextFactory
- com/hazelcast/nio/ssl-mutual-auth/server1.keystore
+ %s
password
- com/hazelcast/nio/ssl-mutual-auth/server1_knows_client1/server1.truststore
-
+ %s
password
SunX509
OPTIONAL
diff --git a/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-required.xml b/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-required.xml
index 70c1fe7edb..4bda5a2238 100644
--- a/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-required.xml
+++ b/tests/integration/backward_compatible/ssl_tests/hazelcast-ma-required.xml
@@ -5,13 +5,12 @@
- com.hazelcast.nio.ssl.ClasspathSSLContextFactory
+ com.hazelcast.nio.ssl.BasicSSLContextFactory
- com/hazelcast/nio/ssl-mutual-auth/server1.keystore
+ %s
password
- com/hazelcast/nio/ssl-mutual-auth/server1_knows_client1/server1.truststore
-
+ %s
password
SunX509
REQUIRED
diff --git a/tests/integration/backward_compatible/ssl_tests/hazelcast-ssl.xml b/tests/integration/backward_compatible/ssl_tests/hazelcast-ssl.xml
index 1d4043721c..536f75779a 100644
--- a/tests/integration/backward_compatible/ssl_tests/hazelcast-ssl.xml
+++ b/tests/integration/backward_compatible/ssl_tests/hazelcast-ssl.xml
@@ -5,10 +5,10 @@
- com.hazelcast.nio.ssl.ClasspathSSLContextFactory
+ com.hazelcast.nio.ssl.BasicSSLContextFactory
- com/hazelcast/nio/ssl-mutual-auth/server1.keystore
+ %s
password
SunX509
TLSv1.2
diff --git a/tests/integration/backward_compatible/ssl_tests/mutual_authentication_test.py b/tests/integration/backward_compatible/ssl_tests/mutual_authentication_test.py
index 6da82b5c7a..e8020dcdf1 100644
--- a/tests/integration/backward_compatible/ssl_tests/mutual_authentication_test.py
+++ b/tests/integration/backward_compatible/ssl_tests/mutual_authentication_test.py
@@ -23,7 +23,7 @@ def tearDown(self):
self.rc.exit()
def test_ma_required_client_and_server_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(True))
+ cluster = self.create_cluster(self.rc, self.read_config(True))
cluster.start_member()
client = HazelcastClient(
**get_ssl_config(
@@ -38,7 +38,7 @@ def test_ma_required_client_and_server_authenticated(self):
client.shutdown()
def test_ma_required_server_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(True))
+ cluster = self.create_cluster(self.rc, self.read_config(True))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -53,7 +53,7 @@ def test_ma_required_server_not_authenticated(self):
)
def test_ma_required_client_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(True))
+ cluster = self.create_cluster(self.rc, self.read_config(True))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -68,7 +68,7 @@ def test_ma_required_client_not_authenticated(self):
)
def test_ma_required_client_and_server_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(True))
+ cluster = self.create_cluster(self.rc, self.read_config(True))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -83,7 +83,7 @@ def test_ma_required_client_and_server_not_authenticated(self):
)
def test_ma_optional_client_and_server_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(False))
+ cluster = self.create_cluster(self.rc, self.read_config(False))
cluster.start_member()
client = HazelcastClient(
**get_ssl_config(
@@ -98,7 +98,7 @@ def test_ma_optional_client_and_server_authenticated(self):
client.shutdown()
def test_ma_optional_server_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(False))
+ cluster = self.create_cluster(self.rc, self.read_config(False))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -113,7 +113,7 @@ def test_ma_optional_server_not_authenticated(self):
)
def test_ma_optional_client_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(False))
+ cluster = self.create_cluster(self.rc, self.read_config(False))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -128,7 +128,7 @@ def test_ma_optional_client_not_authenticated(self):
)
def test_ma_optional_client_and_server_not_authenticated(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(False))
+ cluster = self.create_cluster(self.rc, self.read_config(False))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -143,7 +143,7 @@ def test_ma_optional_client_and_server_not_authenticated(self):
)
def test_ma_required_with_no_cert_file(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(True))
+ cluster = self.create_cluster(self.rc, self.read_config(True))
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -154,7 +154,7 @@ def test_ma_required_with_no_cert_file(self):
)
def test_ma_optional_with_no_cert_file(self):
- cluster = self.create_cluster(self.rc, self.configure_cluster(False))
+ cluster = self.create_cluster(self.rc, self.read_config(False))
cluster.start_member()
client = HazelcastClient(
**get_ssl_config(
@@ -164,7 +164,12 @@ def test_ma_optional_with_no_cert_file(self):
self.assertTrue(client.lifecycle_service.is_running())
client.shutdown()
- def configure_cluster(self, is_ma_required):
+ def read_config(self, is_ma_required):
file_path = self.ma_req_xml if is_ma_required else self.ma_opt_xml
with open(file_path, "r") as f:
- return f.read()
+ xml_config = f.read()
+
+ curr_dir = os.path.dirname(__file__)
+ keystore_path = get_abs_path(curr_dir, "server1.keystore")
+ truststore_path = get_abs_path(curr_dir, "server1.truststore")
+ return xml_config % (keystore_path, truststore_path)
diff --git a/tests/integration/backward_compatible/ssl_tests/server1.keystore b/tests/integration/backward_compatible/ssl_tests/server1.keystore
new file mode 100644
index 0000000000..790920e333
Binary files /dev/null and b/tests/integration/backward_compatible/ssl_tests/server1.keystore differ
diff --git a/tests/integration/backward_compatible/ssl_tests/server1.truststore b/tests/integration/backward_compatible/ssl_tests/server1.truststore
new file mode 100644
index 0000000000..1e7c04e6ff
Binary files /dev/null and b/tests/integration/backward_compatible/ssl_tests/server1.truststore differ
diff --git a/tests/integration/backward_compatible/ssl_tests/ssl_test.py b/tests/integration/backward_compatible/ssl_tests/ssl_test.py
index b8b2bfd3bd..f6ca9e500c 100644
--- a/tests/integration/backward_compatible/ssl_tests/ssl_test.py
+++ b/tests/integration/backward_compatible/ssl_tests/ssl_test.py
@@ -23,14 +23,14 @@ def tearDown(self):
self.rc.exit()
def test_ssl_disabled(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
with self.assertRaises(HazelcastError):
HazelcastClient(**get_ssl_config(cluster.id, False))
def test_ssl_enabled_is_client_live(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
client = HazelcastClient(
@@ -42,11 +42,7 @@ def test_ssl_enabled_is_client_live(self):
client.shutdown()
def test_ssl_enabled_trust_default_certificates(self):
- cluster_config = self.read_configuration(self.default_ca_xml)
- keystore_path = get_abs_path(self.current_directory, "keystore.jks")
- cluster_config = cluster_config % (keystore_path, keystore_path)
-
- cluster = self.create_cluster(self.rc, cluster_config)
+ cluster = self.create_cluster(self.rc, self.read_default_ca_config())
cluster.start_member()
client = HazelcastClient(**get_ssl_config(cluster.id, True))
@@ -55,14 +51,14 @@ def test_ssl_enabled_trust_default_certificates(self):
def test_ssl_enabled_dont_trust_self_signed_certificates(self):
# Member started with self-signed certificate
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
with self.assertRaises(HazelcastError):
HazelcastClient(**get_ssl_config(cluster.id, True))
def test_ssl_enabled_map_size(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
client = HazelcastClient(
@@ -76,7 +72,7 @@ def test_ssl_enabled_map_size(self):
client.shutdown()
def test_ssl_enabled_with_custom_ciphers(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
client = HazelcastClient(
@@ -91,7 +87,7 @@ def test_ssl_enabled_with_custom_ciphers(self):
client.shutdown()
def test_ssl_enabled_with_invalid_ciphers(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
with self.assertRaises(HazelcastError):
@@ -105,7 +101,7 @@ def test_ssl_enabled_with_invalid_ciphers(self):
)
def test_ssl_enabled_with_protocol_mismatch(self):
- cluster = self.create_cluster(self.rc, self.read_configuration(self.hazelcast_ssl_xml))
+ cluster = self.create_cluster(self.rc, self.read_ssl_config())
cluster.start_member()
# Member configured with TLSv1
@@ -119,7 +115,16 @@ def test_ssl_enabled_with_protocol_mismatch(self):
)
)
- @staticmethod
- def read_configuration(filename):
- with open(filename, "r") as f:
- return f.read()
+ def read_default_ca_config(self):
+ with open(self.default_ca_xml, "r") as f:
+ xml_config = f.read()
+
+ keystore_path = get_abs_path(self.current_directory, "keystore.jks")
+ return xml_config % (keystore_path, keystore_path)
+
+ def read_ssl_config(self):
+ with open(self.hazelcast_ssl_xml, "r") as f:
+ xml_config = f.read()
+
+ keystore_path = get_abs_path(self.current_directory, "server1.keystore")
+ return xml_config % keystore_path
diff --git a/tests/unit/reactor_test.py b/tests/unit/reactor_test.py
index f4bd3c4033..0e8fc1a44c 100644
--- a/tests/unit/reactor_test.py
+++ b/tests/unit/reactor_test.py
@@ -1,4 +1,5 @@
import os
+import select
import socket
import threading
import unittest
@@ -182,6 +183,8 @@ def test_wake(self):
self.assertFalse(waker.awake)
waker.wake()
self.assertTrue(waker.awake)
+ # Wait until the reader becomes readable
+ select.select([waker._reader], [], [], 10)
self.assertEqual(b"x", waker._reader.recv(1))
def test_wake_while_awake(self):
@@ -189,17 +192,20 @@ def test_wake_while_awake(self):
waker.wake()
waker.wake()
self.assertTrue(waker.awake)
+ # Wait until the reader becomes readable
+ select.select([waker._reader], [], [], 10)
self.assertEqual(b"x", waker._reader.recv(2)) # only the first one should write
def test_handle_read(self):
waker = self.waker
waker.wake()
self.assertTrue(waker.awake)
+ # Wait until the reader becomes readable
+ select.select([waker._reader], [], [], 10)
waker.handle_read()
self.assertFalse(waker.awake)
- # BlockingIOError on Py3, socket.error on Py2
- with self.assertRaises((IOError, socket.error)):
+ with self.assertRaises(IOError):
# handle_read should consume the socket, there should be nothing
waker._reader.recv(1)
@@ -316,7 +322,7 @@ def test_socket_options(self):
try:
# By default this is set to 0
- self.assertEqual(1, conn.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR))
+ self.assertNotEqual(0, conn.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR))
finally:
conn._inner_close()
diff --git a/tests/unit/serialization/compact_test.py b/tests/unit/serialization/compact_test.py
index 7662bca621..663912b6c3 100644
--- a/tests/unit/serialization/compact_test.py
+++ b/tests/unit/serialization/compact_test.py
@@ -8,7 +8,7 @@
from hazelcast.config import Config
from hazelcast.errors import HazelcastSerializationError
from hazelcast.serialization import SerializationServiceV1
-from hazelcast.serialization.api import CompactSerializer, CompactReader, CompactWriter
+from hazelcast.serialization.api import CompactSerializer, CompactReader, CompactWriter, FieldKind
from hazelcast.serialization.compact import (
RabinFingerprint,
SchemaWriter,
@@ -16,7 +16,6 @@
Schema,
FIELD_OPERATIONS,
_BOOLEANS_PER_BYTE,
- FieldKind,
SchemaNotReplicatedError,
)
@@ -80,7 +79,7 @@ def test_schema(self):
writer.write_int8("age", 0)
writer.write_array_of_timestamp("times", [])
schema = writer.build()
- self.assertEqual(-5445839760245891300, schema.schema_id)
+ self.assertEqual(3662264393229655598, schema.schema_id)
class SchemaTest(unittest.TestCase):
@@ -88,17 +87,11 @@ def test_constructor(self):
fields = [
FieldDescriptor(kind.name, kind)
for kind in FieldKind
- if kind is not FieldKind.NOT_AVAILABLE
+ if FIELD_OPERATIONS[kind] is not None
]
schema = Schema("something", fields)
self._verify_schema(schema, fields)
- def test_constructor_with_invalid_field_kind(self):
- fd = FieldDescriptor("foo", FieldKind.NOT_AVAILABLE)
- self.assertRaises(HazelcastSerializationError, lambda: Schema("foo", [fd]))
- fd.kind = -1
- self.assertRaises(HazelcastSerializationError, lambda: Schema("foo", [fd]))
-
def test_with_no_fields(self):
schema = Schema("something", [])
self.assertEqual({}, schema.fields)