test: Add check-subscriptions to test the Cockpit UI#2091
test: Add check-subscriptions to test the Cockpit UI#2091jirihnidek merged 1 commit intocandlepin:masterfrom
Conversation
|
The new test fails with I think the URL should be |
|
Can one of the admins verify this patch? |
|
The code attempts to save the right config, it seems, but it doesn't seem to have any effect. The daemon says: So the daemon does indeed use the wrong value for "handler". The config file itself does not look as expected: Only the handler/prefix made it through and there is no newline at the end. Doing a manual D-Bus call at this point results in the same error message as above: Restarting the daemon changes that: The daemon says: So it has picked up the new prefix/handler but reverted back to the default host, as could be expected from rhsm.conf. Thus, I don't think this is a bug with the code in cockpit/ or with test/check-subscriptions but rather with the |
I should point out that all the previous content of the config file is gone, too. That is also not expected. :-) |
Yes, that's true. When candlepin is deployed without modificated configuration files, then the URL begins with |
|
@mvollmer I'm almost sure that our QE team have similar tests. |
|
The problem was that subscription-client.js was setting the config values and calling AutoAttach all at the same time. One could argue that the daemon needs to be able to deal with that and serialize the execution of the method calls as needed, but we can also change the client to make them sequentially. Also, a restart of rhsm seems to be necessary. I am making progress with adapting the test from Cockpit, and my plan right now is to continue until I can get it green. At that point, you could merge this and we add this repo to the Cockpit CI config and the test would run automatically for every PR. Wdyt? |
Did it also find the issue with using a custom url? |
1d32f8a to
277fac4
Compare
|
Okay, the tests are green now when I run them locally. I have included the necessary fixes here. The "Don't concurrently set config and attach" fix is argueably a workaround for a bug in rhsm. It should just cope with overlapping Config.Set calls. I think I'll open an issue about that. |
2e77062 to
966e537
Compare
|
Here is a demo PR of how this would look in action: mvollmer#1 The PR deliberately breaks one of the tests, so the failure is expected. |
50f14ca to
e6d75f3
Compare
|
I have changed |
Yes we have similar tests. On the other hand I suppose it should be easy to reuse tests written this way in our testware. |
|
@mvollmer Thanks for your work on this PR. Should we do PR review now or do you still want to work on this PR? |
Please start the review. Thanks! |
|
@mvollmer ok :-) |
jirihnidek
left a comment
There was a problem hiding this comment.
Hi, thanks for your PR.
I'm little bit confused from changes in Javascript code. Does it include bug fix (it seem so)? You mentioned some technical issues during testing this PR. If changes in this PR contains bug fix, then please open another PR containing only bug fix and please fill Bugzilla bug report (commit message should begin with BZ bug number).
I wasn't able to test it much, because I don't have Fedora (Python 3) on my PC and creating of VM requires Python 3. I will try to test it later.
test/run
Outdated
| bots: | ||
| git fetch --depth=1 https://github.com/cockpit-project/cockpit.git | ||
| git checkout --force FETCH_HEAD -- bots/ | ||
| git reset bots |
There was a problem hiding this comment.
It requires Python 3 and Python 2 is not the option. It should be noted somewhere in the README.md
There was a problem hiding this comment.
We also have Vagrant environment. Could it be possible to use existing Vagrant machine or could it be possible to create new testing machine using Vagrant?
There was a problem hiding this comment.
We also have Vagrant environment. Could it be possible to use existing Vagrant machine or could it be possible to create new testing machine using Vagrant?
I'll check that out. The immediate goal here is to integrate the subscription-manager UI tests into the Cockpit CI machinery, because that would be relatively easy. (One might say that it's done already. :-)
Does your Jenkins CI machinery use these Vagrant images? If your are more comfortable with running Cockpit UI tests there, we can certainly work on that as well.
The Cockpit CI integration here has the downside that it only tests the new Cockpit code; it doesn't build and install a new rhsmd, for example. I think that's a significant drawback, and if going with Jenkins would fix that, that would be a strong argument.
There was a problem hiding this comment.
I'll check that out. The immediate goal here is to integrate the subscription-manager UI tests into the Cockpit CI machinery, because that would be relatively easy. (One might say that it's done already. :-)
I can see the reason, why you decided to use something else than Vagrant.
Does your Jenkins CI machinery use these Vagrant images? If your are more comfortable with running Cockpit UI tests there, we can certainly work on that as well.
The definitions of Jenkins jobs are here: https://github.com/candlepin/candlepin-jobs/. Vagrant can be used for testing Jenkins jobs, but our Vagrant machines are used for Jenkins CI. Vagrant machines are used for testing mostly be developers.
The Cockpit CI integration here has the downside that it only tests the new Cockpit code; it doesn't build and install a new rhsmd, for example. I think that's a significant drawback, and if going with Jenkins would fix that, that would be a strong argument.
Yeah, when Vagrant machine is used, then rhsmd and everything else is just as fresh as possible.
There was a problem hiding this comment.
I have added a commit here that installs rhsm into our VM image.
| args = {"addr": "10.111.113.5"} | ||
| m.execute(script=WAIT_SCRIPT % args) | ||
|
|
||
| def testRegister(self): |
There was a problem hiding this comment.
I can see several tests in this function. Could it be refactored little bit? Could you split it into several functions?
There was a problem hiding this comment.
The overhead to setup a test is significant, unfortunately, so we tend to bunch a couple of tests together into a single run just for performances sake... But I see your point, of course. I'll split them up.
There was a problem hiding this comment.
The overhead to setup a test is significant, unfortunately, so we tend to bunch a couple of tests together into a single run just for performances sake... But I see your point, of course. I'll split them up.
You needn't to use setUp() for starting tomcat. You can also use setUpClass() for this purpose. https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUpClass
There was a problem hiding this comment.
You can also use setUpClass() for this purpose.
Ohh, nice! I'll use that.
There was a problem hiding this comment.
You can also use setUpClass() for this purpose.
Ohh, nice! I'll use that.
That didn't work out as expected. The serUpClass method can't start any machines since that needs an instance. (I guess we can try adding support for "infrastructure" machines that are meant to be shared between tests.)
| sleep 1 | ||
| fi | ||
| done | ||
| """ |
There was a problem hiding this comment.
Well. I guess it can work, but I would like to see usage of subprocess and e.g. request module. Calling bash script from python script is unnecessary hack :-)
You can see example of using requests and candlepin API e.g. here: https://github.com/candlepin/candlepin/blob/master/server/bin/create_test_repos.py#L258
There was a problem hiding this comment.
Calling bash script from python script is unnecessary hack :-)
This script runs in the VM itself, via self.machine.execute(...), so this is not such a big hack as it might seem.
Still, Python is strictly nicer than bash, so I'll rewrite the bash bits.
test/check-subscriptions
Outdated
| data = json.loads(sys.stdin.read()) | ||
| print [e['id'] for e in data if e['name'] == 'awesome_os_pool' and e['owner']['displayName'] == 'Admin Owner'][0] | ||
| " | ||
| """ |
There was a problem hiding this comment.
Again. Please use requests module. This is too big hack (from Python call bash, then call curl, then parse output of curl using Python).
There was a problem hiding this comment.
Done. Generating the key can be done in a single step, so I have combined these two scripts.
| data = json.loads(sys.stdin.read()) | ||
| print [ e['id'] for e in data if e['owner']['key'] == 'admin' and e['contractNumber'] == '0' and [p for p in e['providedProducts'] if p['productId'] == '88888'] ][0] | ||
| " | ||
| """ |
test/check-subscriptions
Outdated
|
|
||
| class TestSubscriptions(MachineCase): | ||
| provision = { | ||
| "0": {"address": "10.111.113.1/20"}, |
There was a problem hiding this comment.
Is it always this IP address? If yes, then please use some constant for that. if no, then it should be possible specify it using some configuration file or command line argument.
test/check-subscriptions
Outdated
| class TestSubscriptions(MachineCase): | ||
| provision = { | ||
| "0": {"address": "10.111.113.1/20"}, | ||
| "candlepin": {"image": "candlepin", "address": "10.111.113.5/20"} |
There was a problem hiding this comment.
Same comment here for this IP address.
test/check-subscriptions
Outdated
| self.candlepin.execute("systemctl start tomcat") | ||
|
|
||
| # download product info from the candlepin machine | ||
| product_file_one = os.path.join(self.tmpdir, "6050.pem") |
There was a problem hiding this comment.
I recommend to create some dictionaries with definition of products. Something like this:
PROD_SNOWY = {
"id": "6050",
"name": "Snowy OS Premium Architecture Bits"
}The name of product can be changed in the future a little and it will be easier to fix it. The name of 88888 in master branch is now: Shared File System Bits (no content).
Yes, there are five commits with bug fixes. Do you want five PRs and bug reports for them? |
It would be great (our QE team would love it 😃 ), but one bug report with one PR could be IMHO acceptable too. |
Alright, I made four bug reports and four PRs: #2116, #2114, #2113, #2112. :-) |
e6d75f3 to
c04b712
Compare
|
@mvollmer You are the best! 😃 |
6f1eed8 to
0dc4748
Compare
0dc4748 to
20a9401
Compare
|
@jirihnidek, can we move this forward? |
jirihnidek
left a comment
There was a problem hiding this comment.
Hi Marius, thanks for your updates. 👍 I have few requests.
.gitignore
Outdated
| /bots | ||
| /cockpit/subscription-manager-cockpit.tar.gz | ||
| /node_modules | ||
| /test |
There was a problem hiding this comment.
Directory test should not be in .gitignore, because it includes files with unit tests. I wonder, why do you use absolute path starting with /?
There was a problem hiding this comment.
The leading / is there so that only the top-level test matches. Just test would also match ./syspurpose/test, for example.
/test specifically is in .gitignore because running the tests will create at least ./test/common and ./test/images, but I agree that ignoring all of ./test is wrong.
I'll move all new files out of ./test so we also don't need to ignore anything in there.
| @@ -0,0 +1,248 @@ | |||
| #!/usr/bin/python3 | |||
There was a problem hiding this comment.
Directory ./test/ contains only unit tests at this moment. Please could you move it to some subdirectory (e.g. integration_tests)?
There was a problem hiding this comment.
Yes, I was waiting for this. :-) I'll move the files away. This might require some changes in the Cockpit CI code, but that's for the benefit of everyone so shouldn't be an issue.
| args = {"addr": "10.111.113.5"} | ||
| m.execute(script=WAIT_SCRIPT % args) | ||
|
|
||
| def testRegister(self): |
| @@ -0,0 +1,77 @@ | |||
| #! /usr/bin/make -f | |||
There was a problem hiding this comment.
Please could you move this file to some subdirectory too?
| @@ -0,0 +1,29 @@ | |||
| #!/bin/sh | |||
There was a problem hiding this comment.
Please move this file to some subdirectory too.
074b327 to
6cfdd30
Compare
This also brings the necessary infrastructure.
6cfdd30 to
23e6c12
Compare
|
@jirihnidek, I have moved all the new files into the new directory ./integration-tests. The entry point for the Cockpit bots is now .cockpit-ci/run. You can see a demo in the mvollmer#1 PR, as earlier. |
|
@jirihnidek, forgot to mention: The Cockpit bots still put some files into |
|
Woohoo! Thanks! |
This also brings the necessary infrastructure.