def test_start_proxy_with_all_instances(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
 def test_start_proxy_with_all_instances_generated_credential_file(self):
     self.update_connection_with_dictionary()
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
 def test_start_proxy_with_all_instances_generated_credential_file(self):
     self.gcp_authenticator.set_dictionary_in_airflow_connection()
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + self.generate_unique_path(),
                                  project_id=GCP_PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
 def test_start_proxy_fail_no_parameters(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='a')
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("invalid instance name", str(err))
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("invalid instance name", str(err))
     self.assertIsNone(runner.sql_proxy_process)
Ejemplo n.º 5
0
 def test_start_proxy_with_all_instances_specific_version(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='',
                                  sql_proxy_version='v1.13')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
     self.assertEqual(runner.get_proxy_version(), "1.13")
Ejemplo n.º 6
0
 def test_start_proxy_with_all_instances(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + self.generate_unique_path(),
                                  project_id=GCP_PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
Ejemplo n.º 7
0
 def test_start_proxy_with_all_instances_generated_credential_file(self):
     self.update_connection_with_dictionary()
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
Ejemplo n.º 8
0
 def test_start_proxy_with_all_instances_generated_credential_file(self):
     self.gcp_authenticator.set_dictionary_in_airflow_connection()
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + self.generate_unique_path(),
                                  project_id=GCP_PROJECT_ID,
                                  instance_specification='')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
 def test_start_proxy_with_all_instances_specific_version(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + self.generate_unique_path(),
                                  project_id=GCP_PROJECT_ID,
                                  instance_specification='',
                                  sql_proxy_version='v1.13')
     try:
         runner.start_proxy()
         time.sleep(1)
     finally:
         runner.stop_proxy()
     self.assertIsNone(runner.sql_proxy_process)
     self.assertEqual(runner.get_proxy_version(), "1.13")
Ejemplo n.º 10
0
 def test_start_proxy_fail_no_parameters(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + str(uuid1()),
                                  project_id=PROJECT_ID,
                                  instance_specification='a')
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("invalid instance name", str(err))
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("invalid instance name", str(err))
     self.assertIsNone(runner.sql_proxy_process)