Skip to content

Commit

Permalink
Test for DNS resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben committed Oct 17, 2024
1 parent e147e4c commit 5c4509f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 15 deletions.
45 changes: 30 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
name: CI
name: Checks

on:
pull_request:
push:
branches-ignore:
- "github-pages/*"
- "gh-pages/*"
- "main"
- "master"
schedule:
# “At 00:00 on every 7th day-of-month from 1 through 31.” (https://crontab.guru)
- cron: "0 0 1/7 * *"

jobs:
tests-job:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false

ci-job:
name: Checks
uses: ./.github/workflows/checks.yml
steps:
- name: SCM Checkout
uses: actions/checkout@v4
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false

metrics:
needs: [ ci-job ]
uses: ./.github/workflows/report.yml
- name: Free disk space by removing large directories
run: |
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /opt/ghc
- name: Setup Python & Poetry Environment
uses: exasol/python-toolbox/.github/actions/[email protected]
with:
python-version: '3.10'

- name: Calculate Test Coverage
run: poetry run pytest test/test_itde_manager_in_docker_container.py
46 changes: 46 additions & 0 deletions test/integration/test_itde_manager_in_docker_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,52 @@ def run_test():
return source_code


@pytest.fixture
def itde_connect_test_impl_dns():
"""
This fixture returns the test source code for starting up ITDE,connecting to it and let the DB execute a UDF which requires proper internet access.
The source code needs to appended to the wheel file inside the Docker container called TEST_CONTAINER.
"""

def run_test():
from pathlib import Path

from exasol.nb_connector.ai_lab_config import AILabConfig
from exasol.nb_connector.connections import open_pyexasol_connection
from exasol.nb_connector.itde_manager import bring_itde_up
from exasol.nb_connector.itde_manager import take_itde_down
from exasol.nb_connector.secret_store import Secrets
import requests

requests.get("https://example.com/")
secrets = Secrets(db_file=Path("secrets.sqlcipher"), master_password="test")
secrets.save(AILabConfig.mem_size.value, "2")
secrets.save(AILabConfig.disk_size.value, "4")

bring_itde_up(secrets)
try:
con = open_pyexasol_connection(secrets)
try:
udf = textwrap.dedent('''
CREATE OR REPLACE PYTHON SCALAR SCRIPT test_dns(dummy INTEGER)
RETURNS INTEGER AS
def run(ctx):
import requests
requests.get("https://example.com/")
return 1
''')
result = con.execute(udf).fetchmany()
assert result[0][0] == 1
finally:
con.close()
finally:
take_itde_down(secrets)

function_source_code = textwrap.dedent(dill.source.getsource(run_test))
source_code = f"{function_source_code}\nrun_test()"
return source_code


@pytest.fixture
def itde_recreation_after_take_down():
"""
Expand Down

0 comments on commit 5c4509f

Please sign in to comment.