potiuk commented on a change in pull request #19737: URL: https://github.com/apache/airflow/pull/19737#discussion_r754412824
########## File path: docker_tests/prod_image.py ########## @@ -0,0 +1,202 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import json +import subprocess +import tempfile +from pathlib import Path + +import pytest + +from docker_tests.docker_tests_utils import ( + SOURCE_ROOT, + display_dependency_conflict_message, + docker_image, + run_bash, + run_command, + run_python, +) + + +class TestCommands: + def test_without_command(self): + """Checking the image without a command. It should return non-zero exit code.""" + with pytest.raises(subprocess.CalledProcessError) as ctx: + run_command(["docker", "run", "--rm", "-e", "COLUMNS=180", docker_image]) + assert 2 == ctx.value.returncode + + def test_airflow_command(self): + """Checking 'airflow' command It should return non-zero exit code.""" + with pytest.raises(subprocess.CalledProcessError) as ctx: + run_command(["docker", "run", "--rm", "-e", "COLUMNS=180", docker_image, "airflow"]) + assert 2 == ctx.value.returncode + + def test_airflow_version(self): + """Checking 'airflow version' command It should return zero exit code.""" + output = run_command( + ["docker", "run", "--rm", "-e", "COLUMNS=180", docker_image, "airflow", "version"] + ) + assert "2." in output + + def test_python_version(self): + """Checking 'python --version' command It should return zero exit code.""" + output = run_command( + ["docker", "run", "--rm", "-e", "COLUMNS=180", docker_image, "python", "--version"] + ) + assert "Python 3." in output + + def test_bash_version(self): + """Checking 'bash --version' command It should return zero exit code.""" + output = run_command( + ["docker", "run", "--rm", "-e", "COLUMNS=180", docker_image, "bash", "--version"] + ) + assert "GNU bash," in output + + +class TestPythonPackages: + def test_required_providers_are_installed(self): + lines = ( + d.strip() + for d in (SOURCE_ROOT / "scripts" / "ci" / "installed_providers.txt").read_text().splitlines() + ) + lines = (d for d in lines) + packages_to_install = {f"apache-airflow-providers-{d.replace('.', '-')}" for d in lines} + assert len(packages_to_install) != 0 + + output = run_bash("airflow providers list --output json", stderr=subprocess.DEVNULL) + providers = json.loads(output) + packages_installed = {d['package_name'] for d in providers} + assert len(packages_installed) != 0 + + assert packages_to_install == packages_installed Review comment: Just to explain "why" - we have quite a number of tests that are showing "diff" but without extra comment what to do with the diff, especially new users find it confusing what to do with the information. I think in all such cases where we just expect listst to match we should explain with a short comment how to reconcile the lists. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
