diff options
author | adelez <adelez@google.com> | 2017-12-01 09:42:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 09:42:04 -0800 |
commit | f0b952824b44d55b75dd0bdded70bb743958cead (patch) | |
tree | 46b38ef1709ed28e44d551375269e1921dea32ac /test/core/util | |
parent | 19bb7e43276dd39d47108a023d9c518366c77888 (diff) | |
parent | 5b7cdefb681977357573d9eac866520610d19fa5 (diff) |
Merge pull request #13442 from adelez/foundry_integration
Create a pilot job to run bazel tests remotely
Diffstat (limited to 'test/core/util')
-rw-r--r-- | test/core/util/BUILD | 1 | ||||
-rw-r--r-- | test/core/util/port_isolated_runtime_environment.cc | 42 | ||||
-rw-r--r-- | test/core/util/test_config.h | 2 |
3 files changed, 44 insertions, 1 deletions
diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 268547f6c9..ec88d767ce 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -57,6 +57,7 @@ grpc_cc_library( "parse_hexstring.cc", "passthru_endpoint.cc", "port.cc", + "port_isolated_runtime_environment.cc", "port_server_client.cc", "reconnect_server.cc", "slice_splitter.cc", diff --git a/test/core/util/port_isolated_runtime_environment.cc b/test/core/util/port_isolated_runtime_environment.cc new file mode 100644 index 0000000000..5f0585e9fb --- /dev/null +++ b/test/core/util/port_isolated_runtime_environment.cc @@ -0,0 +1,42 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* When running tests on remote machines, the framework takes a round-robin pick + * of a port within certain range. There is no need to recycle ports. + */ +#include "src/core/lib/iomgr/port.h" +#include "test/core/util/test_config.h" +#if defined(GRPC_PORT_ISOLATED_RUNTIME) + +#include "test/core/util/port.h" + +#define LOWER_PORT 49152 +static int s_allocated_port = LOWER_PORT; + +int grpc_pick_unused_port_or_die(void) { + int allocated_port = s_allocated_port++; + if (s_allocated_port == 65536) { + s_allocated_port = LOWER_PORT; + } + + return allocated_port; +} + +void grpc_recycle_unused_port(int port) { (void)port; } + +#endif /* GRPC_PORT_ISOLATED_RUNTIME */ diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 775ffac949..5b3d34799e 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -33,7 +33,7 @@ gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s); /* Converts a given timeout (in milliseconds) to a deadline. */ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); -#ifndef GRPC_TEST_CUSTOM_PICK_PORT +#if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_PORT_ISOLATED_RUNTIME) #define GRPC_TEST_PICK_PORT #endif |