Merge branch 'master' into grpc_tools_docker_pregenerate_ssh_key

pull/15/head
Tim Emiola 10 years ago
commit 41a19c6cb0
  1. 6
      .gitignore
  2. 638
      Makefile
  3. 15
      build.json
  4. 4
      src/compiler/go_generator.cc
  5. 2
      src/compiler/go_generator.h
  6. 1
      src/core/iomgr/pollset.h
  7. 24
      templates/Makefile.template
  8. 8
      test/core/util/port.h
  9. 12
      test/cpp/client/channel_arguments_test.cc
  10. 2
      test/cpp/client/credentials_test.cc
  11. 8
      test/cpp/end2end/end2end_test.cc
  12. 4
      test/cpp/end2end/sync_client_async_server_test.cc
  13. 4
      test/cpp/qps/qpstest.proto
  14. 50
      tools/run_tests/jobset.py
  15. 67
      tools/run_tests/run_tests.py

6
.gitignore vendored

@ -0,0 +1,6 @@
bins
deps
libs
objs
*.pyc

File diff suppressed because one or more lines are too long

@ -1341,6 +1341,7 @@
"test/cpp/end2end/sync_client_async_server_test.cc" "test/cpp/end2end/sync_client_async_server_test.cc"
], ],
"deps": [ "deps": [
"grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -1353,9 +1354,7 @@
"build": "test", "build": "test",
"c++": true, "c++": true,
"src": [ "src": [
"test/cpp/interop/empty.proto", "test/cpp/qps/qpstest.proto",
"test/cpp/interop/messages.proto",
"test/cpp/interop/test.proto",
"test/cpp/qps/client.cc" "test/cpp/qps/client.cc"
], ],
"deps": [ "deps": [
@ -1372,9 +1371,7 @@
"build": "test", "build": "test",
"c++": true, "c++": true,
"src": [ "src": [
"test/cpp/interop/empty.proto", "test/cpp/qps/qpstest.proto",
"test/cpp/interop/messages.proto",
"test/cpp/interop/test.proto",
"test/cpp/qps/server.cc" "test/cpp/qps/server.cc"
], ],
"deps": [ "deps": [
@ -1451,7 +1448,8 @@
], ],
"deps": [ "deps": [
"grpc++", "grpc++",
"grpc" "grpc",
"gpr"
] ]
}, },
{ {
@ -1463,7 +1461,8 @@
], ],
"deps": [ "deps": [
"grpc++", "grpc++",
"grpc" "grpc",
"gpr"
] ]
}, },
{ {

@ -31,8 +31,6 @@
* *
*/ */
using namespace std;
#include "src/compiler/go_generator.h" #include "src/compiler/go_generator.h"
#include <cctype> #include <cctype>
@ -42,6 +40,8 @@ using namespace std;
#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
using namespace std;
namespace grpc_go_generator { namespace grpc_go_generator {
bool NoStreaming(const google::protobuf::MethodDescriptor* method) { bool NoStreaming(const google::protobuf::MethodDescriptor* method) {

@ -44,7 +44,7 @@ class FileDescriptor;
namespace grpc_go_generator { namespace grpc_go_generator {
string GetServices(const google::protobuf::FileDescriptor* file); std::string GetServices(const google::protobuf::FileDescriptor* file);
} // namespace grpc_go_generator } // namespace grpc_go_generator

@ -35,6 +35,7 @@
#define __GRPC_INTERNAL_IOMGR_POLLSET_H_ #define __GRPC_INTERNAL_IOMGR_POLLSET_H_
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
/* A grpc_pollset is a set of file descriptors that a higher level item is /* A grpc_pollset is a set of file descriptors that a higher level item is
interested in. For example: interested in. For example:

@ -2,6 +2,7 @@
# This currently builds C and C++ code. # This currently builds C and C++ code.
<%! <%!
import re import re
import os
proto_re = re.compile('(.*)\\.proto') proto_re = re.compile('(.*)\\.proto')
@ -355,7 +356,7 @@ buildtests_c: bins_dep_c privatelibs_c\
buildtests_cxx: bins_dep_cxx privatelibs_cxx\ buildtests_cxx: bins_dep_cxx privatelibs_cxx\
% for tgt in targets: % for tgt in targets:
% if tgt.build == 'test' and tgt.get('c++', False): % if tgt.build == 'test' and tgt.get('c++', False):
bins/${tgt.name}\ bins/$(CONFIG)/${tgt.name}\
% endif % endif
% endfor % endfor
@ -687,6 +688,7 @@ libs/$(CONFIG)/lib${lib.name}.a: $(LIB${lib.name.upper()}_OBJS)
$(Q) $(AR) rcs libs/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) $(Q) $(AR) rcs libs/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
% if lib.get('baselib', False): % if lib.get('baselib', False):
% if lib.get('secure', True): % if lib.get('secure', True):
$(Q) rm -rf tmp-merge
$(Q) mkdir tmp-merge $(Q) mkdir tmp-merge
$(Q) ( cd tmp-merge ; $(AR) x ../libs/$(CONFIG)/lib${lib.name}.a ) $(Q) ( cd tmp-merge ; $(AR) x ../libs/$(CONFIG)/lib${lib.name}.a )
$(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done
@ -760,6 +762,18 @@ endif
endif endif
% endif % endif
% for src in lib.src:
% if not proto_re.match(src):
objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% for src2 in lib.src:
% if proto_re.match(src2):
${proto_to_cc(src2)}\
% endif
% endfor
% endif
% endfor
clean_lib${lib.name}: clean_lib${lib.name}:
$(E) "[CLEAN] Cleaning lib${lib.name} files" $(E) "[CLEAN] Cleaning lib${lib.name} files"
$(Q) $(RM) $(LIB${lib.name.upper()}_OBJS) $(Q) $(RM) $(LIB${lib.name.upper()}_OBJS)
@ -836,6 +850,14 @@ bins/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
endif endif
% endif % endif
% for src in tgt.src:
objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% for dep in tgt.deps:
libs/$(CONFIG)/lib${dep}.a\
% endfor
% endfor
deps_${tgt.name}: $(${tgt.name.upper()}_DEPS) deps_${tgt.name}: $(${tgt.name.upper()}_DEPS)
% if tgt.get('secure', True): % if tgt.get('secure', True):

@ -34,6 +34,10 @@
#ifndef __GRPC_TEST_UTIL_PORT_H__ #ifndef __GRPC_TEST_UTIL_PORT_H__
#define __GRPC_TEST_UTIL_PORT_H__ #define __GRPC_TEST_UTIL_PORT_H__
#ifdef __cplusplus
extern "C" {
#endif
/* pick a port number that is currently unused by either tcp or udp. return /* pick a port number that is currently unused by either tcp or udp. return
0 on failure. */ 0 on failure. */
int grpc_pick_unused_port(); int grpc_pick_unused_port();
@ -41,4 +45,8 @@ int grpc_pick_unused_port();
on failure. */ on failure. */
int grpc_pick_unused_port_or_die(); int grpc_pick_unused_port_or_die();
#ifdef __cplusplus
}
#endif
#endif /* __GRPC_TEST_UTIL_PORT_H__ */ #endif /* __GRPC_TEST_UTIL_PORT_H__ */

@ -69,15 +69,12 @@ TEST_F(ChannelArgumentsTest, SetInt) {
key = ""; key = "";
SetChannelArgs(channel_args, &args); SetChannelArgs(channel_args, &args);
EXPECT_EQ(2, args.num_args); EXPECT_EQ(2, args.num_args);
bool found[2] = {false, false};
// We do not enforce order on the arguments. // We do not enforce order on the arguments.
for (int i = 0; i < args.num_args; i++) { for (size_t i = 0; i < args.num_args; i++) {
EXPECT_EQ(GRPC_ARG_INTEGER, args.args[i].type); EXPECT_EQ(GRPC_ARG_INTEGER, args.args[i].type);
if (grpc::string(args.args[i].key) == "key0") { if (grpc::string(args.args[i].key) == "key0") {
found[0] = true;
EXPECT_EQ(0, args.args[i].value.integer); EXPECT_EQ(0, args.args[i].value.integer);
} else if (grpc::string(args.args[i].key) == "key1") { } else if (grpc::string(args.args[i].key) == "key1") {
found[1] = true;
EXPECT_EQ(1, args.args[i].value.integer); EXPECT_EQ(1, args.args[i].value.integer);
} }
} }
@ -107,15 +104,12 @@ TEST_F(ChannelArgumentsTest, SetString) {
channel_args.SetString(key, val); channel_args.SetString(key, val);
SetChannelArgs(channel_args, &args); SetChannelArgs(channel_args, &args);
EXPECT_EQ(2, args.num_args); EXPECT_EQ(2, args.num_args);
bool found[2] = {false, false};
// We do not enforce order on the arguments. // We do not enforce order on the arguments.
for (int i = 0; i < args.num_args; i++) { for (size_t i = 0; i < args.num_args; i++) {
EXPECT_EQ(GRPC_ARG_STRING, args.args[i].type); EXPECT_EQ(GRPC_ARG_STRING, args.args[i].type);
if (grpc::string(args.args[i].key) == "key0") { if (grpc::string(args.args[i].key) == "key0") {
found[0] = true;
EXPECT_STREQ("val0", args.args[i].value.string); EXPECT_STREQ("val0", args.args[i].value.string);
} else if (grpc::string(args.args[i].key) == "key1") { } else if (grpc::string(args.args[i].key) == "key1") {
found[1] = true;
EXPECT_STREQ("val1", args.args[i].value.string); EXPECT_STREQ("val1", args.args[i].value.string);
} }
} }
@ -125,6 +119,6 @@ TEST_F(ChannelArgumentsTest, SetString) {
} // namespace grpc } // namespace grpc
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

@ -65,7 +65,7 @@ TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
} // namespace grpc } // namespace grpc
int main(int argc, char **argv) { int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
grpc_init(); grpc_init();
int ret = RUN_ALL_TESTS(); int ret = RUN_ALL_TESTS();
grpc_shutdown(); grpc_shutdown();

@ -34,7 +34,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include "net/grpc/cpp/echo_duplicate_proto_cc.pb.h" #include "test/cpp/util/echo_duplicate.pb.h"
#include "test/cpp/util/echo.pb.h" #include "test/cpp/util/echo.pb.h"
#include "src/cpp/util/time.h" #include "src/cpp/util/time.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
@ -47,7 +47,7 @@
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
#include <grpc++/status.h> #include <grpc++/status.h>
#include <grpc++/stream.h> #include <grpc++/stream.h>
#include "net/util/netutil.h" #include "test/core/util/port.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -141,7 +141,7 @@ class TestServiceImplDupPkg
class End2endTest : public ::testing::Test { class End2endTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
int port = PickUnusedPortOrDie(); int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port; server_address_ << "localhost:" << port;
// Setup server // Setup server
ServerBuilder builder; ServerBuilder builder;
@ -189,7 +189,7 @@ TEST_F(End2endTest, SimpleRpc) {
TEST_F(End2endTest, MultipleRpcs) { TEST_F(End2endTest, MultipleRpcs) {
ResetStub(); ResetStub();
vector<std::thread*> threads; std::vector<std::thread*> threads;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
threads.push_back(new std::thread(SendRpc, stub_.get(), 10)); threads.push_back(new std::thread(SendRpc, stub_.get(), 10));
} }

@ -49,7 +49,7 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include <grpc++/stream.h> #include <grpc++/stream.h>
#include "test/cpp/end2end/async_test_server.h" #include "test/cpp/end2end/async_test_server.h"
#include "net/util/netutil.h" #include "test/core/util/port.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
using grpc::cpp::test::util::EchoRequest; using grpc::cpp::test::util::EchoRequest;
@ -73,7 +73,7 @@ void ServerLoop(void* s) {
class End2endTest : public ::testing::Test { class End2endTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
int port = PickUnusedPortOrDie(); int port = grpc_pick_unused_port_or_die();
// TODO(yangg) protobuf has a StringPrintf, maybe use that // TODO(yangg) protobuf has a StringPrintf, maybe use that
std::ostringstream oss; std::ostringstream oss;
oss << "[::]:" << port; oss << "[::]:" << port;

@ -4,10 +4,6 @@ syntax = "proto2";
package grpc.testing; package grpc.testing;
option java_api_version = 2;
option cc_api_version = 2;
option java_package = "com.google.net.stubby.testing.integration";
enum PayloadType { enum PayloadType {
// Compressable text format. // Compressable text format.
COMPRESSABLE= 1; COMPRESSABLE= 1;

@ -39,6 +39,36 @@ _RUNNING = object()
_KILLED = object() _KILLED = object()
_COLORS = {
'red': 31,
'green': 32,
'yellow': 33,
}
_BEGINNING_OF_LINE = '\x1b[0G'
_CLEAR_LINE = '\x1b[2K'
_TAG_COLOR = {
'FAILED': 'red',
'PASSED': 'green',
'START': 'yellow',
'WAITING': 'yellow',
}
def message(tag, message, explanatory_text=None):
sys.stdout.write('%s%s\x1b[%dm%s\x1b[0m: %s%s' % (
_BEGINNING_OF_LINE,
_CLEAR_LINE,
_COLORS[_TAG_COLOR[tag]],
tag,
message,
'\n%s\n' % explanatory_text if explanatory_text is not None else ''))
sys.stdout.flush()
class Job(object): class Job(object):
"""Manages one job.""" """Manages one job."""
@ -49,9 +79,7 @@ class Job(object):
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdout=self._tempfile) stdout=self._tempfile)
self._state = _RUNNING self._state = _RUNNING
sys.stdout.write('\x1b[0G\x1b[2K\x1b[33mSTART\x1b[0m: %s' % message('START', self._cmdline)
self._cmdline)
sys.stdout.flush()
def state(self): def state(self):
"""Poll current state of the job. Prints messages at completion.""" """Poll current state of the job. Prints messages at completion."""
@ -60,16 +88,10 @@ class Job(object):
self._state = _FAILURE self._state = _FAILURE
self._tempfile.seek(0) self._tempfile.seek(0)
stdout = self._tempfile.read() stdout = self._tempfile.read()
sys.stdout.write('\x1b[0G\x1b[2K\x1b[31mFAILED\x1b[0m: %s' message('FAILED', '%s [ret=%d]' % (self._cmdline, self._process.returncode), stdout)
' [ret=%d]\n'
'%s\n' % (
self._cmdline, self._process.returncode, stdout))
sys.stdout.flush()
else: else:
self._state = _SUCCESS self._state = _SUCCESS
sys.stdout.write('\x1b[0G\x1b[2K\x1b[32mPASSED\x1b[0m: %s' % message('PASSED', '%s' % self._cmdline)
self._cmdline)
sys.stdout.flush()
return self._state return self._state
def kill(self): def kill(self):
@ -86,6 +108,7 @@ class Jobset(object):
self._check_cancelled = check_cancelled self._check_cancelled = check_cancelled
self._cancelled = False self._cancelled = False
self._failures = 0 self._failures = 0
self._completed = 0
self._maxjobs = maxjobs self._maxjobs = maxjobs
def start(self, cmdline): def start(self, cmdline):
@ -107,8 +130,11 @@ class Jobset(object):
if st == _FAILURE: self._failures += 1 if st == _FAILURE: self._failures += 1
dead.add(job) dead.add(job)
for job in dead: for job in dead:
self._completed += 1
self._running.remove(job) self._running.remove(job)
if not dead: return if dead: return
message('WAITING', '%d jobs running, %d complete' % (
len(self._running), self._completed))
time.sleep(0.1) time.sleep(0.1)
def cancelled(self): def cancelled(self):

@ -11,15 +11,44 @@ import time
import jobset import jobset
import watch_dirs import watch_dirs
# flags required for make for each configuration # SimpleConfig: just compile with CONFIG=config, and run the binary to test
_CONFIGS = ['dbg', 'opt', 'tsan', 'msan', 'asan'] class SimpleConfig(object):
def __init__(self, config):
self.build_config = config
def run_command(self, binary):
return [binary]
# ValgrindConfig: compile with some CONFIG=config, but use valgrind to run
class ValgrindConfig(object):
def __init__(self, config):
self.build_config = config
def run_command(self, binary):
return ['valgrind', binary]
# different configurations we can run under
_CONFIGS = {
'dbg': SimpleConfig('dbg'),
'opt': SimpleConfig('opt'),
'tsan': SimpleConfig('tsan'),
'msan': SimpleConfig('msan'),
'asan': SimpleConfig('asan'),
'valgrind': ValgrindConfig('dbg'),
}
_DEFAULT = ['dbg', 'opt']
_MAKE_TEST_TARGETS = ['buildtests_c', 'buildtests_cxx']
# parse command line # parse command line
argp = argparse.ArgumentParser(description='Run grpc tests.') argp = argparse.ArgumentParser(description='Run grpc tests.')
argp.add_argument('-c', '--config', argp.add_argument('-c', '--config',
choices=['all'] + _CONFIGS, choices=['all'] + sorted(_CONFIGS.keys()),
nargs='+', nargs='+',
default=['all']) default=_DEFAULT)
argp.add_argument('-t', '--test-filter', nargs='*', default=['*']) argp.add_argument('-t', '--test-filter', nargs='*', default=['*'])
argp.add_argument('-n', '--runs_per_test', default=1, type=int) argp.add_argument('-n', '--runs_per_test', default=1, type=int)
argp.add_argument('-f', '--forever', argp.add_argument('-f', '--forever',
@ -29,10 +58,11 @@ argp.add_argument('-f', '--forever',
args = argp.parse_args() args = argp.parse_args()
# grab config # grab config
configs = [cfg run_configs = set(_CONFIGS[cfg]
for cfg in itertools.chain.from_iterable( for cfg in itertools.chain.from_iterable(
_CONFIGS if x == 'all' else [x] _CONFIGS.iterkeys() if x == 'all' else [x]
for x in args.config)] for x in args.config))
build_configs = set(cfg.build_config for cfg in run_configs)
filters = args.test_filter filters = args.test_filter
runs_per_test = args.runs_per_test runs_per_test = args.runs_per_test
forever = args.forever forever = args.forever
@ -44,19 +74,22 @@ def _build_and_run(check_cancelled):
if not jobset.run( if not jobset.run(
(['make', (['make',
'-j', '%d' % (multiprocessing.cpu_count() + 1), '-j', '%d' % (multiprocessing.cpu_count() + 1),
'buildtests_c', target,
'CONFIG=%s' % cfg] 'CONFIG=%s' % cfg]
for cfg in configs), check_cancelled, maxjobs=1): for cfg in build_configs
for target in _MAKE_TEST_TARGETS),
check_cancelled, maxjobs=1):
sys.exit(1) sys.exit(1)
# run all the tests # run all the tests
jobset.run(([x] jobset.run((
for x in itertools.chain.from_iterable( config.run_command(x)
itertools.chain.from_iterable(itertools.repeat( for config in run_configs
glob.glob('bins/%s/%s_test' % (config, filt)), for filt in filters
runs_per_test)) for x in itertools.chain.from_iterable(itertools.repeat(
for config in configs glob.glob('bins/%s/%s_test' % (
for filt in filters)), check_cancelled) config.build_config, filt)),
runs_per_test))), check_cancelled)
if forever: if forever:

Loading…
Cancel
Save