amoghrajesh commented on PR #39003:
URL: https://github.com/apache/airflow/pull/39003#issuecomment-2081869832
@ashb @potiuk @eladkal Need some help with fixing the unit tests here on
this change also want to ask what kind of testing needs to be performed here to
mark this task complete.
So I am trying to write a UT here which calls KPO init and then checks the
DB for the `RenderedTaskInstanceFields` table and validates the redaction.
Didn't get too far with it, so far I have this:
```
@provide_session
@pytest.mark.parametrize(
"input",
[
[
V1EnvVar(
name="password",
value="mypassword",
),
V1EnvVar(
name="normal",
value="normalstuff",
),
V1EnvVar(
name="secret",
value="ok",
),
V1EnvVar(
name="thisisok",
value="password",
),
],
{
"password": "password1",
"good": "thisisgood",
"secret": "normal_stuff",
"normal": "secret"
}
],
)
def test_env_vars_redaction(self, dag_maker, input, session=None):
from airflow.models.renderedtifields import
RenderedTaskInstanceFields
# k = KubernetesPodOperator(
# task_id="task-1",
# env_vars=input,
# )
#
# ctx = create_context(k, persist_to_db=True)
#
# pod = k.build_pod_request_obj(ctx)
# session = Session()
# all_rows = session.query(RenderedTaskInstanceFields).all()
#
# print(all_rows)
with dag_maker("test-dag", session=session) as dag:
task = KubernetesPodOperator(
task_id="task-1",
env_vars=input,
)
ti = dag_maker.create_dagrun().task_instances[0]
ti.task = task
session.add(RenderedTaskInstanceFields(ti))
session.flush()
y = ti.get_rendered_template_fields(session=session)
print(y)
```
Basically i want to validate this:
```
{"cmds": [], "image": "hello-world", "labels": {}, "volumes": [],
"env_from": [], "env_vars": [{"name": "password", "value": "***", "value_from":
null}, {"name": "normal", "value": "normalstuff", "value_from": null}, {"name":
"secret", "value": "***", "value_from": null}, {"name": "thisisok", "value":
"password", "value_from": null}], "arguments": [], "namespace": "default",
"annotations": {}, "config_file": "~/Downloads/ECS\\
Kubeconfigs/shared-rke-01", "volume_mounts": [], "cluster_context": null,
"pod_template_dict": null, "pod_template_file": null, "container_resources":
null}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]