Skip to content
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

Issue/6549 add missing migration script #6596

Closed
wants to merge 15 commits into from

Conversation

Hugo-Inmanta
Copy link
Contributor

Description

Previous PR was missing a migration script

closes #6549

Self Check:

Strike through any lines that are not applicable (~~line~~) then check the box

  • Attached issue to pull request
  • Changelog entry
  • Type annotations are present
  • Code is clear and sufficiently documented
  • No (preventable) type errors (check using make mypy or make mypy-diff)
  • Sufficient test cases (reproduces the bug/tests the requested feature)
  • Correct, in line with design
  • End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
  • If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see test-fixes for more info)

async def test_type_change(
migrate_db_from: abc.Callable[[], abc.Awaitable[None]], get_tables_in_db: abc.Callable[[], abc.Awaitable[list[str]]]
) -> None:
await migrate_db_from()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have liked to assert that the type is int before the migration but I didn't manage to

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect you just need to same code as after the migrate_from_db() call but with str replaced by int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old way of checking was raising an exception: calling this before the migrate_from_db() call would fail because of db pool exhaustion

env = await Environment.get_one(name="dev-1")
assert isinstance(env.settings["autostart_agent_deploy_interval"], int)
assert isinstance(env.settings["autostart_agent_repair_interval"], int)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we got the pool exhaustion. This is very strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it strange as well, I have no idea

src/inmanta/db/versions/v202310090.py Outdated Show resolved Hide resolved
src/inmanta/db/versions/v202310090.py Outdated Show resolved Hide resolved
tests/db/migration_tests/test_v202310040_to_v202310090_.py Outdated Show resolved Hide resolved
async def test_type_change(
migrate_db_from: abc.Callable[[], abc.Awaitable[None]], get_tables_in_db: abc.Callable[[], abc.Awaitable[list[str]]]
) -> None:
await migrate_db_from()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect you just need to same code as after the migrate_from_db() call but with str replaced by int?

@arnaudsjs
Copy link
Contributor

Do we also have a test somewhere that verifies that getting these settings via the API returns data in the right type?

src/inmanta/db/versions/v202310090.py Outdated Show resolved Hide resolved
tests/db/migration_tests/test_v202310040_to_v202310090_.py Outdated Show resolved Hide resolved
tests/db/migration_tests/test_v202310040_to_v202310090_.py Outdated Show resolved Hide resolved
async def test_type_change(
migrate_db_from: abc.Callable[[], abc.Awaitable[None]], get_tables_in_db: abc.Callable[[], abc.Awaitable[list[str]]]
) -> None:
await migrate_db_from()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why we got the pool exhaustion. This is very strange.

@Hugo-Inmanta
Copy link
Contributor Author

Do we also have a test somewhere that verifies that getting these settings via the API returns data in the right type?

Added the test_api_return_type test in tests/server/test_env_settings.py

@@ -38,6 +38,17 @@ def check_only_contains_default_setting(settings_dict: Dict[str, object]) -> Non
assert setting_value == get_environment_setting_default(setting_name)


async def test_api_return_type(client, server, environment_default):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this test case use the environment_default fixture instead of the environment fixture we always use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I copy pasted the test definition from test_environment_settings. Fixed to use the environment fixture.
I wonder, what would the issue be with using environment_default instead ? I'm guessing it is the fact that auto_deploy is true in that one ? Could it cause flakiness/slowness ?

@Hugo-Inmanta Hugo-Inmanta added the merge-tool-ready This ticket is ready to be merged in label Oct 10, 2023
@inmantaci
Copy link
Contributor

Processing this pull request

inmantaci pushed a commit that referenced this pull request Oct 10, 2023
# Description

Previous PR was missing a migration script

closes #6549

# Self Check:

Strike through any lines that are not applicable (`~~line~~`) then check the box

- [ ] Attached issue to pull request
- [ ] Changelog entry
- [ ] Type annotations are present
- [ ] Code is clear and sufficiently documented
- [ ] No (preventable) type errors (check using make mypy or make mypy-diff)
- [ ] Sufficient test cases (reproduces the bug/tests the requested feature)
- [ ] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
- [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
@inmantaci
Copy link
Contributor

Merged into branches master in ba616b3

inmantaci pushed a commit that referenced this pull request Oct 10, 2023
# Description

Previous PR was missing a migration script

closes #6549

# Self Check:

Strike through any lines that are not applicable (`~~line~~`) then check the box

- [ ] Attached issue to pull request
- [ ] Changelog entry
- [ ] Type annotations are present
- [ ] Code is clear and sufficiently documented
- [ ] No (preventable) type errors (check using make mypy or make mypy-diff)
- [ ] Sufficient test cases (reproduces the bug/tests the requested feature)
- [ ] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
- [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
@inmantaci inmantaci closed this Oct 10, 2023
@inmantaci inmantaci deleted the issue/6549-add-missing-migration-script branch October 10, 2023 06:43
@inmantaci
Copy link
Contributor

Processing #6605.

inmantaci pushed a commit that referenced this pull request Oct 10, 2023
Pull request opened by the merge tool on behalf of #6596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-tool-ready This ticket is ready to be merged in
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix issues with deploy/repair interval cron expressions
3 participants