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

[sonic-bgpcfgd] Call Python 3 version of sonic-cfggen for testing #5847

Merged
merged 5 commits into from
Nov 13, 2020
Merged

[sonic-bgpcfgd] Call Python 3 version of sonic-cfggen for testing #5847

merged 5 commits into from
Nov 13, 2020

Conversation

jleveque
Copy link
Contributor

@jleveque jleveque commented Nov 6, 2020

- Why I did it

sonic-bgpcfgd build fails in the absence of Python 2, as it attempts to explicitly call sonic-cfggen using /usr/bin/python2.7. Also, it attempts to call sonic-cfggen using a local, relative path. Since the sonic-config-engine package is not installed, neither are its dependencies.

Resolves #5847

- How I did it

Configure the Python 3 sonic-config-engine as a dependency of sonic-bgpcfgd, which ensures the Python 3 sonic-config-engine package and its dependencies are installed before sonic-bgpcfgd is built/tested.

- How to verify it

Build sonic-bgpcfgd.

- Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@pavel-shirshov
Copy link
Contributor

But currently sonic-config-engines supports only python2.
As soon as sonic-config-engine would be changed to python 3, your change should be applied.

@jleveque
Copy link
Contributor Author

jleveque commented Nov 7, 2020

@pavel-shirshov
Copy link
Contributor

Yes. Youre right. That works for me.

@@ -13,7 +13,7 @@ def run_test(name, template_path, json_path, match_path):
template_path = os.path.join(TEMPLATE_PATH, template_path)
json_path = os.path.join(DATA_PATH, json_path)
cfggen = os.path.abspath("../sonic-config-engine/sonic-cfggen")
command = ['/usr/bin/python2.7', cfggen, "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
command = ['/usr/bin/python3', cfggen, "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
Copy link
Contributor

@pavel-shirshov pavel-shirshov Nov 7, 2020

Choose a reason for hiding this comment

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

One suggestion is to completely remove '/usr/bin/python3' from the command array.
Just cfggen would be enough

Added. That would be enough if you remove
"env={"PYTHONPATH": "."}" from below too

Copy link
Contributor Author

@jleveque jleveque Nov 7, 2020

Choose a reason for hiding this comment

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

I considered that, but until we remove all Python 2, I want to explicitly call the Python 3 version, so that it doesn't accidentally try to run the Python 2 version.

I think we can clean it up later, once we have removed Python 2 completely.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok. sounds good.

Copy link
Contributor Author

@jleveque jleveque Nov 7, 2020

Choose a reason for hiding this comment

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

@pavel-shirshov: When attempting to call sonic-cfggen locally via a relative path, there were missing dependencies. Thus, I made further changes to add a test dependency on the sonic-config-engine package in order to ensure the package is installed in the build environment, and then let the location be resolved via the system path.

However, there are now some test failures. Can you please investigate them?

Copy link
Contributor Author

@jleveque jleveque Nov 8, 2020

Choose a reason for hiding this comment

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

@tahmed-dev: I'm curious if these test failures may be related to the new sorting differences since you removed the dependency of sonic-cfggen on natsort. Perhaps you can comment on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. @pavel-shirshov has migrated the package to Python 3.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jleveque regenerate the verification data for Python 3 cfggen. I could not push to your branch and so create this PR:5913

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tahmed-dev: I have incorporated your changes into my branch. A number of the tests are now passing, but some are still failing. It appears as though you may have used an out-of-date branch. I will try to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All check builds are passing now. Thanks for your help, @tahmed-dev!

Copy link
Contributor

Choose a reason for hiding this comment

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

great news! Thanks @jleveque!

pavel-shirshov
pavel-shirshov previously approved these changes Nov 7, 2020
@pavel-shirshov
Copy link
Contributor

retest broadcom please

@pavel-shirshov
Copy link
Contributor

Can we convert sonic-cfggen into python3?

@jleveque jleveque marked this pull request as ready for review November 13, 2020 17:58
@jleveque jleveque merged commit 56fa3cf into sonic-net:master Nov 13, 2020
@jleveque jleveque deleted the fix_bgpcfgd_build branch November 13, 2020 19:39
santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
…nic-net#5847)

sonic-bgpcfgd build fails in the absence of Python 2, as it attempts to explicitly call sonic-cfggen using `/usr/bin/python2.7`. Also, it attempts to call sonic-cfggen using a local, relative path. Since the sonic-config-engine package is not installed, neither are its dependencies.

Now, we configure the Python 3 sonic-config-engine as a dependency of sonic-bgpcfgd, which ensures the Python 3 sonic-config-engine package and its dependencies are installed before sonic-bgpcfgd is built/tested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants