Make backend options a record, move actual options to be sub-records

This commit is contained in:
Tim Wojtulewicz 2025-02-06 14:30:10 -07:00
parent 64f3969434
commit a485b1d237
23 changed files with 71 additions and 73 deletions

View file

@ -37,9 +37,8 @@ type tbl: table[count] of string;
event zeek_init() {
# Create a database file in the .tmp directory with a 'testing' table
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "types_test.sqlite";
opts$table_name = "types_testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "types_test.sqlite", $table_name = "types_testing"];
local key : Rec;
key$hello = "hello";

View file

@ -12,9 +12,8 @@ type str: string;
event zeek_init() {
# Create a database file in the .tmp directory with a 'testing' table
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "storage-test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "storage-test.sqlite", $table_name = "testing"];
local key = "key1234";

View file

@ -28,9 +28,8 @@ event check_removed() {
}
event setup_test() {
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "storage-test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "storage-test.sqlite", $table_name = "testing"];
backend = Storage::Sync::open_backend(Storage::SQLITE, opts, str, str);

View file

@ -11,9 +11,8 @@
type str: string;
event zeek_init() {
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "storage-test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "storage-test.sqlite", $table_name = "testing"];
local key = "key1234";
local value = "value7890";

View file

@ -20,11 +20,8 @@
type str: string;
event zeek_init() {
local opts : Storage::Backend::Redis::Options;
opts$server_host = "127.0.0.1";
opts$server_port = to_port(getenv("REDIS_PORT"));
opts$key_prefix = "testing";
opts$async_mode = T;
local opts : Storage::BackendOptions;
opts$redis = [$server_host = "127.0.0.1", $server_port = to_port(getenv("REDIS_PORT")), $key_prefix = "testing", $async_mode = T];
local key = "key1234";
local value = "value5678";

View file

@ -22,11 +22,8 @@ redef exit_only_after_terminate = T;
type str: string;
event zeek_init() {
local opts : Storage::Backend::Redis::Options;
opts$server_host = "127.0.0.1";
opts$server_port = to_port(getenv("REDIS_PORT"));
opts$key_prefix = "testing";
opts$async_mode = T;
local opts : Storage::BackendOptions;
opts$redis = [$server_host = "127.0.0.1", $server_port = to_port(getenv("REDIS_PORT")), $key_prefix = "testing", $async_mode = T];
local key = "key1234";
local value = "value5678";

View file

@ -40,11 +40,8 @@ global backend: opaque of Storage::BackendHandle;
type str: string;
event zeek_init() {
local opts : Storage::Backend::Redis::Options;
opts$server_host = "127.0.0.1";
opts$server_port = to_port(getenv("REDIS_PORT"));
opts$key_prefix = "testing";
opts$async_mode = F;
local opts : Storage::BackendOptions;
opts$redis = [$server_host = "127.0.0.1", $server_port = to_port(getenv("REDIS_PORT")), $key_prefix = "testing", $async_mode = F];
backend = Storage::Sync::open_backend(Storage::REDIS, opts, str, str);
}

View file

@ -34,11 +34,8 @@ event check_removed() {
}
event setup_test() {
local opts : Storage::Backend::Redis::Options;
opts$server_host = "127.0.0.1";
opts$server_port = to_port(getenv("REDIS_PORT"));
opts$key_prefix = "testing";
opts$async_mode = F;
local opts : Storage::BackendOptions;
opts$redis = [$server_host = "127.0.0.1", $server_port = to_port(getenv("REDIS_PORT")), $key_prefix = "testing", $async_mode = F];
b = Storage::Sync::open_backend(Storage::REDIS, opts, str, str);

View file

@ -19,11 +19,8 @@
type str: string;
event zeek_init() {
local opts : Storage::Backend::Redis::Options;
opts$server_host = "127.0.0.1";
opts$server_port = to_port(getenv("REDIS_PORT"));
opts$key_prefix = "testing";
opts$async_mode = F;
local opts : Storage::BackendOptions;
opts$redis = [$server_host = "127.0.0.1", $server_port = to_port(getenv("REDIS_PORT")), $key_prefix = "testing", $async_mode = F];
local key = "key1234";
local value = "value1234";

View file

@ -14,9 +14,8 @@ type str: string;
event zeek_init() {
# Create a database file in the .tmp directory with a 'testing' table
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "test.sqlite", $table_name = "testing"];
local key = "key1234";
local value = "value5678";

View file

@ -13,9 +13,8 @@ type str: string;
event zeek_init() {
# Create a database file in the .tmp directory with a 'testing' table
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "test.sqlite", $table_name="testing"];
local key = "key1234";
local value = "value5678";

View file

@ -12,15 +12,15 @@ type str: string;
event zeek_init() {
# Test opening a database with an invalid path
local opts : Storage::Backend::SQLite::Options;
opts$database_path = "/this/path/should/not/exist/test.sqlite";
opts$table_name = "testing";
local opts : Storage::BackendOptions;
opts$sqlite = [$database_path = "/this/path/should/not/exist/test.sqlite",
$table_name = "testing"];
# This should report an error in .stderr and reporter.log
local b = Storage::Sync::open_backend(Storage::SQLITE, opts, str, str);
# Open a valid database file
opts$database_path = "test.sqlite";
opts$sqlite$database_path = "test.sqlite";
b = Storage::Sync::open_backend(Storage::SQLITE, opts, str, str);
local bad_key: count = 12345;