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

add mysql_full_version and suffix return variable #115

Merged
merged 5 commits into from
Mar 16, 2021
Merged

add mysql_full_version and suffix return variable #115

merged 5 commits into from
Mar 16, 2021

Conversation

rndmh3ro
Copy link
Contributor

SUMMARY

This PR adds two new variables: the suffix variable that is sometimes added to the version-string and the full_version-variable that contains the whole version string (to make it easier to compare versions).

Fixes #114

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

mysql_info

@codecov
Copy link

codecov bot commented Mar 11, 2021

Codecov Report

Merging #115 (63595b9) into main (bd86e24) will increase coverage by 0.48%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   75.75%   76.23%   +0.48%     
==========================================
  Files          12       13       +1     
  Lines        1712     1734      +22     
  Branches      438      440       +2     
==========================================
+ Hits         1297     1322      +25     
+ Misses        269      267       -2     
+ Partials      146      145       -1     
Impacted Files Coverage Δ
plugins/modules/mysql_info.py 79.69% <100.00%> (+1.97%) ⬆️
tests/unit/plugins/modules/test_mysql_info.py 100.00% <100.00%> (ø)

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 bd86e24...63595b9. Read the comment docs.

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@Andersson007
Copy link
Collaborator

fyi: don't worry about codecov/project is red.
Waiting for the changelog fragment

@rndmh3ro
Copy link
Contributor Author

I added the fragment!

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM
@Jorge-Rodriguez if the PR looks good to you too, feel free to merge

@Jorge-Rodriguez
Copy link
Contributor

@rndmh3ro could you add an explicit integration test for the suffix output?
Currently we're testing only against MySQL do it should always be empty, and it'll help cover the use case when we finally at MariaDB integration testing.

Thanks.

returned: if not excluded by filter
type: str
sample: "MariaDB"
full_version:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
full_version:
full:

version = self.info['settings']['version'].split('.')

# full_version = "5.5.60-MariaDB"
full_version = self.info['settings']['version']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
full_version = self.info['settings']['version']
full = self.info['settings']['version']

release=int(release),
suffix=str(suffix),
full_version=str(full_version),
Copy link
Collaborator

@Andersson007 Andersson007 Mar 12, 2021

Choose a reason for hiding this comment

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

Suggested change
full_version=str(full_version),
full=str(full),

@@ -48,7 +48,7 @@
- assert:
that:
- result.changed == false
- result.version != {}
- "mysql_version in result.version.full_version"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- "mysql_version in result.version.full_version"
- "mysql_version in result.version.full"

