Skip to content

chore: fixed formatting to make linter happy #31

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

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Publish

on:
Expand All @@ -12,21 +13,20 @@ jobs:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install publish dependencies
run: |
python -m pip install --upgrade pip
pip install '.[publish]'
- name: Build and test wheel
run: |
rm -rf dist/
python -m build --sdist --wheel .
twine check dist/*
- name: Publish
run: |
twine upload --non-interactive --verbose --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} dist/*

- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install publish dependencies
run: |
python -m pip install --upgrade pip
pip install '.[publish]'
- name: Build and test wheel
run: |
rm -rf dist/
python -m build --sdist --wheel .
twine check dist/*
- name: Publish
run: |
twine upload --non-interactive --verbose --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} dist/*
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ src/beku_stackabletech.egg-info
examples/suites/tests/_work
# pixi environments
.pixi

10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ All notable changes to this project will be documented in this file.

- Replace os fs separator ("/") in test case names with underscore ("_") ([#8])

[#7]: https://github.com/stackabletech/beku.py/pull/7)
[#8]: https://github.com/stackabletech/beku.py/pull/8)
[#7]: https://github.com/stackabletech/beku.py/pull/7
[#8]: https://github.com/stackabletech/beku.py/pull/8

## [0.0.8] - 2023-07-01

- Bugfix: apply multiple patches sequentially to a single test
- Bugfix: apply multiple patches sequentially to a single test ([#6])

[#6]: https://github.com/stackabletech/beku.py/pull/6)
[#6]: https://github.com/stackabletech/beku.py/pull/6

## [0.0.7] - 2023-06-26

- Add support for Kuttl test suites and improve CI ([#4])

[#4]: https://github.com/stackabletech/beku.py/pull/4)
[#4]: https://github.com/stackabletech/beku.py/pull/4

## [0.0.6] - 2023-06-21

Expand Down
4 changes: 1 addition & 3 deletions beku.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ python3, runCommand, lib }:
let
# I wish there was a better way. If the command fails, it is very hard to see
# I wish there was a better way. If the command fails, it is very hard to see
# that the problem is here. Perhaps there is some way to evaluate it in python
# and reference __version__ directly?
version = builtins.readFile (runCommand "foo" { src = [ ./src ]; } ''
Expand Down Expand Up @@ -31,5 +31,3 @@ python3.pkgs.buildPythonApplication {
pyyaml
];
}


11 changes: 4 additions & 7 deletions examples/suites/tests/templates/kuttl/commons/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import time

if __name__ == "__main__":
log_level = 'DEBUG'
logging.basicConfig(
level=log_level, format='%(asctime)s %(levelname)s: %(message)s', stream=sys.stdout)
log_level = "DEBUG"
logging.basicConfig(level=log_level, format="%(asctime)s %(levelname)s: %(message)s", stream=sys.stdout)

url = "http://airflow-webserver-default:8080/api/v1/health"
count = 0
Expand All @@ -20,17 +19,15 @@
if code == 200:
break
else:
print(
f"Got non 200 status code [{code}], retrying attempt no [{count}] ....")
print(f"Got non 200 status code [{code}], retrying attempt no [{count}] ....")
except requests.exceptions.Timeout:
print(f"Connection timed out, retrying attempt no [{count}] ....")
except requests.ConnectionError as e:
print(f"Connection Error: {str(e)}")
except requests.RequestException as e:
print(f"General Error: {str(e)}")
except Exception as e:
print(
f"General error occurred {str(e)}, retrying attempt no [{count}] ....")
print(f"General error occurred {str(e)}, retrying attempt no [{count}] ....")

# Wait a little bit before retrying
time.sleep(1)
Expand Down
28 changes: 12 additions & 16 deletions examples/suites/tests/templates/kuttl/commons/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,29 @@ def exception_handler(exception_type, exception, traceback):


def assert_metric(role, metric):
response = requests.get(f'http://airflow-{role}-default:9102/metrics')
assert response.status_code == 200, \
f"Metrics could not be retrieved from the {role}."
assert metric in response.text, \
f"The {role} metrics do not contain the metric {metric}."
response = requests.get(f"http://airflow-{role}-default:9102/metrics")
assert response.status_code == 200, f"Metrics could not be retrieved from the {role}."
assert metric in response.text, f"The {role} metrics do not contain the metric {metric}."


# Trigger a DAG run to create metrics
dag_id = 'example_trigger_target_dag'
dag_conf = {'message': "Hello World"}
dag_id = "example_trigger_target_dag"
dag_conf = {"message": "Hello World"}

rest_url = 'http://airflow-webserver-default:8080/api/v1'
auth = ('airflow', 'airflow')
rest_url = "http://airflow-webserver-default:8080/api/v1"
auth = ("airflow", "airflow")

# allow a few moments for the DAGs to be registered to all roles
time.sleep(10)

response = requests.patch(
f'{rest_url}/dags/{dag_id}', auth=auth, json={'is_paused': False})
response = requests.post(
f'{rest_url}/dags/{dag_id}/dagRuns', auth=auth, json={'conf': dag_conf})
response = requests.patch(f"{rest_url}/dags/{dag_id}", auth=auth, json={"is_paused": False})
response = requests.post(f"{rest_url}/dags/{dag_id}/dagRuns", auth=auth, json={"conf": dag_conf})

assert response.status_code == 200, "DAG run could not be triggered."

# Wait for the metrics to be consumed by the statsd-exporter
time.sleep(4)

assert_metric('scheduler', 'airflow_scheduler_heartbeat')
assert_metric('webserver', 'airflow_task_instance_created_BashOperator')
assert_metric('worker', 'airflow_ti_successes')
assert_metric("scheduler", "airflow_scheduler_heartbeat")
assert_metric("webserver", "airflow_task_instance_created_BashOperator")
assert_metric("worker", "airflow_ti_successes")
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

def check_processed_events():
response = requests.post(
'http://airflow-vector-aggregator:8686/graphql',
"http://airflow-vector-aggregator:8686/graphql",
json={
'query': """
"query": """
{
transforms(first:100) {
nodes {
Expand All @@ -20,22 +20,20 @@ def check_processed_events():
}
}
"""
}
},
)

assert response.status_code == 200, \
'Cannot access the API of the vector aggregator.'
assert response.status_code == 200, "Cannot access the API of the vector aggregator."

result = response.json()

transforms = result['data']['transforms']['nodes']
transforms = result["data"]["transforms"]["nodes"]
for transform in transforms:
processedEvents = transform['metrics']['processedEventsTotal']['processedEventsTotal']
componentId = transform['componentId']
assert processedEvents > 0, \
f'No events were processed in "{componentId}".'
processedEvents = transform["metrics"]["processedEventsTotal"]["processedEventsTotal"]
componentId = transform["componentId"]
assert processedEvents > 0, f'No events were processed in "{componentId}".'


if __name__ == '__main__':
if __name__ == "__main__":
check_processed_events()
print('Test successful!')
print("Test successful!")
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""Example DAG returning the current date"""

from datetime import datetime, timedelta

from airflow import DAG
from airflow.operators.bash import BashOperator


with DAG(
dag_id='date_demo',
schedule_interval='0-59 * * * *',
dag_id="date_demo",
schedule_interval="0-59 * * * *",
start_date=datetime(2021, 1, 1),
catchup=False,
dagrun_timeout=timedelta(minutes=5),
tags=['example'],
tags=["example"],
params={},
) as dag:

run_this = BashOperator(
task_id='run_every_minute',
bash_command='date',
task_id="run_every_minute",
bash_command="date",
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,27 @@ def exception_handler(exception_type, exception, traceback):


def assert_metric(role, metric):
response = requests.get(f'http://airflow-{role}-default:9102/metrics')
assert response.status_code == 200, \
f"Metrics could not be retrieved from the {role}."
assert metric in response.text, \
f"The {role} metrics do not contain the metric {metric}."
response = requests.get(f"http://airflow-{role}-default:9102/metrics")
assert response.status_code == 200, f"Metrics could not be retrieved from the {role}."
assert metric in response.text, f"The {role} metrics do not contain the metric {metric}."


# Trigger a DAG run to create metrics
dag_id = 'date_demo'
dag_id = "date_demo"

rest_url = 'http://airflow-webserver-default:8080/api/v1'
auth = ('airflow', 'airflow')
rest_url = "http://airflow-webserver-default:8080/api/v1"
auth = ("airflow", "airflow")

# allow a few moments for the DAGs to be registered to all roles
time.sleep(10)

response = requests.patch(
f'{rest_url}/dags/{dag_id}', auth=auth, json={'is_paused': False})
response = requests.post(
f'{rest_url}/dags/{dag_id}/dagRuns', auth=auth, json={})
response = requests.patch(f"{rest_url}/dags/{dag_id}", auth=auth, json={"is_paused": False})
response = requests.post(f"{rest_url}/dags/{dag_id}/dagRuns", auth=auth, json={})

assert response.status_code == 200, "DAG run could not be triggered."

# Wait for the metrics to be consumed by the statsd-exporter
time.sleep(4)

assert_metric('scheduler', 'airflow_scheduler_heartbeat')
assert_metric('worker', 'airflow_ti_successes')
assert_metric("scheduler", "airflow_scheduler_heartbeat")
assert_metric("worker", "airflow_ti_successes")
1 change: 1 addition & 0 deletions src/beku/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Package entry point."""

import sys
from .main import main

Expand Down
Loading