Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The tests for Acquia Search are out of date and incompatible with D7's SimpleTest implementation. It would be great to revive the tests to ensure the module is working properly.
Comment | File | Size | Author |
---|---|---|---|
#23 | 1784990-23.patch | 10.39 KB | Nick_vh |
#19 | 1784990-19.patch | 10.42 KB | Nick_vh |
#16 | 1784990-16.patch | 11.24 KB | Nick_vh |
#13 | 1784990-12.patch | 10.67 KB | Nick_vh |
#11 | acquia-search-tests-1784990-11.patch | 9.5 KB | cpliakas |
Comments
Comment #1
cpliakas CreditAttribution: cpliakas commentedFirst patch that adds tests for the derived key and HMAC generation.
Comment #2
cpliakas CreditAttribution: cpliakas commentedThe attached patch is a good start and ready for review. It has two known failures pending the bugfixes for the following issues:
Clearly more tests are warranted, but it might be best to start small.
Comment #3
coltraneApplies cleanly and every test passes but the two mentioned.
Some nitpicks:
I'm under the impression that DrupalUnitTestCase is faster than WebTestCase, but I don't have data to back that up. Perhaps though since every test but EnvironmentUI is more of a unit test it'd be better to separate?
Is there a chance of this URL changing? If so it could be a property of the class in setUp() so it's more noticeable to change.
If you disagree feel free to move back to CNR.
Comment #4
cpliakas CreditAttribution: cpliakas commentedThanks for the review.
That seems right to me. I'll separate our the UI stuff and the low level functionality into the appropriate classes.
Yes, that's a good point. It seems there is some code in the middle of acquia_search_get_environment() that calculates the hostname. Maybe it would be good to separate out that code into an isolated function so that we could re-use it in setUp() as you mentioned.
Thanks again,
Chris
Comment #5
cpliakas CreditAttribution: cpliakas commentedSo I refactored the code using DrupalUnitTestCase, and it appears the I can use the testDerivedKey() and testHTMA() methods with that base class, but none of the others since they require connections to the database. Just moving those functions cut my test times from about 2 min to a little over 1 min, so that is pretty significant!
Comment #6
cpliakas CreditAttribution: cpliakas commentedI held off on breaking up the acquia_search_get_environment() to avoid too many changes at once, but we can attack that when we want to unit test that functionality. Attached patch has the suggestions in #1784990-3: Revive unit tests for Acquia Search.
Comment #7
cpliakas CreditAttribution: cpliakas commentedMarking as "needs review" ...
Comment #8
cpliakas CreditAttribution: cpliakas commentedAdded one more test (last one) which fails because of #1784804: Acquia Search is not set to the default environment on install but is important in assuring that the issue is fixed.
Comment #9
cpliakas CreditAttribution: cpliakas commentedHm, unit tests are now failing with a fatal error for some reason. Marking a needs work pending further investigation.
Comment #10
cpliakas CreditAttribution: cpliakas commentedAh. RTFM, Chris.
#887134: Setting up modules in DrupalUnitTestCase is useless
Comment #11
cpliakas CreditAttribution: cpliakas commentedLet's try this again.
Comment #12
cpliakas CreditAttribution: cpliakas commentedToo many typos :-(
Comment #13
Nick_vhLet's see this one - I added some small tests for the hmac cookie, fixed a typo, added some comments and preventively I added some static clears
Comment #14
cpliakas CreditAttribution: cpliakas commentedLooks good. I like the changes, and can confirm all tests pass.
Comment #15
coltraneMinor, can be changed before your commit.
"and"
Comment #16
Nick_vhComment #17
Nick_vhmarking it rtbc
Comment #18
Nick_vhAnd committed! Moving this to Acquia Search 6.x-3.x for backport
Comment #19
Nick_vhAnd a working one for Acquia Search 6.x-3.x
Comment #20
cpliakas CreditAttribution: cpliakas commentedRe #18, Woo-hoo!
Comment #21
cpliakas CreditAttribution: cpliakas commentedDoesn't look like this was committed to the 7.x-2.x branch yet.
Comment #22
Nick_vhIt was committed, just not pushed - Happens when you want to finish something before ending the day! :)
Comment #23
Nick_vhImproved it with a new line on the end of the test file.
Comment #24
Nick_vhfor the randomAcquiaSearchName I could create a new class and let them inherit from that class, but I found that a little bit over the top.
I'm willing to change it to this architecture though. Just let me know how you'd like it.
Comment #25
cpliakas CreditAttribution: cpliakas commentedNot sure anything needs to change. The patch applies cleanly and the test pass for me, so marking as RTBC.
Comment #26
pwolanin CreditAttribution: pwolanin commentedDoes this work with ACQUIA_DEVELOPMENT_NOSSL removed?
Comment #27
cpliakas CreditAttribution: cpliakas commentedFor 6.x-3.x, or in general?
Comment #28
Nick_vhIt does not matter for the tests
ACQUIA_DEVELOPMENT_NOSSL is used in acquia_search_auth_cookie(), and the test does not use this (it uses acquia_search_authenticator())
ACQUIA_DEVELOPMENT_NOSSL is also used in AcquiaSearchService::prepareRequest and we also don't test this *yet* (used in makeServletRequest, sendRawGet and sendRawPost)
Comment #29
pwolanin CreditAttribution: pwolanin commentedApplied patch and ran it w/ success locally.
Comment #30
coltraneACQUIA_DEVELOPMENT_NOSSL is now defined in acquia_connector_test.module. It may need to move to acquia_agent.test if there are some test cases that don't include the test module, but that can happen in a followup.
#23 has incorrect line-endings. Is that a problem of the file or your editor Nick?
Comment #31
Nick_vhIncorrect line endings?
Please clarify? I've never encountered any problems with that?
Comment #32
Nick_vhCommitted, Ben said the line endings were ok - we can revisit that in separate patch