-
Notifications
You must be signed in to change notification settings - Fork 13
Run examples in CI #336
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
Merged
Merged
Run examples in CI #336
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6ddc9cf
examples: add `drop_examples_keyspace` example
wprzytula ec54aca
add single-node docker-compose for running examples
wprzytula c05137c
examples: delete DSE examples
wprzytula 83f6912
cmake: link libuv for examples
wprzytula cc208a1
cmake: add cpp_integration_testing to RUSTFLAGS for examples
wprzytula 904c26e
IT: add stubs required for examples to compile
wprzytula 925958d
makefile: add target to build examples
wprzytula 90d635b
Makefile: list supported examples
wprzytula 72e6c92
Makefile: support running examples
wprzytula 3453eb4
CI: add run-examples step to CI workflow
wprzytula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
drop_examples_keyspace | ||
4 changes: 2 additions & 2 deletions
4
examples/dse/date_range/CMakeLists.txt → ...les/drop_examples_keyspace/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,54 +25,77 @@ | |
For more information, please refer to <http://unlicense.org/> | ||
*/ | ||
|
||
#include <dse.h> | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char* argv[]) { | ||
/* Setup and connect to cluster */ | ||
CassFuture* connect_future = NULL; | ||
#include "cassandra.h" | ||
|
||
void print_error(CassFuture* future) { | ||
const char* message; | ||
size_t message_length; | ||
cass_future_error_message(future, &message, &message_length); | ||
fprintf(stderr, "Error: %.*s\n", (int)message_length, message); | ||
} | ||
|
||
CassCluster* create_cluster(const char* hosts) { | ||
CassCluster* cluster = cass_cluster_new(); | ||
CassSession* session = cass_session_new(); | ||
char* hosts = "127.0.0.1"; | ||
if (argc > 1) { | ||
hosts = argv[1]; | ||
cass_cluster_set_contact_points(cluster, hosts); | ||
return cluster; | ||
} | ||
|
||
CassError connect_session(CassSession* session, const CassCluster* cluster) { | ||
CassError rc = CASS_OK; | ||
CassFuture* future = cass_session_connect(session, cluster); | ||
|
||
cass_future_wait(future); | ||
rc = cass_future_error_code(future); | ||
if (rc != CASS_OK) { | ||
print_error(future); | ||
} | ||
cass_future_free(future); | ||
|
||
cass_log_set_level(CASS_LOG_INFO); | ||
return rc; | ||
} | ||
|
||
/* Add contact points */ | ||
cass_cluster_set_contact_points(cluster, hosts); | ||
CassError execute_query(CassSession* session, const char* query) { | ||
CassError rc = CASS_OK; | ||
CassFuture* future = NULL; | ||
CassStatement* statement = cass_statement_new(query, 0); | ||
|
||
/* Hostname resolution is typically necessary when authenticating with Kerberos. */ | ||
cass_cluster_set_use_hostname_resolution(cluster, cass_true); | ||
future = cass_session_execute(session, statement); | ||
cass_future_wait(future); | ||
|
||
cass_cluster_set_dse_gssapi_authenticator(cluster, "dse", "[email protected]"); | ||
rc = cass_future_error_code(future); | ||
if (rc != CASS_OK) { | ||
print_error(future); | ||
} | ||
|
||
/* Provide the cluster object as configuration to connect the session */ | ||
connect_future = cass_session_connect(session, cluster); | ||
cass_future_free(future); | ||
cass_statement_free(statement); | ||
|
||
if (cass_future_error_code(connect_future) == CASS_OK) { | ||
CassFuture* close_future = NULL; | ||
return rc; | ||
} | ||
|
||
printf("Successfully connected!\n"); | ||
int main(int argc, char* argv[]) { | ||
CassCluster* cluster = NULL; | ||
CassSession* session = cass_session_new(); | ||
char* hosts = "127.0.0.1"; | ||
|
||
/* Close the session */ | ||
close_future = cass_session_close(session); | ||
cass_future_wait(close_future); | ||
cass_future_free(close_future); | ||
} else { | ||
/* Handle error */ | ||
const char* message; | ||
size_t message_length; | ||
cass_future_error_message(connect_future, &message, &message_length); | ||
fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message); | ||
if (argc > 1) { | ||
hosts = argv[1]; | ||
} | ||
cluster = create_cluster(hosts); | ||
|
||
if (connect_session(session, cluster) != CASS_OK) { | ||
cass_cluster_free(cluster); | ||
cass_session_free(session); | ||
return -1; | ||
} | ||
|
||
execute_query(session, "DROP KEYSPACE IF EXISTS examples"); | ||
|
||
cass_future_free(connect_future); | ||
cass_cluster_free(cluster); | ||
cass_session_free(session); | ||
cass_cluster_free(cluster); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.