Skip to content

Commit 244084b

Browse files
authored
Kickoff 5.2.0 development [API-1564] (#609)
* Kickoff 5.2.0 development This PR contains various fixes to make the client compatible with the 5.2 server. - Server version used in tests bumped to 5.2.2 - For Compact, field kinds are updated with the up-to-date enum values and they are moved to the serialization.api from compact, to match with the Java side - Dependency on the enterprise-tests JAR is removed and the self-signed certificates that we depend on moved to the client-side, instead of adding a dependency to the private test artifacts. - Some reactor related tests that fail on macOS are fixed * add unsupported field kinds * fix broken test
1 parent 1348e39 commit 244084b

File tree

14 files changed

+140
-146
lines changed

14 files changed

+140
-146
lines changed

hazelcast/serialization/api.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import abc
55
import datetime
66
import decimal
7+
import enum
78
import typing
89

910
from hazelcast.serialization.portable.classdef import FieldType
@@ -1381,7 +1382,7 @@ class CompactReader(abc.ABC):
13811382
"""
13821383

13831384
@abc.abstractmethod
1384-
def get_field_kind(self, field_name):
1385+
def get_field_kind(self, field_name: str) -> "FieldKind":
13851386
"""Returns the FieldKind for the given field.
13861387
13871388
Args:
@@ -2593,3 +2594,61 @@ def get_type_name(self) -> str:
25932594
Returns:
25942595
The type name.
25952596
"""
2597+
2598+
2599+
class FieldKind(enum.IntEnum):
2600+
"""
2601+
Represents the types of the fields used in the Compact serialization.
2602+
"""
2603+
2604+
NOT_AVAILABLE = 0
2605+
"""
2606+
Represents fields that do not exist.
2607+
"""
2608+
2609+
BOOLEAN = 1
2610+
ARRAY_OF_BOOLEAN = 2
2611+
INT8 = 3
2612+
ARRAY_OF_INT8 = 4
2613+
CHAR = 5
2614+
ARRAY_OF_CHAR = 6
2615+
INT16 = 7
2616+
ARRAY_OF_INT16 = 8
2617+
INT32 = 9
2618+
ARRAY_OF_INT32 = 10
2619+
INT64 = 11
2620+
ARRAY_OF_INT64 = 12
2621+
FLOAT32 = 13
2622+
ARRAY_OF_FLOAT32 = 14
2623+
FLOAT64 = 15
2624+
ARRAY_OF_FLOAT64 = 16
2625+
STRING = 17
2626+
ARRAY_OF_STRING = 18
2627+
DECIMAL = 19
2628+
ARRAY_OF_DECIMAL = 20
2629+
TIME = 21
2630+
ARRAY_OF_TIME = 22
2631+
DATE = 23
2632+
ARRAY_OF_DATE = 24
2633+
TIMESTAMP = 25
2634+
ARRAY_OF_TIMESTAMP = 26
2635+
TIMESTAMP_WITH_TIMEZONE = 27
2636+
ARRAY_OF_TIMESTAMP_WITH_TIMEZONE = 28
2637+
COMPACT = 29
2638+
ARRAY_OF_COMPACT = 30
2639+
PORTABLE = 31
2640+
ARRAY_OF_PORTABLE = 32
2641+
NULLABLE_BOOLEAN = 33
2642+
ARRAY_OF_NULLABLE_BOOLEAN = 34
2643+
NULLABLE_INT8 = 35
2644+
ARRAY_OF_NULLABLE_INT8 = 36
2645+
NULLABLE_INT16 = 37
2646+
ARRAY_OF_NULLABLE_INT16 = 38
2647+
NULLABLE_INT32 = 39
2648+
ARRAY_OF_NULLABLE_INT32 = 40
2649+
NULLABLE_INT64 = 41
2650+
ARRAY_OF_NULLABLE_INT64 = 42
2651+
NULLABLE_FLOAT32 = 43
2652+
ARRAY_OF_NULLABLE_FLOAT32 = 44
2653+
NULLABLE_FLOAT64 = 45
2654+
ARRAY_OF_NULLABLE_FLOAT64 = 46

hazelcast/serialization/compact.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import collections
33
import datetime
44
import decimal
5-
import enum
65
import typing
76

87
from hazelcast.errors import HazelcastError, HazelcastSerializationError, IllegalStateError
@@ -24,6 +23,7 @@
2423
CompactWriter,
2524
CompactReader,
2625
ObjectDataInput,
26+
FieldKind,
2727
)
2828
from hazelcast.serialization.input import _ObjectDataInput
2929
from hazelcast.serialization.output import _ObjectDataOutput
@@ -1762,8 +1762,6 @@ def _init(self):
17621762

17631763
for field in self.fields_list:
17641764
kind = field.kind
1765-
if kind < 0 or kind >= FieldKind.NOT_AVAILABLE:
1766-
raise HazelcastSerializationError(f"Invalid field kind: {kind}")
17671765
if FIELD_OPERATIONS[field.kind].is_var_sized():
17681766
var_sized_fields.append(field)
17691767
elif FieldKind.BOOLEAN == kind:
@@ -2004,52 +2002,6 @@ def read(self, inp: _ObjectDataInput, start_position: int, index: int) -> int:
20042002
_INT32_POSITION_READER_INSTANCE = Int32PositionReader()
20052003

20062004

2007-
class FieldKind(enum.IntEnum):
2008-
BOOLEAN = 0
2009-
ARRAY_OF_BOOLEAN = 1
2010-
INT8 = 2
2011-
ARRAY_OF_INT8 = 3
2012-
INT16 = 6
2013-
ARRAY_OF_INT16 = 7
2014-
INT32 = 8
2015-
ARRAY_OF_INT32 = 9
2016-
INT64 = 10
2017-
ARRAY_OF_INT64 = 11
2018-
FLOAT32 = 12
2019-
ARRAY_OF_FLOAT32 = 13
2020-
FLOAT64 = 14
2021-
ARRAY_OF_FLOAT64 = 15
2022-
STRING = 16
2023-
ARRAY_OF_STRING = 17
2024-
DECIMAL = 18
2025-
ARRAY_OF_DECIMAL = 19
2026-
TIME = 20
2027-
ARRAY_OF_TIME = 21
2028-
DATE = 22
2029-
ARRAY_OF_DATE = 23
2030-
TIMESTAMP = 24
2031-
ARRAY_OF_TIMESTAMP = 25
2032-
TIMESTAMP_WITH_TIMEZONE = 26
2033-
ARRAY_OF_TIMESTAMP_WITH_TIMEZONE = 27
2034-
COMPACT = 28
2035-
ARRAY_OF_COMPACT = 29
2036-
NULLABLE_BOOLEAN = 32
2037-
ARRAY_OF_NULLABLE_BOOLEAN = 33
2038-
NULLABLE_INT8 = 34
2039-
ARRAY_OF_NULLABLE_INT8 = 35
2040-
NULLABLE_INT16 = 36
2041-
ARRAY_OF_NULLABLE_INT16 = 37
2042-
NULLABLE_INT32 = 38
2043-
ARRAY_OF_NULLABLE_INT32 = 39
2044-
NULLABLE_INT64 = 40
2045-
ARRAY_OF_NULLABLE_INT64 = 41
2046-
NULLABLE_FLOAT32 = 42
2047-
ARRAY_OF_NULLABLE_FLOAT32 = 43
2048-
NULLABLE_FLOAT64 = 44
2049-
ARRAY_OF_NULLABLE_FLOAT64 = 45
2050-
NOT_AVAILABLE = 46
2051-
2052-
20532005
class FieldKindOperations(abc.ABC):
20542006
_VAR_SIZE = -1
20552007

@@ -2236,6 +2188,7 @@ class ArrayOfNullableFloat64Operations(FieldKindOperations):
22362188

22372189

22382190
FIELD_OPERATIONS: typing.List[typing.Optional[FieldKindOperations]] = [
2191+
None,
22392192
BooleanOperations(),
22402193
ArrayOfBooleanOperations(),
22412194
Int8Operations(),
@@ -2282,5 +2235,4 @@ class ArrayOfNullableFloat64Operations(FieldKindOperations):
22822235
ArrayOfNullableFloat32Operations(),
22832236
NullableFloat64Operations(),
22842237
ArrayOfNullableFloat64Operations(),
2285-
None,
22862238
]

start_rc.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
from os.path import isfile
55

6-
SERVER_VERSION = "5.1"
6+
SERVER_VERSION = "5.2.2"
77
RC_VERSION = "0.8-SNAPSHOT"
88

99
RELEASE_REPO = "https://repo1.maven.apache.org/maven2"
@@ -74,15 +74,10 @@ def start_rc(stdout=None, stderr=None):
7474

7575
if enterprise_key:
7676
server = download_if_necessary(ENTERPRISE_REPO, "hazelcast-enterprise", SERVER_VERSION)
77-
ep_tests = download_if_necessary(
78-
ENTERPRISE_REPO, "hazelcast-enterprise", SERVER_VERSION, True
79-
)
80-
81-
artifacts.append(server)
82-
artifacts.append(ep_tests)
8377
else:
8478
server = download_if_necessary(REPO, "hazelcast", SERVER_VERSION)
85-
artifacts.append(server)
79+
80+
artifacts.append(server)
8681

8782
class_path = CLASS_PATH_SEPARATOR.join(artifacts)
8883

tests/integration/backward_compatible/serialization/compact_compatibility/compact_compatibility_test.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def __eq__(self, o: object) -> bool:
4848
def __hash__(self) -> int:
4949
return hash(self.string_field)
5050

51+
def __repr__(self):
52+
return f"InnerCompact(string_field={self.string_field})"
53+
5154

5255
class OuterCompact:
5356
def __init__(self, int_field: int, inner_field: InnerCompact):
@@ -64,6 +67,9 @@ def __eq__(self, o: object) -> bool:
6467
def __hash__(self) -> int:
6568
return hash((self.int_field, self.inner_field))
6669

70+
def __repr__(self):
71+
return f"OuterCompact(int_field={self.int_field}, inner_field={self.inner_field})"
72+
6773

6874
class InnerSerializer(CompactSerializer[InnerCompact]):
6975
def read(self, reader: CompactReader) -> InnerCompact:
@@ -272,7 +278,7 @@ def get_class(self):
272278

273279

274280
@unittest.skipIf(
275-
compare_client_version("5.1") < 0, "Tests the features added in 5.1 version of the client"
281+
compare_client_version("5.2") < 0, "Tests the features added in 5.2 version of the client"
276282
)
277283
class CompactCompatibilityBase(HazelcastTestCase):
278284
rc = None
@@ -282,24 +288,15 @@ class CompactCompatibilityBase(HazelcastTestCase):
282288
@classmethod
283289
def setUpClass(cls) -> None:
284290
cls.rc = cls.create_rc()
285-
if compare_server_version_with_rc(cls.rc, "5.1") < 0:
291+
if compare_server_version_with_rc(cls.rc, "5.2") < 0:
286292
cls.rc.exit()
287-
raise unittest.SkipTest("Compact serialization requires 5.1 server")
288-
289-
if compare_server_version_with_rc(cls.rc, "5.2") >= 0 and compare_client_version("5.2") < 0:
290-
cls.rc.exit()
291-
raise unittest.SkipTest(
292-
"Compact serialization 5.2 server is not compatible with clients older than 5.2"
293-
)
293+
raise unittest.SkipTest("Compact serialization requires 5.2 server")
294294

295295
config = f"""
296296
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
297297
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
298298
xsi:schemaLocation="http://www.hazelcast.com/schema/config
299-
http://www.hazelcast.com/schema/config/hazelcast-config-5.1.xsd">
300-
<serialization>
301-
<compact-serialization enabled="true" />
302-
</serialization>
299+
http://www.hazelcast.com/schema/config/hazelcast-config-5.2.xsd">
303300
<jet enabled="true" />
304301
</hazelcast>
305302
"""
@@ -1777,6 +1774,6 @@ def _put_from_another_client(self, key, value):
17771774
class PartitionServiceCompactCompatibilityTest(CompactCompatibilityBase):
17781775
def test_partition_service(self):
17791776
self.assertEqual(
1780-
268,
1777+
267,
17811778
self.client.partition_service.get_partition_id(OUTER_COMPACT_INSTANCE),
17821779
)

tests/integration/backward_compatible/serialization/compact_test.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
CompactSerializer,
2626
CompactReader,
2727
CompactWriter,
28+
FieldKind,
2829
)
29-
from hazelcast.serialization.compact import FIELD_OPERATIONS, FieldKind
30+
from hazelcast.serialization.compact import FIELD_OPERATIONS
3031

3132
_COMPACT_AVAILABLE = True
3233
except ImportError:
@@ -91,7 +92,7 @@ class FieldKind(enum.Enum):
9192

9293

9394
@unittest.skipIf(
94-
compare_client_version("5.1") < 0, "Tests the features added in 5.1 version of the client"
95+
compare_client_version("5.2") < 0, "Tests the features added in 5.2 version of the client"
9596
)
9697
class CompactTestBase(HazelcastTestCase):
9798
rc = None
@@ -101,28 +102,11 @@ class CompactTestBase(HazelcastTestCase):
101102
@classmethod
102103
def setUpClass(cls) -> None:
103104
cls.rc = cls.create_rc()
104-
if compare_server_version_with_rc(cls.rc, "5.1") < 0:
105+
if compare_server_version_with_rc(cls.rc, "5.2") < 0:
105106
cls.rc.exit()
106-
raise unittest.SkipTest("Compact serialization requires 5.1 server")
107+
raise unittest.SkipTest("Compact serialization requires 5.2 server")
107108

108-
if compare_server_version_with_rc(cls.rc, "5.2") >= 0 and compare_client_version("5.2") < 0:
109-
cls.rc.exit()
110-
raise unittest.SkipTest(
111-
"Compact serialization 5.2 server is not compatible with clients older than 5.2"
112-
)
113-
114-
config = """
115-
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
116-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
117-
xsi:schemaLocation="http://www.hazelcast.com/schema/config
118-
http://www.hazelcast.com/schema/config/hazelcast-config-5.1.xsd">
119-
<serialization>
120-
<compact-serialization enabled="true" />
121-
</serialization>
122-
</hazelcast>
123-
"""
124-
125-
cls.cluster = cls.create_cluster(cls.rc, config)
109+
cls.cluster = cls.create_cluster(cls.rc, None)
126110
cls.member = cls.cluster.start_member()
127111

128112
@classmethod

tests/integration/backward_compatible/ssl_tests/hazelcast-ma-optional.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
<network>
66
<ssl enabled="true">
77
<factory-class-name>
8-
com.hazelcast.nio.ssl.ClasspathSSLContextFactory
8+
com.hazelcast.nio.ssl.BasicSSLContextFactory
99
</factory-class-name>
1010
<properties>
11-
<property name="keyStore">com/hazelcast/nio/ssl-mutual-auth/server1.keystore</property>
11+
<property name="keyStore">%s</property>
1212
<property name="keyStorePassword">password</property>
13-
<property name="trustStore">com/hazelcast/nio/ssl-mutual-auth/server1_knows_client1/server1.truststore
14-
</property>
13+
<property name="trustStore">%s</property>
1514
<property name="trustStorePassword">password</property>
1615
<property name="trustManagerAlgorithm">SunX509</property>
1716
<property name="javax.net.ssl.mutualAuthentication">OPTIONAL</property>

tests/integration/backward_compatible/ssl_tests/hazelcast-ma-required.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
<network>
66
<ssl enabled="true">
77
<factory-class-name>
8-
com.hazelcast.nio.ssl.ClasspathSSLContextFactory
8+
com.hazelcast.nio.ssl.BasicSSLContextFactory
99
</factory-class-name>
1010
<properties>
11-
<property name="keyStore">com/hazelcast/nio/ssl-mutual-auth/server1.keystore</property>
11+
<property name="keyStore">%s</property>
1212
<property name="keyStorePassword">password</property>
13-
<property name="trustStore">com/hazelcast/nio/ssl-mutual-auth/server1_knows_client1/server1.truststore
14-
</property>
13+
<property name="trustStore">%s</property>
1514
<property name="trustStorePassword">password</property>
1615
<property name="trustManagerAlgorithm">SunX509</property>
1716
<property name="javax.net.ssl.mutualAuthentication">REQUIRED</property>

tests/integration/backward_compatible/ssl_tests/hazelcast-ssl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<network>
66
<ssl enabled="true">
77
<factory-class-name>
8-
com.hazelcast.nio.ssl.ClasspathSSLContextFactory
8+
com.hazelcast.nio.ssl.BasicSSLContextFactory
99
</factory-class-name>
1010
<properties>
11-
<property name="keyStore">com/hazelcast/nio/ssl-mutual-auth/server1.keystore</property>
11+
<property name="keyStore">%s</property>
1212
<property name="keyStorePassword">password</property>
1313
<property name="keyManagerAlgorithm">SunX509</property>
1414
<property name="protocol">TLSv1.2</property>

0 commit comments

Comments
 (0)