Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLIENT-3246] Support "force_single_node" client config option for QE Jepsen testing #718

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/main/client/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
11 changes: 9 additions & 2 deletions test/new_tests/test_new_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading