-
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
Changes from 13 commits
69aa7a6
fd4db49
1da955d
075a044
9b66d50
ad4274a
472ad1a
b62ae92
62f84d5
a2ba9b6
b143ad5
b74e6ff
076d31e
d5da978
28505cc
7ab4c81
214209b
d4b6d4f
770b508
6f52aed
b9991f1
387493c
36f76f9
c6e2bd4
045c749
64a811b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# Changelog | ||
|
||
## 0.1.5 | ||
## 0.1.7 | ||
Add: `test_spec` additionally checks if Dockerfile has `ENV AIRBYTE_ENTRYPOINT` defined | ||
and equal to space_joined `ENTRYPOINT` | ||
|
||
## 0.1.6 | ||
Add test whether PKs present and not None if `source_defined_primary_key` defined: https://github.com/airbytehq/airbyte/pull/4140 | ||
|
||
## 0.1.5 | ||
Add configurable timeout for the acceptance tests: https://github.com/airbytehq/airbyte/pull/4296 | ||
Add configurable timeout for the acceptance tests: https://github.com/airbytehq/airbyte/pull/4296 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,11 @@ def test_spec(self, connector_spec: ConnectorSpecification, docker_runner: Conne | |
if connector_spec: | ||
assert spec_messages[0].spec == connector_spec, "Spec should be equal to the one in spec.json file" | ||
|
||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT"), "AIRBYTE_ENTRYPOINT must be set in dockerfile" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💪🏼 |
||
assert docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT") == " ".join( | ||
docker_runner.entry_point | ||
), "env should be equal to space-joined entrypoint" | ||
|
||
|
||
@pytest.mark.default_timeout(30) | ||
class TestConnection(BaseTest): | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,86 @@ | ||||||
# | ||||||
# 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 os | ||||||
from pathlib import Path | ||||||
|
||||||
import docker | ||||||
from source_acceptance_test.utils import ConnectorRunner | ||||||
|
||||||
|
||||||
class TestEnvAttributes: | ||||||
def create_dockerfile(self, text, tag): | ||||||
# nano ~/.docker/config.json credsStore-> credStore to enable on MAC | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this? |
||||||
client = docker.from_env() | ||||||
fileobj = io.BytesIO() | ||||||
fileobj.write(text) | ||||||
|
||||||
fileobj.seek(0) | ||||||
args = { | ||||||
"path": os.path.abspath("."), | ||||||
"fileobj": fileobj, | ||||||
"tag": tag, | ||||||
"forcerm": True, | ||||||
"rm": True, | ||||||
} | ||||||
image, iterools_tee = client.images.build(**args) | ||||||
docker_runner = ConnectorRunner(image_name=tag, volume=Path(".")) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use tmp fixture instead of Path |
||||||
return docker_runner | ||||||
|
||||||
def test_build_dockerfile_valid(self): | ||||||
valid_text = b""" | ||||||
FROM python:3.7-slim | ||||||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||||||
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" | ||||||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] | ||||||
""" | ||||||
docker_runner = self.create_dockerfile(valid_text, 'my-valid-one') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets move this to fixture, so we will have 3 different fixtures, |
||||||
|
||||||
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_build_dockerfile_no_env(self): | ||||||
no_env_text = b""" | ||||||
FROM python:3.7-slim | ||||||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||||||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] | ||||||
""" | ||||||
docker_runner = self.create_dockerfile(no_env_text, 'my-no-env-one') | ||||||
assert not docker_runner.env_variables.get("AIRBYTE_ENTRYPOINT"), "this test should fail if AIRBYTE_ENTRYPOINT defined" | ||||||
|
||||||
def test_build_dockerfile_ne_properties(self): | ||||||
ne_env_entrypoint_text = b""" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need unique name for this variable everytime |
||||||
FROM python:3.7-slim | ||||||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||||||
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" | ||||||
ENTRYPOINT ["python3", "/airbyte/integration_code/main.py"] | ||||||
""" | ||||||
docker_runner = self.create_dockerfile(ne_env_entrypoint_text, 'ne__one') | ||||||
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 " ".join(ENTRYPOINT)==ENV" | ||||||
) |
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.
can you correct these version headers?