Eng 567 record integration version on exec logs#7650
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Updating test for endpoints
Greptile SummaryThis PR records the SaaS integration config version ( Key changes:
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 5ae13c1 |
src/fides/api/alembic/migrations/versions/a1ca9ddf3c3c_add_saas_version_to_executionlog.py
Show resolved
Hide resolved
| def test_execution_log_saas_version_stored(db, execution_log_data): | ||
| execution_log_data["saas_version"] = "2.3.0" | ||
| execution_log = ExecutionLog.create(db, data=execution_log_data) | ||
|
|
||
| retrieved = db.query(ExecutionLog).filter_by(privacy_request_id="test_id").first() | ||
| assert retrieved is not None | ||
| assert retrieved.saas_version == "2.3.0" | ||
| execution_log.delete(db) |
There was a problem hiding this comment.
Manual record deletion in test — not needed
Both new tests call execution_log.delete(db) at the end. The database is automatically cleared between test runs, so this manual cleanup is unnecessary and goes against the testing conventions for this project. The cleanup should be removed from both new tests.
| def test_execution_log_saas_version_stored(db, execution_log_data): | |
| execution_log_data["saas_version"] = "2.3.0" | |
| execution_log = ExecutionLog.create(db, data=execution_log_data) | |
| retrieved = db.query(ExecutionLog).filter_by(privacy_request_id="test_id").first() | |
| assert retrieved is not None | |
| assert retrieved.saas_version == "2.3.0" | |
| execution_log.delete(db) | |
| def test_execution_log_saas_version_stored(db, execution_log_data): | |
| execution_log_data["saas_version"] = "2.3.0" | |
| ExecutionLog.create(db, data=execution_log_data) | |
| retrieved = db.query(ExecutionLog).filter_by(privacy_request_id="test_id").first() | |
| assert retrieved is not None | |
| assert retrieved.saas_version == "2.3.0" |
The same applies to test_execution_log_saas_version_null_for_non_saas at line 122.
Rule Used: Do not manually delete database records in test fi... (source)
Learnt From
ethyca/fides#6688
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| assert execution_log.status == ExecutionLogStatus.complete | ||
|
|
||
| def test_saas_version_null_for_non_saas_connector( | ||
| self, graph_task, db, privacy_request | ||
| ): | ||
| """Non-SaaS connectors (postgres in this fixture) should produce null saas_version.""" | ||
| graph_task.log_start(action_type=ActionType.access) | ||
|
|
||
| execution_log = ( | ||
| db.query(ExecutionLog) | ||
| .filter( | ||
| ExecutionLog.privacy_request_id == privacy_request.id, | ||
| ExecutionLog.collection_name == "b", | ||
| ExecutionLog.dataset_name == "a", | ||
| ) | ||
| .first() | ||
| ) | ||
| assert execution_log is not None | ||
| assert execution_log.saas_version is None | ||
|
|
||
| def test_saas_version_populated_for_saas_connector( | ||
| self, saas_graph_task, saas_example_connection_config, privacy_request, db | ||
| ): |
There was a problem hiding this comment.
Accessing private instance attribute in test
saas_graph_task._saas_version directly accesses a private implementation detail of GraphTask. This assertion is mostly redundant given that the test already verifies the saas_version is correctly propagated to the execution log record (the real observable behavior). The assertion on the private field is fragile — if the internal attribute is renamed or restructured it breaks without any functional regression.
Consider removing this assertion and relying solely on the execution log verification that follows, or exposing a public property if the attribute needs to be observable from outside the class.
| assert execution_log.status == ExecutionLogStatus.complete | |
| def test_saas_version_null_for_non_saas_connector( | |
| self, graph_task, db, privacy_request | |
| ): | |
| """Non-SaaS connectors (postgres in this fixture) should produce null saas_version.""" | |
| graph_task.log_start(action_type=ActionType.access) | |
| execution_log = ( | |
| db.query(ExecutionLog) | |
| .filter( | |
| ExecutionLog.privacy_request_id == privacy_request.id, | |
| ExecutionLog.collection_name == "b", | |
| ExecutionLog.dataset_name == "a", | |
| ) | |
| .first() | |
| ) | |
| assert execution_log is not None | |
| assert execution_log.saas_version is None | |
| def test_saas_version_populated_for_saas_connector( | |
| self, saas_graph_task, saas_example_connection_config, privacy_request, db | |
| ): | |
| def test_saas_version_populated_for_saas_connector( | |
| self, saas_graph_task, saas_example_connection_config, privacy_request, db | |
| ): | |
| """SaaS connectors should stamp saas_version on every execution log entry.""" | |
| expected_version = saas_example_connection_config.saas_config["version"] | |
| saas_graph_task.log_start(action_type=ActionType.access) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
- Use conditional logger.info calls instead of mixing f-strings with loguru placeholders in log_start/log_retry - Add comment explaining _saas_version is snapshotted at construction time - Fix missing blank line between test functions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
johnewart
left a comment
There was a problem hiding this comment.
The backend stuff looks good - the frontend bits seem sane but I will let someone else confirm that 👍🏼
Ticket 567
Description Of Changes
Adding the integration version to the execution logs.
This would help during testing and monitoring to verify what version of the integration an instance is running
Code Changes
Steps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works