Skip to content

Commit f343b29

Browse files
committed
Adjust VECTOR type tests when run on Solaris
1 parent 650a167 commit f343b29

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

mysql-connector-python/tests/qa/test_qa_vector_type.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828

2929
"""VECTOR Type Tests."""
3030

31-
import asyncio
3231
import datetime
3332
import math
33+
import os
34+
import platform
3435
import struct
3536
import unittest
3637

@@ -45,6 +46,10 @@
4546
from mysql.connector.errors import DatabaseError, InterfaceError, ProgrammingError
4647

4748

49+
LOCAL_PLATFORM = platform.platform().lower() if hasattr(platform, "platform") else ""
50+
PLATFORM_IS_SOLARIS = "sunos-" in LOCAL_PLATFORM
51+
52+
4853
@unittest.skipIf(
4954
tests.MYSQL_VERSION < (9, 0, 0),
5055
"MySQL Server 8.4.0 and older don't support VECTOR types.",
@@ -431,11 +436,22 @@ def test_ingest_big_endian_encoding(self):
431436
432437
Expect no error but a mismatch between the original sequence and the returned one.
433438
"""
439+
byte_order = ">" # big-endian - true for most modern architectures
440+
err_msg = ""
441+
if PLATFORM_IS_SOLARIS:
442+
# for some legacy architectures "<" must be used to indicate big-endian
443+
_, _, _, _, arch = os.uname()
444+
if "sun4v" in arch.lower():
445+
byte_order = "<"
446+
err_msg = (
447+
f"Solaris with {arch} architecture using byte-order '{byte_order}'"
448+
)
449+
434450
record_id = 6
435451
row = [
436452
record_id,
437453
struct.pack(
438-
f">{len(self.v1)}f", *(tuple(self.v1))
454+
f"{byte_order}{len(self.v1)}f", *(tuple(self.v1))
439455
).hex(), # BigEndian encoding
440456
"Mario",
441457
datetime.date(1967, 3, 17),
@@ -462,7 +478,7 @@ def test_ingest_big_endian_encoding(self):
462478

463479
self.assertEqual(field_type, FieldType.VECTOR)
464480
self.assertIsInstance(v, exp_instance)
465-
self.assertNotEqual(v, self.v1)
481+
self.assertNotEqual(v, self.v1, err_msg)
466482

467483
@tests.foreach_cnx()
468484
def test_vector_max_dim(self):
@@ -889,11 +905,22 @@ async def test_ingest_big_endian_encoding(self):
889905
890906
Expect no error but a mismatch between the original sequence and the returned one.
891907
"""
908+
byte_order = ">" # big-endian - true for most modern architectures
909+
err_msg = ""
910+
if PLATFORM_IS_SOLARIS:
911+
# for some legacy architectures "<" must be used to indicate big-endian
912+
_, _, _, _, arch = os.uname()
913+
if "sun4v" in arch.lower():
914+
byte_order = "<"
915+
err_msg = (
916+
f"Solaris with {arch} architecture using byte-order '{byte_order}'"
917+
)
918+
892919
record_id = 6
893920
row = [
894921
record_id,
895922
struct.pack(
896-
f">{len(self.v1)}f", *(tuple(self.v1))
923+
f"{byte_order}{len(self.v1)}f", *(tuple(self.v1))
897924
).hex(), # BigEndian encoding
898925
"Mario",
899926
datetime.date(1967, 3, 17),
@@ -922,7 +949,7 @@ async def test_ingest_big_endian_encoding(self):
922949

923950
self.assertEqual(field_type, FieldType.VECTOR)
924951
self.assertIsInstance(v, exp_instance)
925-
self.assertNotEqual(v, self.v1)
952+
self.assertNotEqual(v, self.v1, err_msg)
926953

927954
@tests.foreach_cnx()
928955
async def test_vector_max_dim(self):

0 commit comments

Comments
 (0)