Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,10 @@ def test_task_retry_on_api_failure(self, _, mock_executor, caplog):
mock_executor.attempt_submit_jobs()
mock_executor.sync_running_jobs()
for i in range(2):
assert f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
assert (
f"Airflow task {airflow_keys[i]} has failed a maximum of {mock_executor.MAX_SUBMIT_JOB_ATTEMPTS} times. Marking as failed"
in caplog.text
)

@mock.patch("airflow.providers.amazon.aws.executors.batch.batch_executor.exponential_backoff_retry")
def test_sync_unhealthy_boto_connection(self, mock_exponentional_backoff_retry, mock_executor):
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -554,7 +554,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
operator.hook.TERMINAL_STATES = [BatchState.SUCCESS]
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.spark_params["conf"] == {}


Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -467,7 +467,10 @@ def test_inject_openlineage_simple_config_wrong_transport_to_spark(
)
operator.execute(MagicMock())

assert "OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
assert (
"OpenLineage transport type `console` does not support automatic injection of OpenLineage transport information into Spark properties."
in caplog.text
)
assert operator.conf == {
"parquet.compression": "SNAPPY",
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -2545,6 +2545,7 @@ def test_async_get_logs_should_execute_successfully(
@patch(KUB_OP_PATH.format("extract_xcom"))
@patch(HOOK_CLASS)
@patch(KUB_OP_PATH.format("pod_manager"))
@pytest.mark.xfail
def test_async_write_logs_should_execute_successfully(
self, mock_manager, mocked_hook, mock_extract_xcom, post_complete_action, get_logs
):
Expand All@@ -2565,8 +2566,12 @@ def test_async_write_logs_should_execute_successfully(
self.run_pod_async(k)

if get_logs:
assert f"Container logs: {test_logs}"
# Note: the test below is broken and failing. Either the mock is wrong
# or the mocked container is not in a state that logging methods are called at-all.
# See https://github.com/apache/airflow/issues/57515
assert f"Container logs: {test_logs}" # noqa: PLW0129
post_complete_action.assert_called_once()
mock_manager.return_value.read_pod_logs.assert_called()
else:
mock_manager.return_value.read_pod_logs.assert_not_called()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,14 +156,14 @@ async def test_run_loop_return_waiting_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand All@@ -175,14 +175,14 @@ async def test_run_loop_return_running_event(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.AsyncMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -250,7 +250,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,5 +153,8 @@ async def test_run_loop_is_still_running(self, mock_hook, trigger, caplog):
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {TransferState.RUNNING}"
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert (
f"Current state is {TransferState.RUNNING}" in caplog.text
or "Current state is TransferState.RUNNING" in caplog.text
)
assert f"Waiting for {POLL_INTERVAL} seconds" in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -229,8 +229,8 @@ async def test_run_loop_is_still_running(self, mock_job_status, template_job_sta
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current job status is: {JobState.JOB_STATE_RUNNING}"
assert f"Sleeping for {POLL_SLEEP} seconds."
assert "Current job status is: JOB_STATE_RUNNING" in caplog.text
assert f"Sleeping for {POLL_SLEEP} seconds." in caplog.text
# cancel the task to suppress test warnings
task.cancel()

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,4 +132,4 @@ async def test_async_dataplex_job_run_loop_is_still_running(
await asyncio.sleep(0.5)

assert not task.done()
assert f"Current state is: {DataScanJob.State.RUNNING}, sleeping for {TEST_POLL_INTERVAL} seconds."
assert f"Current state is: RUNNING, sleeping for {TEST_POLL_INTERVAL} seconds." in caplog.text
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,14 +200,14 @@ async def test_run_loop_return_waiting_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.WAITING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand All@@ -219,14 +219,14 @@ async def test_run_loop_return_running_event_should_execute_successfully(
mock_hook.get_pod.return_value = self._mock_pod_result(mock.MagicMock())
mock_method.return_value = ContainerState.RUNNING

caplog.set_level(logging.INFO)
caplog.set_level(logging.DEBUG)

task = asyncio.create_task(trigger.run().__anext__())
await asyncio.sleep(0.5)

assert not task.done()
assert "Container is not completed and still working."
assert f"Sleeping for {POLL_INTERVAL} seconds."
assert "Container is not completed and still working." in caplog.text
assert f"Sleeping for {POLL_INTERVAL} seconds." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_KUB_POD_PATH}._wait_for_pod_start")
Expand DownExpand Up@@ -265,7 +265,7 @@ async def test_logging_in_trigger_when_fail_should_execute_successfully(

generator = trigger.run()
await generator.asend(None)
assert "Container logs:"
assert "Waiting until 120s to get the POD scheduled..." in caplog.text

@pytest.mark.parametrize(
"container_state, expected_state",
Expand DownExpand Up@@ -447,8 +447,8 @@ async def test_run_loop_return_waiting_event_pending_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text

@pytest.mark.asyncio
@mock.patch(f"{TRIGGER_PATH}._get_hook")
Expand All@@ -470,8 +470,8 @@ async def test_run_loop_return_waiting_event_running_status(
await asyncio.sleep(0.5)

assert not task.done()
assert "Operation is still running."
assert f"Sleeping for {POLL_INTERVAL}s..."
assert "Operation is still running." in caplog.text
assert f"Sleeping for {POLL_INTERVAL}s..." in caplog.text


class TestGKEStartJobTrigger:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -591,8 +591,11 @@ extend-select = [
"E", # pycodestyle rules
"W", # pycodestyle rules
# Warning (PLW) re-implemented in ruff from Pylint
"PLW0127", # Self-assignment of variable
"PLW0120", # else clause on loop without a break statement; remove the else and dedent its contents
"PLW0127", # Self-assignment of variable
"PLW0128", # Redeclared variable {name} in assignment
"PLW0129", # Asserting on an empty string literal will never pass
"PLW0133", # Missing raise statement on exception
# Per rule enables
"RUF006", # Checks for asyncio dangling task
"RUF015", # Checks for unnecessary iterable allocation for first element
Expand DownExpand Up@@ -625,7 +628,6 @@ extend-select = [
"RET506", # Unnecessary {branch} after raise statement
"RET507", # Unnecessary {branch} after continue statement
"RET508", # Unnecessary {branch} after break statement
"PLW0133", # Missing raise statement on exception
]
ignore = [
"D100", # Unwanted; Docstring at the top of every file.
Expand Down
Loading