-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAT: verify AIRBYTE_ENTRYPOINT
is defined
#4478
Merged
vovavovavovavova
merged 26 commits into
master
from
valdemar/#4262_assert_airbyte_entrypoint_env_defined
Jul 7, 2021
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
69aa7a6
save changes required for work; TODO locate all places that need to b…
vovavovavovavova fd4db49
Merge remote-tracking branch 'origin/master' into valdemar/#4262_asse…
vovavovavovavova 1da955d
move new test inside test_spec
vovavovavovavova 075a044
apply suggestions
vovavovavovavova 9b66d50
change return type + add check env = space_joined_entrypoint
vovavovavovavova ad4274a
requested
vovavovavovavova 472ad1a
add check entrypoint with env
vovavovavovavova b62ae92
bump SAT --version && changelog update
vovavovavovavova 62f84d5
Merge remote-tracking branch 'origin/master' into valdemar/#4262_asse…
vovavovavovavova a2ba9b6
merge && fix changelog
vovavovavovavova b143ad5
changes
vovavovavovavova b74e6ff
add dynamic docker runner creator + test having properties
vovavovavovavova 076d31e
update the names
vovavovavovavova d5da978
change names
vovavovavovavova 28505cc
make fixtures
vovavovavovavova 7ab4c81
Merge remote-tracking branch 'origin/master' into valdemar/#4262_asse…
vovavovavovavova 214209b
upd text
vovavovavovavova d4b6d4f
Update airbyte-integrations/bases/source-acceptance-test/unit_tests/t…
vovavovavovavova 770b508
requested changes
vovavovavovavova 6f52aed
Update airbyte-integrations/bases/source-acceptance-test/unit_tests/t…
vovavovavovavova b9991f1
Update airbyte-integrations/bases/source-acceptance-test/unit_tests/t…
vovavovavovavova 387493c
apply requested changes
vovavovavovavova 36f76f9
change names (requested)
vovavovavovavova c6e2bd4
move binary strings to standard with convertation in builder
vovavovavovavova 045c749
fixing merge-conflict side effect
vovavovavovavova 64a811b
resolve new conflict (both)
vovavovavovavova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
airbyte-integrations/bases/source-acceptance-test/unit_tests/test_spec_unit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# | ||
# MIT License | ||
# | ||
# Copyright (c) 2020 Airbyte | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
|
||
import io | ||
|
||
import docker | ||
import pytest | ||
from source_acceptance_test.utils import ConnectorRunner | ||
|
||
|
||
def build_docker_image(text: str, tag: str) -> docker.models.images.Image: | ||
""" | ||
Really for this test we dont need to remove the image since we access it by a string name | ||
and remove it also by a string name. But maybe we wanna use it somewhere | ||
""" | ||
client = docker.from_env() | ||
fileobj = io.BytesIO(bytes(text, "utf-8")) | ||
image, iterools_tee = client.images.build(fileobj=fileobj, tag=tag, forcerm=True, rm=True) | ||
return image | ||
|
||
|
||
@pytest.fixture | ||
def correct_connector_image() -> str: | ||
dockerfile_text = """ | ||
FROM scratch | ||
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" | ||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] | ||
""" | ||
tag = "my-valid-one" | ||
build_docker_image(dockerfile_text, tag) | ||
yield tag | ||
client = docker.from_env() | ||
client.images.remove(image=tag, force=True) | ||
|
||
|
||
@pytest.fixture | ||
def connector_image_without_env(): | ||
dockerfile_text = """ | ||
FROM scratch | ||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] | ||
""" | ||
tag = "my-no-env" | ||
build_docker_image(dockerfile_text, tag) | ||
yield tag | ||
client = docker.from_env() | ||
client.images.remove(image=tag, force=True) | ||
|
||
|
||
@pytest.fixture | ||
def connector_image_with_ne_properties(): | ||
dockerfile_text = """ | ||
FROM scratch | ||
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" | ||
ENTRYPOINT ["python3", "/airbyte/integration_code/main.py"] | ||
""" | ||
tag = "my-ne-properties" | ||
build_docker_image(dockerfile_text, tag) | ||
yield tag | ||
client = docker.from_env() | ||
client.images.remove(image=tag, force=True) | ||
|
||
|
||
class TestEnvAttributes: | ||
def test_correct_connector_image(self, correct_connector_image, tmp_path): | ||
docker_runner = ConnectorRunner(image_name=correct_connector_image, volume=tmp_path) | ||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT"), "AIRBYTE_ENTRYPOINT must be set in dockerfile" | ||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT") == " ".join( | ||
docker_runner.entry_point | ||
), "env should be equal to space-joined entrypoint" | ||
|
||
def test_connector_image_without_env(self, connector_image_without_env, tmp_path): | ||
docker_runner = ConnectorRunner(image_name=connector_image_without_env, volume=tmp_path) | ||
assert not docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT"), "this test should fail if AIRBYTE_ENTRYPOINT defined" | ||
|
||
def test_docker_image_env_ne_entrypoint(self, connector_image_with_ne_properties, tmp_path): | ||
docker_runner = ConnectorRunner(image_name=connector_image_with_ne_properties, volume=tmp_path) | ||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT"), "AIRBYTE_ENTRYPOINT must be set in dockerfile" | ||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT") != " ".join(docker_runner.entry_point), ( | ||
"This test should fail if we have " ".join(ENTRYPOINT)==ENV" | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪🏼