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

[Caracal] Adapt Tox and Github Workflow & [Caracal] Fix Unit Tests #120

Open
wants to merge 3 commits into
base: stable/2024.1-m3
Choose a base branch
from

Conversation

sven-rosenzweig
Copy link
Contributor

@sven-rosenzweig sven-rosenzweig commented Nov 14, 2024

[Caracal] Adapt Tox and Github Workflow
Adapt github workflow python version and branch to the Caracal/2024.1 release.

[Caracal] Fix Unit Tests
With the Caracal release, default policies are activated by default causing our tests to fail error 'PolicyNotAuthorized'. Simply running them as admin fixes the issue.

@sven-rosenzweig sven-rosenzweig changed the base branch from stable/yoga-m3 to stable/2024.1-m3 November 14, 2024 12:40
@sven-rosenzweig sven-rosenzweig marked this pull request as draft November 14, 2024 15:51
@sven-rosenzweig sven-rosenzweig marked this pull request as ready for review November 19, 2024 14:00
Adapt github workflow python version and branch to the Caracal/2024.1
release.

With later versions of pecan, WebTest is not a dependency of it anymore,
so in order to continue using this, an additional import in
test-requirements is required.
self.assertEqual("10.100.1.2-10.100.1.5/24", router_atts.dynamic_nat_pool)

with mock.patch.object(ASR1KPluginBase, 'ensure_default_route_skip_monitoring', autospec=True):
upd_router = self._remove_external_gateway_from_router(router['router']['id'], None)
# upd_router = self._remove_external_gateway_from_router(router['router']['id'], None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need the commted out call? I think we can remove it, right?

With the Caracal release, default policies are activated by default
causing our tests to fail error 'PolicyNotAuthorized'.
Simply running them as admin fixes the issue.
Comment on lines 718 to 721
agent_host=self.agent_host,
port_id=self.port_id,
segment_id=self.segment_id
).first()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be indented to the same level.

@@ -684,25 +713,27 @@ def __init__(self, context, router_id, port, segment):

@property
def _record_exists(self):
entry = self.session.query(asr1k_models.ASR1KExtraAttsModel).filter_by(router_id=self.router_id,
with db_api.CONTEXT_READER.using(self.context):
entry = self.context.query(asr1k_models.ASR1KExtraAttsModel).filter_by(router_id=self.router_id,
agent_host=self.agent_host,
port_id=self.port_id,
segment_id=self.segment_id
).first()
return entry is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be indented into the with, I think.

if len(second_dot1qs_available) == 0:
raise asr1k_exceptions.SecondDot1QPoolExhausted(agent_host=self.agent_host)
self.second_dot1q = random.choice(second_dot1qs_available)
with db_api.CONTEXT_READER.using(self.context):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be a decorator.

).first()
if entry:
entry.update(extra_att)
with db_api.CONTEXT_WRITER.using(context):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be a decorator.

Copy link
Contributor Author

@sven-rosenzweig sven-rosenzweig Nov 29, 2024

Choose a reason for hiding this comment

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

to make this work with a decorate the contest must be passed as parameter

 @db_api.CONTEXT_READER
    def set_next_entries(self, context):
        extra_atts = context.query(asr1k_models.ASR1KExtraAttsModel).filter_by(agent_host=self.agent_host)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my suggestion is to leave it as is

As per blueprint [1], the existing use of oslo_db session
handling (e.g., context.session.begin()) introduces potential issues.
Notably, unit tests failed during the Caracal release, though
no definitive deployment impact has been identified yet.

To future-proof the code and align with recommended practices,
we are migrating to the enginefacade pattern now.
This involves replacing:
with context.session.begin():
  context.session.add(obj)

with 'db_api.CONTEXT_WRITER.using(context)'

[1] https://blueprints.launchpad.net/neutron/+spec/enginefacade-switch
[2] Oslo db spec: http://specs.openstack.org/openstack/oslo-specs/specs/kilo/make-enginefacade-a-facade.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants