google-cloud-cpp: add unit tests

This commit is contained in:
Phillip Cloud
2021-10-29 12:24:58 -04:00
parent 79ea7aa9f9
commit 2db4ece355
2 changed files with 164 additions and 4 deletions
@@ -6,8 +6,8 @@
, cmake
, crc32c
, curl
, grpc
, gbenchmark
, grpc
, gtest
, ninja
, nlohmann_json
@@ -15,6 +15,7 @@
, protobuf
# default list of APIs: https://github.com/googleapis/google-cloud-cpp/blob/v1.32.1/CMakeLists.txt#L173
, apis ? [ "*" ]
, staticOnly ? stdenv.hostPlatform.isStatic
}:
let
googleapisRev = "ed739492993c4a99629b6430affdd6c0fb59d435";
@@ -24,6 +25,7 @@ let
rev = googleapisRev;
hash = "sha256:1xrnh77vb8hxmf1ywqsifzd39kylhbdyah0b0b9bm7nw0mnahssl";
};
excludedTests = builtins.fromTOML (builtins.readFile ./skipped_tests.toml);
in
stdenv.mkDerivation rec {
pname = "google-cloud-cpp";
@@ -45,6 +47,9 @@ stdenv.mkDerivation rec {
cmake
ninja
pkg-config
] ++ lib.optionals (!doInstallCheck) [
gbenchmark
gtest
];
buildInputs = [
@@ -53,14 +58,57 @@ stdenv.mkDerivation rec {
crc32c
curl
grpc
gbenchmark
gtest
nlohmann_json
protobuf
];
doInstallCheck = true;
preInstallCheck =
let
# These paths are added to (DY)LD_LIBRARY_PATH because they contain
# testing-only shared libraries that do not need to be installed, but
# need to be loadable by the test executables.
#
# Setting (DY)LD_LIBRARY_PATH is only necessary when building shared libraries.
additionalLibraryPaths = [
"$PWD/google/cloud/bigtable"
"$PWD/google/cloud/bigtable/benchmarks"
"$PWD/google/cloud/pubsub"
"$PWD/google/cloud/spanner"
"$PWD/google/cloud/spanner/benchmarks"
"$PWD/google/cloud/storage"
"$PWD/google/cloud/storage/benchmarks"
"$PWD/google/cloud/testing_util"
];
ldLibraryPathName = "${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH";
in
lib.optionalString doInstallCheck (
lib.optionalString (!staticOnly) ''
export ${ldLibraryPathName}=${lib.concatStringsSep ":" additionalLibraryPaths}
'' + ''
export GTEST_FILTER="-${lib.concatStringsSep ":" excludedTests.cases}"
''
);
installCheckPhase = lib.optionalString doInstallCheck ''
runHook preInstallCheck
# disable tests that contact the internet
ctest --exclude-regex '^(${lib.concatStringsSep "|" excludedTests.whole})'
runHook postInstallCheck
'';
installCheckInputs = lib.optionals doInstallCheck [
gbenchmark
gtest
];
cmakeFlags = [
"-DBUILD_SHARED_LIBS:BOOL=ON"
"-DBUILD_SHARED_LIBS:BOOL=${if staticOnly then "OFF" else "ON"}"
# unconditionally build tests to catch linker errors as early as possible
# this adds a good chunk of time to the build
"-DBUILD_TESTING:BOOL=ON"
"-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES:BOOL=OFF"
] ++ lib.optionals (apis != [ "*" ]) [
@@ -0,0 +1,112 @@
whole = [
"bigquery_bigquery_read_integration_test",
"bigtable_admin_backup_integration_test",
"bigtable_admin_iam_policy_integration_test",
"bigtable_admin_integration_test",
"bigtable_apply_read_latency_benchmark",
"bigtable_data_async_future_integration_test",
"bigtable_data_integration_test",
"bigtable_endurance_benchmark",
"bigtable_filters_integration_test",
"bigtable_mutation_batcher_throughput_benchmark",
"bigtable_mutations_integration_test",
"bigtable_read_sync_vs_async_benchmark",
"bigtable_scan_throughput_benchmark",
"bigtable_table_sample_rows_integration_test",
"iam_iam_credentials_integration_test",
"iam_iam_integration_test",
"pubsub_endurance",
"pubsub_schema_admin_integration_test",
"pubsub_subscriber_integration_test",
"pubsub_subscription_admin_integration_test",
"pubsub_throughput",
"pubsub_topic_admin_integration_test",
"spanner_admin_backup_extra_integration_test",
"spanner_admin_database_admin_integration_test",
"spanner_admin_instance_admin_integration_test",
"spanner_backup_extra_integration_test",
"spanner_client_integration_test",
"spanner_client_stress_test",
"spanner_data_types_integration_test",
"spanner_database_admin_integration_test",
"spanner_instance_admin_integration_test",
"spanner_multiple_rows_cpu_benchmark",
"spanner_rpc_failure_threshold_integration_test",
"spanner_session_pool_integration_test",
"spanner_single_row_throughput_benchmark",
"storage_aggregate_download_throughput_benchmark",
"storage_aggregate_upload_throughput_benchmark",
"storage_alternative_endpoint_integration_test",
"storage_auto_finalize_integration_test",
"storage_bucket_integration_test",
"storage_create_client_integration_test",
"storage_create_dataset",
"storage_curl_download_request_integration_test",
"storage_curl_request_integration_test",
"storage_curl_resumable_upload_session_integration_test",
"storage_curl_sign_blob_integration_test",
"storage_grpc_integration_test",
"storage_key_file_integration_test",
"storage_minimal_iam_credentials_rest_integration_test",
"storage_object_basic_crud_integration_test",
"storage_object_checksum_integration_test",
"storage_object_compose_many_integration_test",
"storage_object_file_integration_test",
"storage_object_hash_integration_test",
"storage_object_insert_integration_test",
"storage_object_insert_preconditions_integration_test",
"storage_object_integration_test",
"storage_object_list_objects_versions_integration_test",
"storage_object_media_integration_test",
"storage_object_parallel_upload_integration_test",
"storage_object_plenty_clients_serially_integration_test",
"storage_object_plenty_clients_simultaneously_integration_test",
"storage_object_read_headers_integration_test",
"storage_object_read_preconditions_integration_test",
"storage_object_read_range_integration_test",
"storage_object_read_stream_integration_test",
"storage_object_resumable_parallel_upload_integration_test",
"storage_object_resumable_write_integration_test",
"storage_object_rewrite_integration_test",
"storage_object_write_preconditions_integration_test",
"storage_object_write_stream_integration_test",
"storage_object_write_streambuf_integration_test",
"storage_service_account_integration_test",
"storage_signed_url_integration_test",
"storage_small_reads_integration_test",
"storage_storage_file_transfer_benchmark",
"storage_storage_parallel_uploads_benchmark",
"storage_storage_throughput_vs_cpu_benchmark",
"storage_thread_integration_test",
"storage_throughput_experiment_test",
"storage_tracing_integration_test",
"storage_unified_credentials_integration_test",
"common_grpc_utils_internal_grpc_impersonate_service_account_integration_test"
]
cases = [
"BackupExtraIntegrationTest.CreateBackupWithExpiredVersionTime",
"BackupExtraIntegrationTest.BackupWithExpiredVersionTime",
"BackupExtraIntegrationTest.BackupWithFutureVersionTime",
"BackupExtraIntegrationTest.CreateBackupWithFutureVersionTime",
"DatabaseAdminClientTest.CreateWithEncryptionKey",
"DatabaseAdminClientTest.CreateWithNonexistentEncryptionKey",
"DatabaseAdminClientTest.DatabaseBasicCRUD",
"DatabaseAdminClientTest.VersionRetentionPeriodCreate",
"DatabaseAdminClientTest.VersionRetentionPeriodCreateFailure",
"DatabaseAdminClientTest.VersionRetentionPeriodUpdate",
"DatabaseAdminClientTest.VersionRetentionPeriodUpdateFailure",
"InstanceAdminClientTest.InstanceConfig",
"InstanceAdminClientTest.InstanceIam",
"InstanceAdminClientTest.InstanceReadOperations",
"LoggingIntegrationTest.ListMonitoredResourceDescriptors",
"LoggingIntegrationTest.WriteLogEntries",
"ObjectFileMultiThreadedTest.Download",
"SubscriberIntegrationTest.FireAndForget",
"SubscriberIntegrationTest.PublishOrdered",
"SubscriberIntegrationTest.PublishPullAck",
"SubscriberIntegrationTest.RawStub",
"SubscriberIntegrationTest.ReportNotFound",
"SubscriberIntegrationTest.StreamingSubscriptionBatchSource",
"SubscriptionAdminIntegrationTest.SubscriptionCRUD",
"TopicAdminIntegrationTest.TopicCRUD"
]