Skip to content
Open
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
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ commands:
type: string
steps:
- run: |
brew install [email protected]
brew install --skip-post-install [email protected] && brew postinstall [email protected]
Copy link
Member

Choose a reason for hiding this comment

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

What does it fix, again? I think I saw a similar PR, but I don't remember

curl -OL "https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-darwin-<<parameters.bazel-arch>>"
sudo mv "bazelisk-darwin-<<parameters.bazel-arch>>" /usr/local/bin/bazel
chmod a+x /usr/local/bin/bazel
Expand Down Expand Up @@ -531,7 +531,7 @@ jobs:

- deploy-maven-jni-snapshot-unix

# - deploy-clib-snapshot-unix
- deploy-clib-snapshot-unix
# - test-clib-assembly-linux:
# target-arch: arm64

Expand All @@ -553,7 +553,7 @@ jobs:

- deploy-maven-jni-snapshot-unix

# - deploy-clib-snapshot-unix
- deploy-clib-snapshot-unix
# - test-clib-assembly-linux:
# target-arch: x86_64

Expand All @@ -577,7 +577,7 @@ jobs:

# - run: brew install cmake

# - deploy-clib-snapshot-unix
- deploy-clib-snapshot-unix
# - test-clib-assembly-mac:
# target-arch: arm64

Expand All @@ -601,7 +601,7 @@ jobs:

# - run: brew install cmake

# - deploy-clib-snapshot-unix
- deploy-clib-snapshot-unix
# - test-clib-assembly-mac:
# target-arch: x86_64

Expand All @@ -622,8 +622,8 @@ jobs:

- run: .circleci\windows\java\deploy_snapshot.bat

# - run: .circleci\windows\clib\deploy_snapshot.bat
# - run: .circleci\windows\clib\test_assembly.bat
- run: .circleci\windows\clib\deploy_snapshot.bat
- run: .circleci\windows\clib\test_assembly.bat

# - run: .circleci\windows\cpp\deploy_snapshot.bat
# - run: .circleci\windows\cpp\test_assembly.bat
Expand Down Expand Up @@ -730,7 +730,7 @@ jobs:
bazel-arch: arm64
- deploy-pip-release-unix
- deploy-maven-jni-release-unix
# - deploy-clib-release-unix
- deploy-clib-release-unix
# - deploy-cpp-release-unix

# - install-libicu-linux
Expand All @@ -744,7 +744,7 @@ jobs:
bazel-arch: amd64
- deploy-pip-release-unix
- deploy-maven-jni-release-unix
# - deploy-clib-release-unix
- deploy-clib-release-unix
# - deploy-cpp-release-unix

# - install-libicu-linux
Expand All @@ -758,7 +758,7 @@ jobs:
bazel-arch: arm64
- deploy-pip-release-unix
- deploy-maven-jni-release-unix
# - deploy-clib-release-unix
- deploy-clib-release-unix
# - deploy-cpp-release-unix
# - deploy-dotnet-runtime-release-unix

Expand All @@ -771,7 +771,7 @@ jobs:
bazel-arch: amd64
- deploy-pip-release-unix
- deploy-maven-jni-release-unix
# - deploy-clib-release-unix
- deploy-clib-release-unix
# - deploy-cpp-release-unix
# - deploy-dotnet-runtime-release-unix

Expand All @@ -783,7 +783,7 @@ jobs:
- run: .circleci\windows\prepare.bat
- run: .circleci\windows\python\deploy_release.bat
- run: .circleci\windows\java\deploy_release.bat
# - run: .circleci\windows\clib\deploy_release.bat
- run: .circleci\windows\clib\deploy_release.bat
# - run: .circleci\windows\cpp\deploy_release.bat
# - run: .circleci\windows\csharp\deploy_release.bat

Expand Down
28 changes: 14 additions & 14 deletions .factory/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,20 @@ build:
# tool/test/stop-cluster-servers.sh
# exit $TEST_SUCCESS

# test-c-integration:
# image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
# dependencies:
# - build
# command: |
# export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
# export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
# bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
# bazel run @typedb_dependencies//distribution/artifact:create-netrc
# tool/test/start-community-server.sh &&
# bazel test //c/tests/integration:test-driver --test_output=errors &&
# export TEST_SUCCESS=0 || export TEST_SUCCESS=1
# tool/test/stop-community-server.sh
# exit $TEST_SUCCESS
test-c-integration:
image: typedb-ubuntu-20.04 # Ubuntu 20.04 has GLIBC version 2.31 (2020) which we should verify to compile against
dependencies:
- build
command: |
export ARTIFACT_USERNAME=$REPO_TYPEDB_USERNAME
export ARTIFACT_PASSWORD=$REPO_TYPEDB_PASSWORD
bazel run @typedb_dependencies//tool/bazelinstall:remote_cache_setup.sh
bazel run @typedb_dependencies//distribution/artifact:create-netrc
tool/test/start-community-server.sh &&
bazel test //c/tests/integration:test-driver --test_output=errors &&
export TEST_SUCCESS=0 || export TEST_SUCCESS=1
tool/test/stop-community-server.sh
exit $TEST_SUCCESS

