werbolis commented on a change in pull request #10682: URL: https://github.com/apache/airflow/pull/10682#discussion_r510405602
########## File path: tests/bats/test_in_container_utils.bats ########## @@ -0,0 +1,45 @@ +#!/usr/bin/env bats + +# 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. +setup() { + load bats_utils + source "${AIRFLOW_SOURCES}/scripts/in_container/_in_container_utils.sh" +} + +@test "test success exit" { + container_utils::in_container_script_end 1 + assert_success +} + +@test "test heartbeat start and stop" { + container_utils::start_output_heartbeat "Creating kubernetes cluster" 1 + container_utils::stop_output_heartbeat + assert [ -z "$(ps -p $HEARTBEAT_PID -o pid=)" ] && [ -n "$HEARTBEAT_PID" ] +} + +#TODO(werbolis) These (new) tests fail in `breeze static-check bats-tests` run. Investigate & fix. +# @test "test not in_container" { +# run container_utils::assert_in_container +# assert [ $status -eq 1 ] +# } +# +# @test "test install_airflow" { +# container_utils::install_released_airflow_version "1.10.2" +# airflow_version=$(airflow version) +# assert [ airflow_version=="1.10.2" ] +# } Review comment: @OmairK did you aim to run these tests in the local dev env? The pre-commit hook uses `breeze static-check bats-tests`, which runs them inside in a container, so I'm pretty sure we can't have a "not in container" test here. `test install_airflow` - the installation takes ages... Failure to install airflow should be easy to detect when building CI image. Perhaps we could stay safe and quick by stubbing pip and checking if it gets called with proper args? (e.g. https://github.com/jasonkarns/bats-mock) I like the idea of testing these scripts, we definitely should have more tests! This PR is already somewhat bloated - if you're OK with that, I'd rather stick to two first tests in this file and add more in a separate PR. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
