| 
					
				 | 
			
			
				@@ -35,8 +35,93 @@ import itertools 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import xml.etree.cElementTree as ET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import jobset 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+_CLOUD_TO_PROD_BASE_ARGS = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '--server_host_override=grpc-test.sandbox.google.com', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '--server_host=grpc-test.sandbox.google.com', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    '--server_port=443'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# TOOD(jtattermusch) wrapped languages use this variable for location  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# of roots.pem. We might want to use GRPC_DEFAULT_SSL_ROOTS_FILE_PATH 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# supported by C core SslCredentials instead. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+_SSL_CERT_ENV = { 'SSL_CERT_FILE':'/usr/local/share/grpc/roots.pem' } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# TODO(jtatttermusch) unify usage of --enable_ssl, --use_tls and --use_tls=true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class CXXLanguage: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __init__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cmdline_base = ['bins/opt/interop_client'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cwd = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_args(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ['--enable_ssl','--use_prod_roots']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_env(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __str__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return 'c++' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class CSharpLanguage: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __init__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cmdline_base = ['mono', 'Grpc.IntegrationTesting.Client.exe'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_args(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ['--use_tls']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_env(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return _SSL_CERT_ENV 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __str__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return 'csharp' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class NodeLanguage: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __init__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cmdline_base = ['node', 'src/node/interop/interop_client.js'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cwd = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_args(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ['--use_tls=true']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_env(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return _SSL_CERT_ENV 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __str__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return 'node' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class RubyLanguage: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __init__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cmdline_base = ['ruby', 'src/ruby/bin/interop/interop_client.rb'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    self.client_cwd = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_args(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ['--use_tls']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def cloud_to_prod_env(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return _SSL_CERT_ENV 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  def __str__(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return 'ruby' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # TODO(jtattermusch): add php and python once we get them working 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-_LANGUAGES = ['c++', 'node', 'csharp', 'ruby'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+_LANGUAGES = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'c++' : CXXLanguage(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'csharp' : CSharpLanguage(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'node' : NodeLanguage(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'ruby' : RubyLanguage(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # TODO(jtattermusch): add empty_stream once C++ start supporting it. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # TODO(jtattermusch): add support for auth tests. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -45,6 +130,17 @@ _TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                'cancel_after_begin', 'cancel_after_first_response', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                'timeout_on_sleeping_server'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def cloud_to_prod_jobspec(language, test_case): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  """Creates jobspec for cloud-to-prod interop test""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  cmdline = language.cloud_to_prod_args() + ['--test_case=%s' % test_case] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  test_job = jobset.JobSpec( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          cmdline=cmdline, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          cwd=language.client_cwd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          shortname="cloud_to_prod:%s:%s" % (language, test_case), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          environ=language.cloud_to_prod_env(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          timeout_seconds=60) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return test_job 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 argp = argparse.ArgumentParser(description='Run interop tests.') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 argp.add_argument('-l', '--language', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   choices=['all'] + sorted(_LANGUAGES), 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -52,18 +148,18 @@ argp.add_argument('-l', '--language', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   default=['all']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 args = argp.parse_args() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-languages = [l for l in itertools.chain.from_iterable( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                      iter(_LANGUAGES) if x == 'all' else [x] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                      for x in args.language)] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+languages = set(_LANGUAGES[l] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for l in itertools.chain.from_iterable( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                      _LANGUAGES.iterkeys() if x == 'all' else [x] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                      for x in args.language)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# TODO(jtattermusch): make python script generate cmdline params for interop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# tests. It's easier to manage than in a shell script. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 jobs = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 jobNumber = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 for language in languages: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  for test in _TEST_CASES: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    test_job = jobset.JobSpec( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          cmdline=['tools/run_tests/run_interop_test.sh', '%s' % language, '%s' % test],  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          shortname="cloud_to_prod:%s:%s" % (language, test), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          timeout_seconds=60) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  for test_case in _TEST_CASES: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    test_job = cloud_to_prod_jobspec(language, test_case) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     jobs.append(test_job) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     jobNumber+=1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |