summaryrefslogtreecommitdiffstats
path: root/libdlmclient/test
diff options
context:
space:
mode:
authorDamian Hobson-Garcia <dhobsong@igel.co.jp>2021-02-19 03:52:55 +0000
committerDamian Hobson-Garcia <dhobsong@igel.co.jp>2021-04-06 15:58:47 +0900
commitabb27e7774e3cd12bd3cfe3d4858bbe590e59be0 (patch)
tree2b676f85323f0297ffd187d3aef2c0b224e2ff99 /libdlmclient/test
parentd196375b8b130e119285fb19984870edc6941a90 (diff)
Add lease request and release protocol
Explicitly request / release leases instead of implicitly by opening and closing the connection. This will allow the lease manager to take different action when a client shuts down gracefully vs when it crashes, holding a lease. Bug-AGL: SPEC-3862 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp> Change-Id: Ibc68bee855ce18e56eb6f57e5ad1743248320013
Diffstat (limited to 'libdlmclient/test')
-rw-r--r--libdlmclient/test/test-socket-server.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libdlmclient/test/test-socket-server.c b/libdlmclient/test/test-socket-server.c
index 281aaf7..6aaa4e4 100644
--- a/libdlmclient/test/test-socket-server.c
+++ b/libdlmclient/test/test-socket-server.c
@@ -25,6 +25,7 @@
#include <sys/un.h>
#include <unistd.h>
+#include "dlm-protocol.h"
#include "socket-path.h"
#include "test-helpers.h"
@@ -56,6 +57,13 @@ static void send_fd_list_over_socket(int socket, int nfds, int *fds)
free(buf);
}
+static void expect_client_command(int socket, enum dlm_opcode opcode)
+{
+ struct dlm_client_request req;
+ ck_assert_int_eq(receive_dlm_client_request(socket, &req), true);
+ ck_assert_int_eq(req.opcode, opcode);
+}
+
struct server_state {
pthread_t tid;
pthread_mutex_t lock;
@@ -77,7 +85,7 @@ static void *test_server_thread(void *arg)
ck_assert_int_eq(
sockaddr_set_lease_server_path(&address, config->lease_name), true);
- int server = socket(PF_UNIX, SOCK_STREAM, 0);
+ int server = socket(PF_UNIX, SOCK_SEQPACKET, 0);
ck_assert_int_ge(server, 0);
unlink(address.sun_path);
@@ -102,6 +110,8 @@ static void *test_server_thread(void *arg)
return NULL;
}
+ expect_client_command(client, DLM_GET_LEASE);
+
if (config->send_no_data)
goto done;
@@ -120,6 +130,7 @@ static void *test_server_thread(void *arg)
config->fds[i] = get_dummy_fd();
send_fd_list_over_socket(client, config->nfds, config->fds);
+ expect_client_command(client, DLM_RELEASE_LEASE);
done:
close(client);
close(server);