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

Implement an sw/hw/fw upgrade event handler plugin #2515

Merged
merged 2 commits into from Jan 20, 2023

Conversation

johannaengland
Copy link
Contributor

@johannaengland johannaengland commented Nov 24, 2022

The plugin copies the variables old_version and new_version (if exists) to alert history to use in reports (#2466)

I decided to not just do it for software upgrades, but also firmware and hardware in case we also want to create reports for that.

Also fixes #2533 as a side effect.

@github-actions
Copy link

github-actions bot commented Nov 24, 2022

Test results

     12 files       12 suites   12m 29s ⏱️
3 206 tests 3 110 ✔️   96 💤 0
9 093 runs  8 805 ✔️ 288 💤 0

Results for commit 3555eb2.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Merging #2515 (5d38055) into master (c541744) will decrease coverage by 0.96%.
The diff coverage is 94.11%.

❗ Current head 5d38055 differs from pull request most recent head 3555eb2. Consider uploading reports for the commit 3555eb2 to get more accurate results

@@            Coverage Diff             @@
##           master    #2515      +/-   ##
==========================================
- Coverage   53.54%   52.59%   -0.96%     
==========================================
  Files         556      556              
  Lines       40432    39615     -817     
==========================================
- Hits        21651    20834     -817     
  Misses      18781    18781              
Impacted Files Coverage Δ
python/nav/eventengine/plugins/upgrade.py 94.11% <94.11%> (ø)
python/nav/napalm.py 34.14% <0.00%> (-42.05%) ⬇️
python/nav/ipdevpoll/epollreactor2.py 66.66% <0.00%> (-28.58%) ⬇️
python/nav/portadmin/napalm/juniper.py 35.64% <0.00%> (-10.24%) ⬇️
python/nav/mibs/if_mib.py 38.88% <0.00%> (-8.74%) ⬇️
python/nav/web/geomap/templatetags/geomap.py 41.66% <0.00%> (-8.34%) ⬇️
python/nav/django/templatetags/date_and_time.py 38.09% <0.00%> (-7.74%) ⬇️
python/nav/mibs/cisco_entity_fru_control_mib.py 44.68% <0.00%> (-7.18%) ⬇️
python/nav/django/templatetags/portadmin.py 50.00% <0.00%> (-7.15%) ⬇️
python/nav/django/templatetags/watchdog.py 60.00% <0.00%> (-6.67%) ⬇️
... and 225 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Looks great, but I have one question about the available variables - and:

The diff coverage is less than 50%, so codecov complains. Can you get this under test so we keep our coverage stats up?

python/nav/eventengine/plugins/upgrade.py Outdated Show resolved Hide resolved
@johannaengland
Copy link
Contributor Author

Are there any tests for eventengine plugins that I could orient myself on?

@lunkwill42
Copy link
Member

lunkwill42 commented Dec 1, 2022

Are there any tests for eventengine plugins that I could orient myself on?

Sure. There is tests/unittests/eventengine/ (where tests use mocks - and also mocking by subclasing - to make proper unit tests), and tests/integration/eventengine/ (where tests set up more complex "black box" testing of eventengine as a whole)

@sonarcloud
Copy link

sonarcloud bot commented Dec 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Seeing the changes you implemented as a result of my previous review, I see that my feedback could have been a bit more specific regarding the old/new version variable stuff. Looks to me like you need an extra PR 😛

Also, codecov still doesn't seem very happy 😞

python/nav/eventengine/plugins/upgrade.py Outdated Show resolved Hide resolved
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

So, after an out-of-band discussion about missing code coverage, the conclusion is thus:

There is no need/reason for this plugin to be tested in a black-box fashion, involving a full eventengine daemon run, as the upgrade plugin's behavior is quite simple.

You're better off testing the plugin class directly. This doesn't start a subprocess, where the collection of coverage data can be problematic.

python/nav/eventengine/plugins/upgrade.py Outdated Show resolved Hide resolved
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Much better, just nitpicks left :)

tests/integration/eventengine/upgrade_test.py Outdated Show resolved Hide resolved
lunkwill42
lunkwill42 previously approved these changes Jan 20, 2023
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

🎉

@lunkwill42 lunkwill42 dismissed their stale review January 20, 2023 11:26

Failing tests this time around :P

@sonarcloud
Copy link

sonarcloud bot commented Jan 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

@lunkwill42 lunkwill42 merged commit 404b1ba into Uninett:master Jan 20, 2023
@johannaengland johannaengland deleted the upgrade-eventengine-plugin branch January 20, 2023 12:52
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.

[BUG] ipdevpoll posts generic deviceNotice events around the time of software upgrades
2 participants