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

ci: use virtual environment in functional tests #476

Merged
merged 65 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
514679f
feat: venv tools
JeremyTubongbanua Dec 13, 2024
4150efc
feat: Almost working
JeremyTubongbanua Dec 13, 2024
7e0a597
feat: use dev_env tag
JeremyTubongbanua Dec 13, 2024
6da8640
fix: memory bug in atclient_pkam_authenticate
JeremyTubongbanua Dec 13, 2024
46a9821
feat: implement atclient_connection_set_read_timeout
JeremyTubongbanua Dec 13, 2024
f0c9db3
fix: add compatibility to staging in test_atclient_pkam_authenticate
JeremyTubongbanua Dec 13, 2024
7a1fb89
fix: test commands in CI
JeremyTubongbanua Dec 13, 2024
a17cbc2
fix: file name
JeremyTubongbanua Dec 13, 2024
2c534bf
feat: add step to start venv in CI
JeremyTubongbanua Dec 13, 2024
f72bed6
ci: install docker-compose step
JeremyTubongbanua Dec 13, 2024
c265076
ci:
JeremyTubongbanua Dec 13, 2024
a4c45e8
ci: add longer sleeps
JeremyTubongbanua Dec 13, 2024
f020671
chore: remove unused keys
JeremyTubongbanua Dec 19, 2024
a34fdb2
chore: remove sudo from pkam_virtualenv.sh
JeremyTubongbanua Dec 19, 2024
cf69ddf
feat: move mbedtls sockets into its own layer under connection
XavierChanth Dec 9, 2024
89fb405
chore: address review comments & cleanup work
XavierChanth Dec 17, 2024
363f046
ci:
JeremyTubongbanua Dec 19, 2024
b9782f5
ci:
JeremyTubongbanua Dec 19, 2024
907663e
feat: add read timeout to functional_tests_pkam_auth
JeremyTubongbanua Dec 19, 2024
7a0d22d
fix:
JeremyTubongbanua Dec 19, 2024
fb8fb71
fix: do not overwrite ret value during tear down in functional tests
JeremyTubongbanua Dec 20, 2024
7e73d9f
feat: impl to create new enollments using APKAM-OTP (#453)
srieteja Dec 19, 2024
3c908dd
feat: Almost working
JeremyTubongbanua Dec 13, 2024
daccf62
fix: add compatibility to staging in test_atclient_pkam_authenticate
JeremyTubongbanua Dec 13, 2024
9e82f53
feat: venv tools
JeremyTubongbanua Dec 13, 2024
84518cd
feat: Almost working
JeremyTubongbanua Dec 13, 2024
10db653
feat: use dev_env tag
JeremyTubongbanua Dec 13, 2024
1e2f8f6
fix: test commands in CI
JeremyTubongbanua Dec 13, 2024
481def2
fix: file name
JeremyTubongbanua Dec 13, 2024
8ec4abe
feat: add step to start venv in CI
JeremyTubongbanua Dec 13, 2024
a3f0486
ci: install docker-compose step
JeremyTubongbanua Dec 13, 2024
a4ff212
ci:
JeremyTubongbanua Dec 13, 2024
b0aad50
ci: add longer sleeps
JeremyTubongbanua Dec 13, 2024
dba8bc1
chore: remove unused keys
JeremyTubongbanua Dec 19, 2024
1751d78
feat: move mbedtls sockets into its own layer under connection
XavierChanth Dec 9, 2024
72625f5
chore: address review comments & cleanup work
XavierChanth Dec 17, 2024
9dbcb29
ci:
JeremyTubongbanua Dec 19, 2024
ad06351
ci:
JeremyTubongbanua Dec 19, 2024
d75d120
fix: do not overwrite ret value during tear down in functional tests
JeremyTubongbanua Dec 20, 2024
f661887
feat: impl to create new enollments using APKAM-OTP (#453)
srieteja Dec 19, 2024
a773cd1
feat: Almost working
JeremyTubongbanua Dec 13, 2024
10b31e1
fix: add compatibility to staging in test_atclient_pkam_authenticate
JeremyTubongbanua Dec 13, 2024
26c6f11
fix:
JeremyTubongbanua Dec 23, 2024
ecc8ff7
ci:
JeremyTubongbanua Dec 23, 2024
1de7c34
ci:
JeremyTubongbanua Dec 23, 2024
55aaeca
ci:
JeremyTubongbanua Dec 23, 2024
7687aa0
fix: compilation errors
JeremyTubongbanua Dec 23, 2024
d90b727
fix: warning
JeremyTubongbanua Dec 23, 2024
b58a178
fix:
JeremyTubongbanua Dec 23, 2024
90e2739
ci:
JeremyTubongbanua Dec 23, 2024
7ef980a
ci:
JeremyTubongbanua Dec 23, 2024
6b291e2
ci:
JeremyTubongbanua Dec 23, 2024
736b0e5
ci: add virtual environment step in functional tests
JeremyTubongbanua Dec 23, 2024
869e55d
ci:
JeremyTubongbanua Dec 23, 2024
0b7b39a
ci: nslookup
JeremyTubongbanua Dec 23, 2024
977b65d
feat: null terminate port_str
JeremyTubongbanua Dec 25, 2024
9e0e897
fix: test_atclient_monitor bugs
JeremyTubongbanua Dec 25, 2024
0096bba
feat: modify test_atclient_connection.c
JeremyTubongbanua Dec 25, 2024
81d9095
fix: typo
JeremyTubongbanua Dec 25, 2024
a06a149
fix:
JeremyTubongbanua Dec 25, 2024
7feb7ad
fix:
JeremyTubongbanua Dec 25, 2024
696e6ad
chore: undo playground
JeremyTubongbanua Dec 25, 2024
42636c7
chore: undo random change
JeremyTubongbanua Dec 25, 2024
e35e9e6
chore: remove unused function
JeremyTubongbanua Dec 25, 2024
e91dc26
ci: remove debug statements in our tests.yaml
JeremyTubongbanua Jan 2, 2025
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
31 changes: 24 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,38 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Load secrets
working-directory: tests/functional_tests
working-directory: tests/functional_tests/tools/virtualenv/keys
run: |
mkdir -p ~/.atsign/keys/
echo "${{ secrets.ATKEYS_12ALPACA }}" > ~/.atsign/keys/@12alpaca_key.atKeys
echo "${{ secrets.ATKEYS_12SNOWBOATING }}" > ~/.atsign/keys/@12snowboating_key.atKeys
ls -la
JeremyTubongbanua marked this conversation as resolved.
Show resolved Hide resolved
cp "@alice🛠_key.atKeys" ~/.atsign/keys/
cp "@bob🛠_key.atKeys" ~/.atsign/keys/

- name: Start Virtual Environment
working-directory: tests/functional_tests/tools/virtualenv
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
sudo ./start_virtualenv.sh
sleep 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test for the services being ready rather than sleeping?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll open a ticket for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I implement docker readiness checking in this PR or should we merge this into trunk so it can be used by others now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy for it to be done later. So merge now.

sudo ./pkam_virtualenv.sh
sleep 1

- name: Add vip.ve.atsign.zone to /etc/hosts
run: |
echo "127.0.0.1 vip.ve.atsign.zone" | sudo tee -a /etc/hosts
cat /etc/hosts
JeremyTubongbanua marked this conversation as resolved.
Show resolved Hide resolved
echo "---"
nslookup vip.ve.atsign.zone

- name: Install atSDK
run: |
cmake -S . -B build -DATSDK_BUILD_TESTS="func"
cmake -S . -B build -DATSDK_BUILD_TESTS="func" -DCMAKE_BUILD_TYPE=Debug -DFIRST_ATSIGN="\"@alice🛠\"" -DSECOND_ATSIGN="\"@bob🛠\"" -DATDIRECTORY_HOST="\"vip.ve.atsign.zone\"" -DATDIRECTORY_PORT=64
sudo cmake --build build --target install

- name: Build and Run Functional Tests
working-directory: build/tests/functional_tests
- name: Run Functional Tests
run: |
ctest --test-dir . -VV --timeout 90
ctest --test-dir build/tests/functional_tests -VV --timeout 90

build-examples:
runs-on: "ubuntu-latest"
Expand Down
9 changes: 9 additions & 0 deletions packages/atclient/include/atclient/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ int atclient_connection_disconnect(atclient_connection *ctx);
*/
bool atclient_connection_is_connected(atclient_connection *ctx);

/**
* @brief set the blocking read timeout of the connection
*
* @param ctx the connection to set the read timeout on, assumed to be initialized and connected
* @param timeout_ms the timeout in milliseconds
* @return void
*/
void atclient_connection_set_read_timeout(atclient_connection *ctx, const uint32_t timeout_ms);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions packages/atclient/src/atclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int atclient_pkam_authenticate(atclient *ctx, const char *atsign, const atclient
options->atserver_port != 0) {
atserver_host = options->atserver_host;
atserver_port = options->atserver_port;
should_free_atserver_host = true;
should_free_atserver_host = false;
}

if (atserver_host == NULL || atserver_port == 0) {
Expand Down Expand Up @@ -719,7 +719,7 @@ exit: {
bool atclient_is_connected(atclient *ctx) { return atclient_connection_is_connected(&(ctx->atserver_connection)); }

void atclient_set_read_timeout(atclient *ctx, const int timeout_ms) {
atclient_tls_socket_set_read_timeout(&ctx->atserver_connection._socket, timeout_ms);
atclient_connection_set_read_timeout(&ctx->atserver_connection, timeout_ms);
}

static void atclient_set_atsign_initialized(atclient *ctx, const bool initialized) {
Expand Down
8 changes: 8 additions & 0 deletions packages/atclient/src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,14 @@ int atclient_connection_read(atclient_connection *ctx, unsigned char **value, si
exit: { return ret; }
}

void atclient_connection_set_read_timeout(atclient_connection *ctx, const uint32_t timeout_ms) {
if (ctx == NULL) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "ctx is NULL\n");
return;
}
atclient_tls_socket_set_read_timeout(&ctx->_socket, timeout_ms);
}

static void atclient_connection_set_is_connection_enabled(atclient_connection *ctx, const bool should_be_connected) {
ctx->_is_connection_enabled = should_be_connected;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atclient/src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exit: { return ret; }
}

void atclient_monitor_set_read_timeout(atclient *monitor_conn, const int timeoutms) {
atclient_tls_socket_set_read_timeout(&monitor_conn->atserver_connection._socket, timeoutms);
atclient_set_read_timeout(monitor_conn, timeoutms);
}

int atclient_monitor_start(atclient *monitor_conn, const char *regex) {
Expand Down
6 changes: 4 additions & 2 deletions packages/atclient/src/socket_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ int atclient_tls_socket_connect(struct atclient_tls_socket *socket, const char *
return 1;
}

char port_str[5];
snprintf(port_str, 5, "%" PRIu16, port);
const size_t port_str_size = 6;
char port_str[port_str_size];
memset(port_str, 0, sizeof(char) * port_str_size);
snprintf(port_str, port_str_size, "%" PRIu16, port);

int ret;
// 1. Connect
Expand Down
16 changes: 14 additions & 2 deletions tests/functional_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
option(FIRST_ATSIGN "First atSign used for all functional tests" OFF)
if(NOT "${FIRST_ATSIGN}" STREQUAL OFF)
message("Functional tests override first atsign: ${FIRST_ATSIGN}")
message("[ATSDK FUNCTIONAL TESTS] Functional tests override first atsign: ${FIRST_ATSIGN}")
add_compile_definitions(FIRST_ATSIGN=${FIRST_ATSIGN})
endif()

option(SECOND_ATSIGN "Second atSign for two-way atSign functional tests" OFF)
if(NOT "${SECOND_ATSIGN}" STREQUAL OFF)
message("Functional tests override second atsign: ${SECOND_ATSIGN}")
message("[ATSDK FUNCTIONAL TESTS] Functional tests override second atsign: ${SECOND_ATSIGN}")
add_compile_definitions(SECOND_ATSIGN=${SECOND_ATSIGN})
endif()

option(ATDIRECTORY_HOST "Host for atDirectory functional tests" OFF)
if(NOT "${ATDIRECTORY_HOST}" STREQUAL OFF)
message("[ATSDK FUNCTIONAL TESTS] Functional tests override atDirectory host: ${ATDIRECTORY_HOST}")
add_compile_definitions(ATDIRECTORY_HOST=${ATDIRECTORY_HOST})
endif()

option(ATDIRECTORY_PORT "Port for atDirectory functional tests" OFF)
if(NOT "${ATDIRECTORY_PORT}" STREQUAL OFF)
message("[ATSDK FUNCTIONAL TESTS] Functional tests override atDirectory port: ${ATDIRECTORY_PORT}")
add_compile_definitions(ATDIRECTORY_PORT=${ATDIRECTORY_PORT})
endif()

cmake_minimum_required(VERSION 3.19)
set(CMAKE_C_STANDARD 99)

Expand Down
9 changes: 7 additions & 2 deletions tests/functional_tests/lib/include/functional_tests/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ extern "C" {

#include <stddef.h>

#define ROOT_HOST "root.atsign.org"
#define ROOT_PORT 64
#ifndef ATDIRECTORY_HOST
#define ATDIRECTORY_HOST "root.atsign.org"
#endif

#ifndef ATDIRECTORY_PORT
#define ATDIRECTORY_PORT 64
#endif

#ifndef FIRST_ATSIGN
#define FIRST_ATSIGN "@12alpaca"
Expand Down
4 changes: 2 additions & 2 deletions tests/functional_tests/lib/include/functional_tests/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ extern "C" {
#include "atclient/atclient.h"
#include <stddef.h>

int functional_tests_set_up_atkeys(atclient_atkeys *atkeys, const char *atsign, const size_t atsignlen);
int functional_tests_pkam_auth(atclient *atclient, atclient_atkeys *atkeys, const char *atsign, const size_t atsignlen);
int functional_tests_set_up_atkeys(atclient_atkeys *atkeys, const char *atsign);
int functional_tests_pkam_auth(atclient *atclient, atclient_atkeys *atkeys, const char *atsign);
int functional_tests_publickey_exists(atclient *atclient, const char *key, const char *shared_by,
const char *knamespace);
int functional_tests_selfkey_exists(atclient *atclient, const char *key, const char *shared_by, const char *knamespace);
Expand Down
43 changes: 38 additions & 5 deletions tests/functional_tests/lib/src/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

#define TAG "functional_tests_helpers"

int functional_tests_set_up_atkeys(atclient_atkeys *atkeys, const char *atsign, const size_t atsignlen) {
int functional_tests_set_up_atkeys(atclient_atkeys *atkeys, const char *atsign) {
int ret = 1;

const size_t atkeyspathsize = 1024;
char atkeyspath[atkeyspathsize];
memset(atkeyspath, 0, atkeyspathsize);
size_t atkeyspathlen = 0;

if ((ret = functional_tests_get_atkeys_path(atsign, atsignlen, atkeyspath, atkeyspathsize, &atkeyspathlen)) != 0) {
if ((ret = functional_tests_get_atkeys_path(atsign, strlen(atsign), atkeyspath, atkeyspathsize, &atkeyspathlen)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to get atkeys_sharedwith path: %d\n", ret);
goto exit;
}
Expand All @@ -35,22 +35,55 @@ int functional_tests_set_up_atkeys(atclient_atkeys *atkeys, const char *atsign,
exit: { return ret; }
}

int functional_tests_pkam_auth(atclient *atclient, atclient_atkeys *atkeys, const char *atsign,
const size_t atsignlen) {
int functional_tests_pkam_auth(atclient *atclient, atclient_atkeys *atkeys, const char *atsign) {
int ret = 1;

atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "functional_tests_pkam_auth Begin\n");

if ((ret = atclient_pkam_authenticate(atclient, atsign, atkeys, NULL, NULL)) != 0) {
if(atclient == NULL) {
ret = 1;
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atclient is NULL\n");
return ret;
}

if(atkeys == NULL) {
ret = 1;
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atkeys is NULL\n");
return ret;
}

if(atsign == NULL) {
ret = 1;
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atsign is NULL\n");
return ret;
}

atclient_authenticate_options authenticate_options;
atclient_authenticate_options_init(&authenticate_options);

if((ret = atclient_authenticate_options_set_atdirectory_host(&authenticate_options, ATDIRECTORY_HOST)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atclient_authenticate_options_set_atdirectory_host: %d\n", ret);
goto exit;
}

if((ret = atclient_authenticate_options_set_atdirectory_port(&authenticate_options, ATDIRECTORY_PORT)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atclient_authenticate_options_set_atdirectory_port: %d\n", ret);
goto exit;
}

if ((ret = atclient_pkam_authenticate(atclient, atsign, atkeys, &authenticate_options, NULL)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "atclient_pkam_authenticate: %d\n", ret);
goto exit;
}

atclient_set_read_timeout(atclient, 5*1000); // 5 second read timeout

atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "pkam authenticated\n");

goto exit;

exit: {
atclient_authenticate_options_free(&authenticate_options);
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "functional_tests_pkam_auth End (%d)\n", ret);
return ret;
}
Expand Down
Loading
Loading