test-java-integration:
image: typedb-ubuntu-22.04
Expand Down
30 changes: 20 additions & 10 deletions c/tests/assembly/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <typedb_driver.h>

const char* TYPEDB_CORE_ADDRESS = "127.0.0.1:1729";
const char* TYPEDB_CORE_USERNAME = "admin";
const char* TYPEDB_CORE_PASSWORD = "password";
const char* DRIVER_LANG = "c";


Expand All @@ -40,34 +42,42 @@ bool check_error_may_print(const char* filename, int lineno) {
}

#define FAILED() check_error_may_print(__FILE__, __LINE__)
TypeDBDriver* driver_open_for_tests(const char* address, const char* username, const char* password) {
DriverOptions* options = NULL;
Credentials* creds = credentials_new(username, password);
if (check_error_may_print(__FILE__, __LINE__)) goto cleanup;
options = driver_options_new(false, NULL);;
if (check_error_may_print(__FILE__, __LINE__)) goto cleanup;
TypeDBDriver* driver = driver_open_with_description(address, creds, options, DRIVER_LANG);
Copy link
Member

Choose a reason for hiding this comment

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

I remember we discussed with @flyingsilverfin that we want a separate driver_open function for C, which uses DRIVER_LANG implicitly.

This function should be:

  • Easily preferred by a user compared to driver_open_with_description
  • Easily rejected by a developer of another language (probably with c_lang or something)
  • Ideally, the only function available for the C devs (not possible, driver_open_with_description will always be accessible)

We can rename driver_open_with_description to driver_open_for_swig or something scarier just to be very explicit since we don't really want these descriptions to be compromised. Once done, let's use this function in these tests instead.

cleanup:
driver_options_drop(options);
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 noop if there is nothing to drop?

credentials_drop(creds);

return driver;
}

int main() {
const char databaseName[] = "test_assembly_clib";

Connection* connection = NULL;
DatabaseManager* databaseManager = NULL;
TypeDBDriver* driver = NULL;

bool success = false;

connection = driver_open_core(TYPEDB_CORE_ADDRESS, DRIVER_LANG);
if (FAILED()) goto cleanup;

databaseManager = database_manager_new(connection);
driver = driver_open_for_tests(TYPEDB_CORE_ADDRESS, TYPEDB_CORE_USERNAME, TYPEDB_CORE_PASSWORD);
if (FAILED()) goto cleanup;

databases_create(databaseManager, databaseName);
databases_create(driver, databaseName);
if (FAILED()) goto cleanup;

if (!databases_contains(databaseManager, databaseName)) {
if (!databases_contains(driver, databaseName)) {
fprintf(stderr, "databases_contains(\'%s\') failed\n", databaseName);
goto cleanup;
}

success = true;
cleanup:
check_error_may_print(__FILE__, __LINE__);
database_manager_drop(databaseManager);
driver_close(connection);
driver_close(driver);

printf("Success: %s\n", success ? "true" : "false");
return success ? 0 : 1;
Expand Down
28 changes: 24 additions & 4 deletions c/tests/integration/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "common.h"

const char* TYPEDB_CORE_ADDRESS = "127.0.0.1:1729";
const char* TYPEDB_CORE_USERNAME = "admin";
const char* TYPEDB_CORE_PASSWORD = "password";
const char* DRIVER_LANG = "c";

bool check_error_may_print(const char* filename, int lineno) {
Expand All @@ -38,9 +40,27 @@ bool check_error_may_print(const char* filename, int lineno) {
} else return false;
}

void delete_database_if_exists(DatabaseManager* databaseManager, const char* name) {
if (NULL != databaseManager && databases_contains(databaseManager, name)) {
Database* database = databases_get(databaseManager, name);
database_delete(database);
void delete_database_if_exists(TypeDBDriver* driver, const char* name) {
if (driver == NULL) return;
bool contains = databases_contains(driver, name);
if (check_error_may_print(__FILE__, __LINE__)) return;
if (contains) {
const Database* db = databases_get(driver, name);
if (check_error_may_print(__FILE__, __LINE__)) return;
database_delete(db);
}
}

TypeDBDriver* driver_open_for_tests(const char* address, const char* username, const char* password) {
DriverOptions* options = NULL;
Credentials* creds = credentials_new(username, password);
if (check_error_may_print(__FILE__, __LINE__)) goto cleanup;
options = driver_options_new(false, NULL);;
if (check_error_may_print(__FILE__, __LINE__)) goto cleanup;
TypeDBDriver* driver = driver_open_with_description(address, creds, options, DRIVER_LANG);
cleanup:
driver_options_drop(options);
credentials_drop(creds);

return driver;
}
6 changes: 5 additions & 1 deletion c/tests/integration/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
*/

extern const char* TYPEDB_CORE_ADDRESS;
extern const char* TYPEDB_CORE_USERNAME;
extern const char* TYPEDB_CORE_PASSWORD;

bool check_error_may_print(const char* filename, int lineno);

void delete_database_if_exists(DatabaseManager* databaseManager, const char* name);
TypeDBDriver* driver_open_for_tests(const char* address, const char* username, const char* password);

void delete_database_if_exists(TypeDBDriver* driver, const char* name);
Loading