Exemplo n.º 1
0
 def test_namespace_from_connection(self, mock_create_namespaced_crd,
                                    mock_kubernetes_hook):
     op = SparkKubernetesOperator(
         application_file=TEST_VALID_APPLICATION_JSON,
         dag=self.dag,
         kubernetes_conn_id='kubernetes_with_namespace',
         task_id='test_task_id')
     op.execute(None)
     mock_kubernetes_hook.assert_called_once_with()
     mock_create_namespaced_crd.assert_called_with(
         body=TEST_APPLICATION_DICT,
         group='sparkoperator.k8s.io',
         namespace='mock_namespace',
         plural='sparkapplications',
         version='v1beta2')
Exemplo n.º 2
0
 def test_create_application_from_json_with_api_group_and_version(
         self, mock_create_namespaced_crd, mock_kubernetes_hook):
     api_group = 'sparkoperator.example.com'
     api_version = 'v1alpha1'
     op = SparkKubernetesOperator(
         application_file=TEST_VALID_APPLICATION_JSON,
         dag=self.dag,
         kubernetes_conn_id='kubernetes_default_kube_config',
         task_id='test_task_id',
         api_group=api_group,
         api_version=api_version,
     )
     op.execute(None)
     mock_kubernetes_hook.assert_called_once_with()
     mock_create_namespaced_crd.assert_called_with(
         body=TEST_APPLICATION_DICT,
         group=api_group,
         namespace='default',
         plural='sparkapplications',
         version=api_version,
     )