From c7b5bfbb64c39ae4c35dd6421b2e28fb8ade4f4c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:50:40 -0800 Subject: [PATCH 1/4] Support force_single_node for testing --- aerospike-client-c | 2 +- src/main/client/type.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/aerospike-client-c b/aerospike-client-c index 57c945dce..da2bf9abb 160000 --- a/aerospike-client-c +++ b/aerospike-client-c @@ -1 +1 @@ -Subproject commit 57c945dcea8c2356106b366569b1af290dc7945b +Subproject commit da2bf9abbe96e8cef351975c9b34f3c95d8bb908 diff --git a/src/main/client/type.c b/src/main/client/type.c index aaacbcac2..b725fd2a3 100644 --- a/src/main/client/type.c +++ b/src/main/client/type.c @@ -1037,22 +1037,22 @@ static int AerospikeClient_Type_Init(AerospikeClient *self, PyObject *args, goto CONSTRUCTOR_ERROR; } - PyObject *py_max_socket_idle = NULL; - py_max_socket_idle = PyDict_GetItemString(py_config, "max_socket_idle"); - if (py_max_socket_idle && PyLong_Check(py_max_socket_idle)) { - long max_socket_idle = PyLong_AsLong(py_max_socket_idle); - if (max_socket_idle >= 0) { - config.max_socket_idle = (uint32_t)max_socket_idle; + bool *bool_config_refs[] = {&config.force_single_node, + config.fail_if_not_connected}; + const char *bool_config_name[] = {"force_single_node", + "fail_if_not_connected"}; + + // TODO: needs better input validation. + // i.e throw an exception if value is not a bool type + for (unsigned long i = 0; + i < sizeof(bool_config_name) / sizeof(bool_config_name[0]); i++) { + PyObject *py_bool_value = + PyDict_GetItemString(py_config, bool_config_name[i]); + if (py_bool_value && PyBool_Check(py_bool_value)) { + *bool_config_refs[i] = PyObject_IsTrue(py_bool_value); } } - PyObject *py_fail_if_not_connected = - PyDict_GetItemString(py_config, "fail_if_not_connected"); - if (py_fail_if_not_connected && PyBool_Check(py_fail_if_not_connected)) { - config.fail_if_not_connected = - PyObject_IsTrue(py_fail_if_not_connected); - } - PyObject *py_user_name = PyDict_GetItemString(py_config, "user"); PyObject *py_user_pwd = PyDict_GetItemString(py_config, "password"); if (py_user_name && PyUnicode_Check(py_user_name) && py_user_pwd && From 45c7e084ab3686d38b75aa0f46b8fb598afb30ec Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:12:30 -0800 Subject: [PATCH 2/4] fix --- src/main/client/type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/client/type.c b/src/main/client/type.c index b725fd2a3..916bbca99 100644 --- a/src/main/client/type.c +++ b/src/main/client/type.c @@ -1038,7 +1038,7 @@ static int AerospikeClient_Type_Init(AerospikeClient *self, PyObject *args, } bool *bool_config_refs[] = {&config.force_single_node, - config.fail_if_not_connected}; + &config.fail_if_not_connected}; const char *bool_config_name[] = {"force_single_node", "fail_if_not_connected"}; From 21b4ba4f1a43ef058b9d725429a4aca73a550b4f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 22 Jan 2025 12:29:12 -0800 Subject: [PATCH 3/4] CI/CD: Fix Python client failing to build in smoke tests. We haven't officially supported Ubuntu 24.04 yet --- .github/workflows/tests.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 65ada314e..82bcbc488 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,7 @@ on: jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 with: @@ -41,7 +41,7 @@ jobs: - uses: pre-commit/action@v3.0.0 build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: py-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] @@ -90,7 +90,7 @@ jobs: path: ./dist/*.whl generate-coverage-report: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 with: @@ -175,7 +175,7 @@ jobs: coverage-upload: needs: generate-coverage-report if: ${{ !cancelled() }} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: @@ -196,7 +196,7 @@ jobs: stubtest: needs: build - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 with: @@ -221,7 +221,7 @@ jobs: # Run this when testing new server features on server release candidate # to make sure the tests don't regress on the last server release. test-ce-latest-release: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 if: ${{ contains(github.event.pull_request.labels.*.name, 'new-server-features') }} needs: build @@ -261,7 +261,7 @@ jobs: working-directory: test test-ce: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build strategy: matrix: @@ -336,7 +336,7 @@ jobs: working-directory: test test-lowest-supported-server: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build steps: - uses: actions/checkout@v2 @@ -374,7 +374,7 @@ jobs: working-directory: test test-ee: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build steps: - uses: actions/checkout@v2 @@ -413,7 +413,7 @@ jobs: cat ./configs/aerospike.conf spellcheck-docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 with: @@ -430,7 +430,7 @@ jobs: working-directory: doc check-links-docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -451,7 +451,7 @@ jobs: - node_close_listener - cluster_name fail-fast: false - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From adfb8bb9a970712dd19ae7b0a2a0355b3ab8945e Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:06:43 -0800 Subject: [PATCH 4/4] add regression test --- test/new_tests/test_new_constructor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/new_tests/test_new_constructor.py b/test/new_tests/test_new_constructor.py index d101ea13a..a0a1108f0 100644 --- a/test/new_tests/test_new_constructor.py +++ b/test/new_tests/test_new_constructor.py @@ -110,9 +110,16 @@ def test_neg_setting_rack_ids(rack_ids): aerospike.client(config) -def test_setting_use_services_alternate(): +@pytest.mark.parametrize( + "setting", + [ + "use_services_alternate", + "force_single_node" + ] +) +def test_bool_settings(setting): config = copy.deepcopy(gconfig) - config["use_services_alternate"] = True + config[setting] = True client = aerospike.client(config) assert client is not None