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

Unit tests for sds_sync module #661

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jmolmo
Copy link

@jmolmo jmolmo commented Jun 15, 2018

sds_sync module implementation

In my opinion there is needed a refactorization of the code in this module. Basically the problem is the "extension" of the implementation in each of the methods/functions.
It seems that all the execution units can be easily simplified "breaking" them in small auxiliary functions.
This will give us several advantages:

  1. More easy to read/maintain the code
  2. Unit test more easy to do, and a real possibility of test diferent scenes in the unit tests, not only code coverage is important.
  3. More easy to extend/add functionality
  4. More difficult to repeat things already done/checked in the same function

Method GlusterIntegrationSdsSyncStateThread.Run()

Cluster state and cluster node context are loaded several times in different parts of the method.
I think that even in the case that the situation/state of the cluster change while this method is being executed is not good to load again this information.
IMHO, this can lead to inconsistences. I think that it would be safer to load the information at the beginning and use this information in the rest of the method. Periodic syncs will give us the evolution of the state, but refreshing the status information while we are executing the "run" method seems to be dangerous.

I haven't got a good knowledgment of the whole system, and i haven't work with gluster clusters, also not time enough to solve this lacks, so it is possible that i be wrong in my changes, in any case, this is nothing that cannot be solved with a good code review!, and i really think that this changes will improve the code.

Function check_volumes()

This function has been extracted (refactorization) from the GlusterIntegrationSdsSyncStateThread.Run(). The unit test shows that each time a new option is found, it is saved ... probably it can be modified to save only in one attemp all the options.

Another thing i do not unsderstand is why if there is no options in the volume loaded, the options discovered (gluster cmd details) are not included in the volume.

@jmolmo jmolmo requested review from shtripat and a team as code owners June 15, 2018 07:23
@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@r0h4n
Copy link
Contributor

r0h4n commented Jun 15, 2018

@GowthamShanmugam @anmolsachan please review this

@shtripat The changes seem interesting, please review them

Copy link
Member

@shtripat shtripat left a comment

Choose a reason for hiding this comment

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

Overall changes looks fine to me.
There is a minor comment.

@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #661 into master will increase coverage by 3.38%.
The diff coverage is 68.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #661      +/-   ##
==========================================
+ Coverage   38.76%   42.14%   +3.38%     
==========================================
  Files          42       42              
  Lines        2056     2088      +32     
  Branches      279      282       +3     
==========================================
+ Hits          797      880      +83     
+ Misses       1232     1174      -58     
- Partials       27       34       +7
Impacted Files Coverage Δ
tendrl/gluster_integration/sds_sync/__init__.py 33.09% <68.06%> (+18.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78cbb58...4496163. Read the comment docs.

@shtripat
Copy link
Member

Somehow even I am not able to see the comment. Anyway overall code changes look fine.

@jmolmo
Copy link
Author

jmolmo commented Jun 15, 2018 via email

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.

None yet

4 participants