diff options
Diffstat (limited to 'test')
24 files changed, 300 insertions, 65 deletions
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index f37aa66c5f..c538bffd71 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -67,7 +67,9 @@ def main(): 'vs_proj_dir': 'test/bad_client', 'deps': [ 'grpc_test_util_unsecure', - 'grpc_unsecure' + 'grpc_unsecure', + 'gpr_test_util', + 'gpr' ] }], 'targets': [ @@ -82,7 +84,9 @@ def main(): 'deps': [ 'bad_client_test', 'grpc_test_util_unsecure', - 'grpc_unsecure' + 'grpc_unsecure', + 'gpr_test_util', + 'gpr' ] } for t in sorted(BAD_CLIENT_TESTS.keys())]} diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py index 9f05fed485..cc097a8fdf 100755 --- a/test/core/bad_ssl/gen_build_yaml.py +++ b/test/core/bad_ssl/gen_build_yaml.py @@ -58,7 +58,9 @@ def main(): 'platforms': ['linux', 'posix', 'mac'], 'deps': [ 'grpc_test_util', - 'grpc' + 'grpc', + 'gpr_test_util', + 'gpr' ] } ], @@ -74,7 +76,9 @@ def main(): 'deps': [ 'bad_ssl_test_server', 'grpc_test_util', - 'grpc' + 'grpc', + 'gpr_test_util', + 'gpr' ] } for t in sorted(BAD_CLIENT_TESTS.keys())] + [ @@ -88,7 +92,9 @@ def main(): 'platforms': ['linux', 'posix', 'mac'], 'deps': [ 'grpc_test_util', - 'grpc' + 'grpc', + 'gpr_test_util', + 'gpr' ] } for t in sorted(BAD_CLIENT_TESTS.keys())]} diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index d4fa7ab518..f24dbe72cf 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -152,11 +152,15 @@ def main(): sec_deps = [ 'end2end_certs', 'grpc_test_util', - 'grpc' + 'grpc', + 'gpr_test_util', + 'gpr' ] unsec_deps = [ 'grpc_test_util_unsecure', - 'grpc_unsecure' + 'grpc_unsecure', + 'gpr_test_util', + 'gpr' ] json = { '#': 'generated with test/end2end/gen_build_json.py', diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index aac20fd96a..77cc57d4d6 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -237,8 +237,8 @@ static void reader_thread(void *arg) { gpr_timespec interval; int counter = 0; printf(" Reader starting\n"); - interval = gpr_time_from_micros(args->read_iteration_interval_in_msec * 1000, - GPR_TIMESPAN); + interval = gpr_time_from_micros( + (int64_t)args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN); gpr_mu_lock(args->mu); while (!args->stop_flag && records_read < args->total_records) { gpr_cv_wait(&args->stop, args->mu, interval); diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 0149bc3afd..d311eb136a 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -251,7 +251,7 @@ static void test(const char *name, void (*body)(void *m), gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( - start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN)); + start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); fprintf(stderr, "%s:", name); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { iterations <<= 1; diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index fc26f94d29..6cc3786df1 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -125,15 +125,15 @@ static void test_values(void) { } /* Test possible overflow in conversion of -ve values. */ - x = gpr_time_from_micros(-(LONG_MAX - 999997), GPR_TIMESPAN); + x = gpr_time_from_micros(-(INT64_MAX - 999997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); - x = gpr_time_from_nanos(-(LONG_MAX - 999999997), GPR_TIMESPAN); + x = gpr_time_from_nanos(-(INT64_MAX - 999999997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); - x = gpr_time_from_millis(-(LONG_MAX - 997), GPR_TIMESPAN); + x = gpr_time_from_millis(-(INT64_MAX - 997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c index f0e8ec386f..483e79fb25 100644 --- a/test/core/transport/chttp2/timeout_encoding_test.c +++ b/test/core/transport/chttp2/timeout_encoding_test.c @@ -93,7 +93,7 @@ static void assert_decodes_as(const char *buffer, gpr_timespec expected) { } void decode_suite(char ext, - gpr_timespec (*answer)(long x, gpr_clock_type clock)) { + gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) { long test_vals[] = {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9}; diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 15b71747fb..f6bb2e1f72 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,16 +54,16 @@ extern double g_fixture_slowdown_factor; (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \ g_fixture_slowdown_factor) -#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_millis((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ +#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_millis((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ GPR_TIMESPAN)) -#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_micros((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ +#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_micros((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ GPR_TIMESPAN)) #ifndef GRPC_TEST_CUSTOM_PICK_PORT diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 4c7caa9b87..e246c0b0e2 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -56,7 +56,9 @@ using grpc::testing::EchoResponse; using std::chrono::system_clock; const int kNumThreads = 100; // Number of threads -const int kNumRpcs = 1000; // Number of RPCs per thread +const int kNumAsyncSendThreads = 2; +const int kNumAsyncReceiveThreads = 50; +const int kNumRpcs = 1000; // Number of RPCs per thread namespace grpc { namespace testing { @@ -273,7 +275,7 @@ class AsyncClientEnd2endTest : public ::testing::Test { for (int i = 0; i < num_rpcs; ++i) { AsyncClientCall* call = new AsyncClientCall; EchoRequest request; - request.set_message("Hello"); + request.set_message("Hello: " + std::to_string(i)); call->response_reader = common_.GetStub()->AsyncEcho(&call->context, request, &cq_); call->response_reader->Finish(&call->response, &call->status, @@ -290,7 +292,9 @@ class AsyncClientEnd2endTest : public ::testing::Test { bool ok = false; if (!cq_.Next(&got_tag, &ok)) break; AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag); - GPR_ASSERT(ok); + if (!ok) { + gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code()); + } delete call; bool notify; @@ -315,22 +319,22 @@ class AsyncClientEnd2endTest : public ::testing::Test { TEST_F(AsyncClientEnd2endTest, ThreadStress) { common_.ResetStub(); std::vector<std::thread*> send_threads, completion_threads; - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { completion_threads.push_back(new std::thread( &AsyncClientEnd2endTest_ThreadStress_Test::AsyncCompleteRpc, this)); } - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncSendThreads; ++i) { send_threads.push_back( new std::thread(&AsyncClientEnd2endTest_ThreadStress_Test::AsyncSendRpc, this, kNumRpcs)); } - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncSendThreads; ++i) { send_threads[i]->join(); delete send_threads[i]; } Wait(); - for (int i = 0; i < kNumThreads / 2; ++i) { + for (int i = 0; i < kNumAsyncReceiveThreads; ++i) { completion_threads[i]->join(); delete completion_threads[i]; } diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 6b6294ba51..f3f8f37051 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -96,8 +96,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function< std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> - start_req, + CompletionQueue*)> start_req, std::function<void(grpc::Status, ResponseType*)> on_done) : ClientRpcContext(channel_id), context_(), @@ -143,8 +142,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function<void(grpc::Status, ResponseType*)> callback_; std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> - start_req_; + CompletionQueue*)> start_req_; grpc::Status status_; double start_; std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>> @@ -164,12 +162,11 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { using ClientImpl<StubType, RequestType>::cores_; using ClientImpl<StubType, RequestType>::channels_; using ClientImpl<StubType, RequestType>::request_; - AsyncClient( - const ClientConfig& config, - std::function<ClientRpcContext*(int, StubType*, const RequestType&)> - setup_ctx, - std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> - create_stub) + AsyncClient(const ClientConfig& config, + std::function<ClientRpcContext*(int, StubType*, + const RequestType&)> setup_ctx, + std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> + create_stub) : ClientImpl<StubType, RequestType>(config, create_stub), num_async_threads_(NumThreads(config)), channel_lock_(new std::mutex[config.client_channels()]), @@ -411,8 +408,7 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { std::function<std::unique_ptr< grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>( BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, - void*)> - start_req, + void*)> start_req, std::function<void(grpc::Status, ResponseType*)> on_done) : ClientRpcContext(channel_id), context_(), @@ -464,10 +460,10 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { ResponseType response_; bool (ClientRpcContextStreamingImpl::*next_state_)(bool, Histogram*); std::function<void(grpc::Status, ResponseType*)> callback_; - std::function<std::unique_ptr< - grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>( - BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, void*)> - start_req_; + std::function< + std::unique_ptr<grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>( + BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, + void*)> start_req_; grpc::Status status_; double start_; std::unique_ptr<grpc::ClientAsyncReaderWriter<RequestType, ResponseType>> @@ -511,8 +507,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { int channel_id, grpc::GenericStub* stub, const ByteBuffer& req, std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>( grpc::GenericStub*, grpc::ClientContext*, - const grpc::string& method_name, CompletionQueue*, void*)> - start_req, + const grpc::string& method_name, CompletionQueue*, void*)> start_req, std::function<void(grpc::Status, ByteBuffer*)> on_done) : ClientRpcContext(channel_id), context_(), @@ -569,8 +564,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { std::function<void(grpc::Status, ByteBuffer*)> callback_; std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>( grpc::GenericStub*, grpc::ClientContext*, const grpc::string&, - CompletionQueue*, void*)> - start_req_; + CompletionQueue*, void*)> start_req_; grpc::Status status_; double start_; std::unique_ptr<grpc::GenericClientAsyncReaderWriter> stream_; diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index c70b0303b8..80f6ada409 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -384,5 +384,18 @@ std::unique_ptr<ScenarioResult> RunScenario( delete[] servers; return result; } + +void RunQuit() { + // Get client, server lists + auto workers = get_workers("QPS_WORKERS"); + for (size_t i = 0; i < workers.size(); i++) { + auto stub = WorkerService::NewStub( + CreateChannel(workers[i], InsecureChannelCredentials())); + Void dummy; + grpc::ClientContext ctx; + GPR_ASSERT(stub->QuitWorker(&ctx, dummy, &dummy).ok()); + } +} + } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h index 2a7cf805e5..3af61f7391 100644 --- a/test/cpp/qps/driver.h +++ b/test/cpp/qps/driver.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,6 +70,7 @@ std::unique_ptr<ScenarioResult> RunScenario( const grpc::testing::ServerConfig& server_config, size_t num_servers, int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count); +void RunQuit(); } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index ffc8a83fc5..69fb4d75e8 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -78,6 +78,8 @@ DEFINE_int32(client_core_limit, -1, "Limit on client cores to use"); DEFINE_bool(secure_test, false, "Run a secure test"); +DEFINE_bool(quit, false, "Quit the workers"); + using grpc::testing::ClientConfig; using grpc::testing::ServerConfig; using grpc::testing::ClientType; @@ -90,6 +92,11 @@ namespace grpc { namespace testing { static void QpsDriver() { + if (FLAGS_quit) { + RunQuit(); + return; + } + RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 7e9e05f7ec..9442017ddf 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -103,8 +103,8 @@ static std::unique_ptr<Server> CreateServer(const ServerConfig& config) { class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { public: - explicit WorkerServiceImpl(int server_port) - : acquired_(false), server_port_(server_port) {} + WorkerServiceImpl(int server_port, QpsWorker* worker) + : acquired_(false), server_port_(server_port), worker_(worker) {} Status RunClient(ServerContext* ctx, ServerReaderWriter<ClientStatus, ClientArgs>* stream) @@ -140,6 +140,16 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { return Status::OK; } + Status QuitWorker(ServerContext* ctx, const Void*, Void*) GRPC_OVERRIDE { + InstanceGuard g(this); + if (!g.Acquired()) { + return Status(StatusCode::RESOURCE_EXHAUSTED, ""); + } + + worker_->MarkDone(); + return Status::OK; + } + private: // Protect against multiple clients using this worker at once. class InstanceGuard { @@ -250,10 +260,12 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { std::mutex mu_; bool acquired_; int server_port_; + QpsWorker* worker_; }; QpsWorker::QpsWorker(int driver_port, int server_port) { - impl_.reset(new WorkerServiceImpl(server_port)); + impl_.reset(new WorkerServiceImpl(server_port, this)); + gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0)); char* server_address = NULL; gpr_join_host_port(&server_address, "::", driver_port); @@ -269,5 +281,11 @@ QpsWorker::QpsWorker(int driver_port, int server_port) { QpsWorker::~QpsWorker() {} +bool QpsWorker::Done() const { + return (gpr_atm_acq_load(&done_) != static_cast<gpr_atm>(0)); +} +void QpsWorker::MarkDone() { + gpr_atm_rel_store(&done_, static_cast<gpr_atm>(1)); +} } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/qps_worker.h b/test/cpp/qps/qps_worker.h index 27de69fa65..624c182100 100644 --- a/test/cpp/qps/qps_worker.h +++ b/test/cpp/qps/qps_worker.h @@ -36,6 +36,8 @@ #include <memory> +#include <grpc/support/atm.h> + namespace grpc { class Server; @@ -49,9 +51,14 @@ class QpsWorker { explicit QpsWorker(int driver_port, int server_port = 0); ~QpsWorker(); + bool Done() const; + void MarkDone(); + private: std::unique_ptr<WorkerServiceImpl> impl_; std::unique_ptr<Server> server_; + + gpr_atm done_; }; } // namespace testing diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index a1e73e9abe..f42cfe3255 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -56,7 +56,7 @@ namespace testing { static void RunServer() { QpsWorker worker(FLAGS_driver_port, FLAGS_server_port); - while (!got_sigint) { + while (!got_sigint && !worker.Done()) { gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5, GPR_TIMESPAN))); } diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc index 1e501dfd28..48c6ce7697 100644 --- a/test/cpp/util/time_test.cc +++ b/test/cpp/util/time_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ namespace { class TimeTest : public ::testing::Test {}; TEST_F(TimeTest, AbsolutePointTest) { - long us = 10000000L; + int64_t us = 10000000L; gpr_timespec ts = gpr_time_from_micros(us, GPR_TIMESPAN); ts.clock_type = GPR_CLOCK_REALTIME; system_clock::time_point tp{microseconds(us)}; diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh index 5a01c91875..1de62041b3 100755 --- a/test/distrib/csharp/run_distrib_test.sh +++ b/test/distrib/csharp/run_distrib_test.sh @@ -32,10 +32,11 @@ set -ex cd $(dirname $0) -unzip "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets.zip" -d TestNugetFeed +unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets.zip" -d TestNugetFeed -# TODO(jtattermusch): replace the version number -./update_version.sh 0.13.0 +# Extract the version number from Grpc nuget package name. +CSHARP_VERSION=$(ls TestNugetFeed | grep '^Grpc\.[0-9].*\.nupkg$' | sed s/^Grpc\.// | sed s/\.nupkg$//) +./update_version.sh $CSHARP_VERSION nuget restore diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh index 569f7ff4bd..f2554e8998 100755 --- a/test/distrib/csharp/update_version.sh +++ b/test/distrib/csharp/update_version.sh @@ -33,4 +33,4 @@ set -e cd $(dirname $0) # Replaces version placeholder with value provided as first argument. -sed -i "s/__GRPC_NUGET_VERSION__/$1/g" DistribTest/packages.config DistribTest/DistribTest.csproj +sed -ibak "s/__GRPC_NUGET_VERSION__/$1/g" DistribTest/packages.config DistribTest/DistribTest.csproj diff --git a/test/distrib/node/distrib_test.js b/test/distrib/node/distrib_test.js new file mode 100755 index 0000000000..cdd8eba8b8 --- /dev/null +++ b/test/distrib/node/distrib_test.js @@ -0,0 +1,57 @@ +#!/usr/bin/env node +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +var grpc = require('grpc'); + +function identity(x) { + return x; +} + +var Client = grpc.makeGenericClientConstructor({ + 'echo' : { + path: '/buffer/echo', + requestStream: false, + responseStream: false, + requestSerialize: identity, + requestDeserialize: identity, + responseSerialize: identity, + responseDeserialize: identity + } +}); + +var client = new Client("localhost:1000", grpc.credentials.createInsecure()); + +client.$channel.close(); + +console.log("Success!"); diff --git a/test/distrib/node/package.json b/test/distrib/node/package.json new file mode 100644 index 0000000000..b02a796c97 --- /dev/null +++ b/test/distrib/node/package.json @@ -0,0 +1,7 @@ +{ + "name": "grpc-distrib-test", + "version": "0.0.1", + "dependencies": { + "grpc": "*" + } +} diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh new file mode 100755 index 0000000000..99a51f01f7 --- /dev/null +++ b/test/distrib/node/run_distrib_test.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# Copyright 2015-2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +NODE_VERSION=$1 +source ~/.nvm/nvm.sh +set -ex + +cd $(dirname $0) + +nvm install $NODE_VERSION + +npm install -g node-static + +STATIC_SERVER=127.0.0.1 +STATIC_PORT=8080 + +# Serves the input_artifacts directory statically at localhost:8080 +static "$EXTERNAL_GIT_ROOT/input_artifacts" -a $STATIC_SERVER -p $STATIC_PORT & +STATIC_PID=$! + +STATIC_URL="http://$STATIC_SERVER:$STATIC_PORT/" + +npm install --unsafe-perm $STATIC_URL/grpc.tgz --grpc_node_binary_host_mirror=$STATIC_URL + +kill -9 $STATIC_PID + +./distrib_test.js diff --git a/test/distrib/python/distribtest.py b/test/distrib/python/distribtest.py new file mode 100644 index 0000000000..66c1f88796 --- /dev/null +++ b/test/distrib/python/distribtest.py @@ -0,0 +1,36 @@ +# Copyright 2015-2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from grpc.beta import implementations + +# This code doesn't do much but makes sure the native extension is loaded +# which is what we are testing here. +channel = implementations.insecure_channel('localhost', 1000) +del channel +print 'Success!' diff --git a/test/distrib/python/run_distrib_test.sh b/test/distrib/python/run_distrib_test.sh index 34e3efccbd..8fd7ffb54c 100755 --- a/test/distrib/python/run_distrib_test.sh +++ b/test/distrib/python/run_distrib_test.sh @@ -32,5 +32,27 @@ set -ex cd $(dirname $0) -pip install "$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-0.12.0b6.tar.gz" +# Pick up the source dist archive whatever its version is +SDIST_ARCHIVE=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-*.tar.gz +BDIST_DIR="file://$EXTERNAL_GIT_ROOT/input_artifacts" + +if [ ! -f ${SDIST_ARCHIVE} ] +then + echo "Archive ${SDIST_ARCHIVE} does not exist." + exit 1 +fi + +PIP=pip2 +which $PIP || PIP=pip +PYTHON=python2 +which $PYTHON || PYTHON=python + +# TODO(jtattermusch): this shouldn't be required +$PIP install --upgrade six + +GRPC_PYTHON_BINARIES_REPOSITORY="${BDIST_DIR}" \ + $PIP install \ + ${SDIST_ARCHIVE} + +$PYTHON distribtest.py |