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")
 def test_start_proxy_with_all_instances_generated_credential_file(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)
 def test_start_proxy_fail_no_parameters(self):
     runner = CloudSqlProxyRunner(path_prefix='/tmp/' + self.generate_unique_path(),
                                  project_id=GCP_PROJECT_ID,
                                  instance_specification='a')
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("The cloud_sql_proxy finished early", str(err))
     with self.assertRaises(AirflowException) as cm:
         runner.start_proxy()
     err = cm.exception
     self.assertIn("The cloud_sql_proxy finished early", str(err))
     self.assertIsNone(runner.sql_proxy_process)
Пример #4
0
 def test_start_proxy_fail_no_parameters(self):
     runner = CloudSqlProxyRunner(
         path_prefix='/tmp/' + self.generate_unique_path(),
         project_id=GCP_PROJECT_ID,
         instance_specification='a',
     )
     with pytest.raises(AirflowException) as ctx:
         runner.start_proxy()
     err = ctx.value
     assert "The cloud_sql_proxy finished early" in str(err)
     with pytest.raises(AirflowException) as ctx:
         runner.start_proxy()
     err = ctx.value
     assert "The cloud_sql_proxy finished early" in str(err)
     assert runner.sql_proxy_process is None