@@ -0,0 +1,2 @@
minor_changes:
- mysql_info - add `full_version` and `suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- mysql_info - add `full_version` and `suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).
- mysql_info - add `version.full` and `version.suffix` return values (https://github.com/ansible-collections/community.mysql/issues/114).

@rndmh3ro
Copy link
Contributor Author

@Andersson007, thanks I'll add the changes locally.

Currently we're testing only against MySQL do it should always be empty, and it'll help cover the use case when we finally at MariaDB integration testing.

@Jorge-Rodriguez sadly it's not always empty. Looking at the CI-logs:

MySQL 8:

2021-03-12T08:50:26.7204419Z TASK [test_mysql_info : Collect info only about version and databases] *********
2021-03-12T08:50:27.1526986Z �[0;32mok: [testhost] => {"changed": false, "databases": {"information_schema": {"size": 0}, "mysql": {"size": 2654208}, "performance_schema": {"size": 0}, "sys": {"size": 16384}}, "version": {"full_version": "8.0.22", "major": 8, "minor": 0, "release": 22, "suffix": ""}}�[0m


2021-03-12T08:51:25.3928912Z TASK [test_mysql_replication : find out the database version] ******************
2021-03-12T08:51:25.9604764Z �[0;32mok: [testhost] => {"changed": false, "version": {"full_version": "8.0.22", "major": 8, "minor": 0, "release": 22, "suffix": ""}}�[0m

MySQL 5.7:

2021-03-12T08:49:45.3867627Z TASK [test_mysql_info : Collect info only about version and databases] *********
2021-03-12T08:49:45.8869227Z �[0;32mok: [testhost] => {"changed": false, "databases": {"information_schema": {"size": 163840}, "mysql": {"size": 2644595}, "performance_schema": {"size": 0}, "sys": {"size": 16384}}, "version": {"full_version": "5.7.31-log", "major": 5, "minor": 7, "release": 31, "suffix": "log"}}�[0m

2021-03-12T08:51:00.7500011Z TASK [test_mysql_replication : find out the database version] ******************
2021-03-12T08:51:01.4887762Z �[0;32mok: [testhost] => {"changed": false, "version": {"full_version": "5.7.31-log", "major": 5, "minor": 7, "release": 31, "suffix": "log"}}�[0m

How should we proceed here?

@Jorge-Rodriguez
Copy link
Contributor

@rndmh3ro maybe a unit test would be better suited for the task

@rndmh3ro
Copy link
Contributor Author

maybe a unit test would be better suited for the task

I'm not familiar with writing unit tests. My Python-knowledge in this regard is quite limited. How does one do that? :)

@Jorge-Rodriguez
Copy link
Contributor

maybe a unit test would be better suited for the task

I'm not familiar with writing unit tests. My Python-knowledge in this regard is quite limited. How does one do that? :)

There are a couple of simple examples in the tests/units folder. If you still don't feel comfortable, just let me know and I can do it.

@Andersson007
Copy link
Collaborator

@Jorge-Rodriguez it's a very good spot about unit tests.
If @rndmh3ro is not familiar with it, i wouldn't overwhelm him with it (but it's good to study how pytest work in general, just see tests/units/* content).
But if you like to figure out the topic, we could wait.
If not, i think i could implement the unit tests later (or anyone else if they wish), after this is merged if there's no concerns that the changes will break the module.
@Jorge-Rodriguez if you put possible input and output that we expect here, it would be really great.

What do you folks think?

(@rndmh3ro feel free to fix what i suggested for a while.)

@Andersson007
Copy link
Collaborator

@Jorge-Rodriguez ah, didn't see your comment, cool, thanks!

@rndmh3ro
Copy link
Contributor Author

I'd be glad if any of you two can write the unit test (and after that I'll try to understand it :)).

@Andersson007
Copy link
Collaborator

@rndmh3ro sounds sensible

@Jorge-Rodriguez
Copy link
Contributor

@rndmh3ro That unit test took a lot more magick than I expected. I'll be happy to go through it with you if you want.
@Andersson007 I included the changes you requested.

@rndmh3ro
Copy link
Contributor Author

I'll be happy to go through it with you if you want.

That'd be great. There are some parts I don't understand.
Either here or on IRC? On here it's probably better for discoverability so others could learn from it, too. However maybe this PR is not the right place for this.

@Jorge-Rodriguez
Copy link
Contributor

Jorge-Rodriguez commented Mar 16, 2021

@rndmh3ro I'll be hanging out as Tiriel on the Ansible channel on freenode

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM
@Jorge-Rodriguez thanks for the unit tests and adding the suggested changes!
Feel free to merge

@Jorge-Rodriguez Jorge-Rodriguez merged commit a5ee4b3 into ansible-collections:main Mar 16, 2021
@Jorge-Rodriguez
Copy link
Contributor

Better yet would be to review the unit test in a repo discussion. @Andersson007 can we enable those?

@Andersson007
Copy link
Collaborator

@Jorge-Rodriguez , enabled, please check

@Andersson007
Copy link
Collaborator

@rndmh3ro there's more complex case in community.postresql. I'd add it myself there. I'll put a reference to this PR with a comment that the original idea is yours.

@Jorge-Rodriguez
Copy link
Contributor

@Jorge-Rodriguez , enabled, please check

It works. Thanks

@rndmh3ro
Copy link
Contributor Author

#122

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.

mysql_user: get full mysql version string as a variable
3 participants