Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Clean up and bug fixes #79

Merged
merged 2 commits into from
Nov 8, 2016
Merged

Clean up and bug fixes #79

merged 2 commits into from
Nov 8, 2016

Conversation

tehhobbit
Copy link
Contributor

@tehhobbit tehhobbit commented Nov 4, 2016

Due to updates to the top command in 4.17:

  • Fixes a bug where the regex used for ram would cause a stacktrace
  • Fixes a bug where the regex for cpu usage would cause a stacktrace

These where older bugs and have never actually worked

  • Fixes a bug where onboard sensors where not displayed
  • Fixes a bug where total ram was returned instead of available
  • Fixes a bug where only cpu used by userspace was reported

Just to make things a bit easier to read.

  • Clean up of overly nested loops

Do you guys want this as one large issue or as several issues ?

Fixes #84 (adding this so the issue is closed automagically when this is merged)

@mirceaulinic
Copy link
Member

mirceaulinic commented Nov 4, 2016

Hi @tehhobbit,

It's fine fixing them in one single PR. But it would be great to open an issue per bug. Doing so, you can then create a new test case per issue providing the specific mock data, as you see on your device (what triggered the bug in your case). For example: for issue #58 we have provided the mock data under https://github.com/napalm-automation/napalm-eos/tree/develop/test/unit/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down, having the dir name using the issue ID and a very brief description. That way, will be easier on the long term to see what happened, why some lines of code are present etc. Additionally (but not mandatory), if you have new lines, you can also add a short inline comment in your code to point the issue ID.

Does this make sense to you?

Also, make sure pylama is happy (line 476 might be too long - max len is 100 as per https://github.com/napalm-automation/napalm-eos/blob/develop/setup.cfg)

"used_ram": 4580692
},
"cpu": {
"0": {
"%usage": 3.5
"%usage": 4.3
Copy link
Member

Choose a reason for hiding this comment

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

You didn't like the value of 3.5? :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an effect of that previously only userspace usage was reported.

Copy link
Member

Choose a reason for hiding this comment

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

I was just messing around :)

* Fixes a bug where onboard sensors where not displayed
* Fixes a bug where the regex used for ram would cause a stacktrace
* Fixes a bug where total ram was returned instead of available
* Fixes a bug where the regex for cpu usage would cause a stacktrace
* Fixes a bug where only cpu used by userspace was reported
* Clean up of overly nested loops
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 79.231% when pulling 73d5f8b on tehhobbit:derp into 49d4f54 on napalm-automation:develop.

@tehhobbit
Copy link
Contributor Author

For the mock data I am a bit unsure how to do that, since we would have to try the same test with multiple versions of data ( one for older EOS releases and one for newer EOS releases) I have added data to cover the on board sensor case.

@mirceaulinic
Copy link
Member

mirceaulinic commented Nov 4, 2016

@tehhobbit napalm-eos is one of the few napalm drivers (yet) using the new testing framework allowing us to test multiple scenarios, multiple OS versions etc.

Let's look again at the example #58: under napalm-eos/test/unit/mocked_data/test_get_bgp_neighbors/ (https://github.com/napalm-automation/napalm-eos/tree/develop/test/unit/mocked_data/test_get_bgp_neighbors) you will see two directories:

  • normal
  • issue58_neighbor_down

All tests have the dir normal (for the default behaviour) and anything under must stay unchanged (unless drastic changes such as executing different commands on the device - as you had in #76, or other exceptional cases).

Now, for any bug, you only need to do mkdir <test_case_name> and place the same files as you see under normal but with a different content.

Is this more obvious now?

@dbarrosop
Copy link
Member

Yes, please, add a new test case. Should be fairly easy to add and I think @mirceaulinic is guiding (ask if you have questions). That will allow us to ensure we do regression tests and that we also test corner cases.

Thanks for the fixes, keep them coming ;)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 79.231% when pulling c9a32a1 on tehhobbit:derp into 49d4f54 on napalm-automation:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 79.231% when pulling ce8c5d4 on tehhobbit:derp into 49d4f54 on napalm-automation:develop.

@dbarrosop
Copy link
Member

Thx for the last commit, now we are talking. Shouldn't you revert the changes to the "normal" test case, though?

@tehhobbit
Copy link
Contributor Author

You mean having the new ones as normal and the exception as it used to be ?

@mirceaulinic
Copy link
Member

As pointed out above, what is under the normal dir should remain unchanged, i.e.: exactly the content from https://github.com/napalm-automation/napalm-eos/tree/develop/test/unit/mocked_data/test_get_environment/normal
You only need to add new mock data, not change the existing one in this case.

@tehhobbit
Copy link
Contributor Author

Well that is how it is now. So I gather no further changes are needed. The reason for asking is that Arista have changed the output for all future versions making the old behaviour obsolete and for a fact not the normal case.

Copy link
Member

@mirceaulinic mirceaulinic left a comment

Choose a reason for hiding this comment

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

I left few inline comments - please revert the changes from the corresponding files.

@@ -869,6 +869,33 @@
}
],
"shutdownOnOverheat": true,
"tempSensors": [],
Copy link
Member

Choose a reason for hiding this comment

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

@tehhobbit this file was changed - should not be. Please revert this.

@@ -328,8 +338,6 @@
"capacity": 2900
}
},
"used_ram": "",
Copy link
Member

Choose a reason for hiding this comment

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

@tehhobbit this file was changed - should not be. Please revert this.

@dbarrosop
Copy link
Member

Well that is how it is now. So I gather no further changes are needed. The reason for asking is that Arista have changed the output for all future versions making the old behaviour obsolete and for a fact not the normal case.

Well, thanks Arista for that : (

However, we can't just adapt the code and break older versions so the patch here has to support both scenarios. Probably a couple of helper methods that are called depending on the version would do.

@dbarrosop dbarrosop modified the milestones: 0.4.4, 0.4.3 Nov 7, 2016
@tehhobbit
Copy link
Contributor Author

Added #84 for data that is actually wrong (removed in the current PR). In regards to breaking change, nothing of this breaks when I have tested across 4.14 - 4.17 both chassis and fixed formfactor.

@dbarrosop
Copy link
Member

Ok, reviewed the code again. I just realized you just added data to the normal case, you didn't actually changed the test itself. Sorry for the confusion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Faulty data in tests and output
4 participants