Skip to content

Conversation

@aaronweeden
Copy link
Contributor

@aaronweeden aaronweeden commented Oct 12, 2023

Description

This PR adds regression tests of the warehouse/raw-data REST endpoint.

It also removes some of the integration tests that were made redundant by the new regression tests.

Tests for the SUPREMM realm will be added in ubccr/xdmod-supremm#354.

Motivation and Context

There will be upcoming PRs (e.g., #1779, #1780) that modify the warehouse/raw-data endpoint, and the new tests from this PR will help catch any unintended changes to the response data.

Tests performed

In a Docker container running tools-ext-01.ccr.xdmod.org/xdmod-10.5.0-x86_64:rockylinux8.5-0.3:

  1. Run export XDMOD_TEST_MODE=fresh_install
  2. Run the following commands:
    export COMPOSER_ALLOW_SUPERUSER=1
    export XDMOD_REALMS='jobs,storage,cloud'
    export XDMOD_IS_CORE=yes
    export XDMOD_INSTALL_DIR=/xdmod
    openssl genrsa -rand /proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/uptime 2048 > /etc/pki/tls/private/localhost.key
    /usr/bin/openssl req -new -key /etc/pki/tls/private/localhost.key -x509 -sha256 -days 365 -set_serial $RANDOM -extensions v3_req -out /etc/pki/tls/certs/localhost.crt -subj "/C=XX/L=Default City/O=Default Company Ltd"
    git clone https://github.com/ubccr/xdmod /xdmod
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/regression/runtests.sh
    cd /xdmod
    composer install
    mkdir ~/phpunit
    mkdir /tmp/screenshots
    ~/bin/buildrpm xdmod
    ./tests/ci/bootstrap.sh
    ./tests/ci/validate.sh
    composer install --no-progress
    mv ./configuration/organization.json ./configuration/organization.json.old
    mv ./configuration/portal_settings.ini ./configuration/portal_settings.ini.old
    cp /etc/xdmod/portal_settings.ini ./configuration/portal_settings.ini
    cp /etc/xdmod/organization.json ./configuration/organization.json
    ./tests/ci/scripts/qa-test-setup.sh
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/unit/runtests.sh
    /xdmod/tests/unit/runtests.sh > /unit-before.txt
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/component/runtests.sh
    /xdmod/tests/component/runtests.sh > /component-before.txt
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/regression/runtests.sh
    /xdmod/tests/regression/runtests.sh > /regression-before.txt
    cd /xdmod/tests/integration
    ../../vendor/bin/phpunit --testsuite default --group UserAdminTest.createUsers --debug > /integration-before.txt
    ../../vendor/bin/phpunit --testsuite default --exclude-group UserAdminTest.createUsers --debug >> /integration-before.txt
    cd /xdmod
    git clone https://github.com/aaronweeden/xdmod -b add-raw-data-regression-tests /xdmod-new
    unalias rm
    rm -r /xdmod/tests
    cp -r /xdmod{-new,}/tests
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/unit/runtests.sh
    /xdmod/tests/unit/runtests.sh > /unit-after.txt
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/component/runtests.sh
    /xdmod/tests/component/runtests.sh > /component-after.txt
    sed -i 's/\$phpunit /$phpunit --debug /' /xdmod/tests/regression/runtests.sh
    /xdmod/tests/regression/runtests.sh > /regression-after.txt
    cd /xdmod/tests/integration
    ../../vendor/bin/phpunit --testsuite default --group UserAdminTest.createUsers --debug > /integration-after.txt
    ../../vendor/bin/phpunit --testsuite default --exclude-group UserAdminTest.createUsers --debug >> /integration-after.txt
    unalias mv
    for file in /regression-{before,after}.txt; do
        for test in {testChartSettings,testChartFilters,testCsvExport}; do
            for realm in {Jobs,Cloud,Storage}; do
                sed -i "s/$test with data set.*$realm.*/$test $realm/" $file;
            done;
        done;
        sort $file > $file.tmp;
        mv $file.tmp $file;
    done
    
  3. Compare /unit-{before,after}.txt and make sure the only differences are user hashes and amount of time the tests ran.
  4. Compare /component-{before,after}.txt and make sure the only differences are test name hashes and amount of time the tests ran.
  5. Compare /integration-{before,after}.txt and make sure the differences are correct:
    1. Different random values for ControllerTest::testEnumTargetAddresses.
    2. The testGetRawData tests have been removed in which the test data start with success_0, success_16500, and success_fields_and_filters.
    3. The last group of tests:
      1. Takes a few seconds less.
      2. Uses ~80 fewer MB.
      3. 787 tests -> 784 tests.
      4. 571156 assertions -> 7141 assertions.
  6. Compare /regression-{before,after}.txt and make sure the differences are correct:
    1. Different dots at the top.
    2. One extra line each starting with 'Configuration', 'OK', 'PHPUnit', 'Runtime', and 'Time' (evidencing the new group of tests).
    3. Four new lines for WarehouseRawDataTest::testGetRawData.
  7. Repeat in a new container with export XDMOD_TEST_MODE=upgrade.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch 2 times, most recently from d3953f4 to 240527c Compare October 13, 2023 15:01
@aaronweeden aaronweeden added the qa / testing Updates/additions to tests label Oct 13, 2023
@aaronweeden aaronweeden added this to the 11.0.0 milestone Oct 13, 2023
@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch 2 times, most recently from 5385b5d to 6e98c84 Compare October 13, 2023 18:23
@aaronweeden aaronweeden marked this pull request as ready for review October 13, 2023 18:48
@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch from 6e98c84 to 8aa08d6 Compare October 13, 2023 18:50
. '/../integration/lib/'
. str_replace('\\', '/', $className)
. '.php';
. str_replace(
Copy link
Member

Choose a reason for hiding this comment

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

Please can you explain this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a comment above the code to explain; it is to make sure IntegrationTests\BaseTest can be resolved to ../integration/lib/BaseTest.php and IntegrationTests\TokenAuthTest can be resolved to ../integration/lib/TokenAuthTest.php, since they are directly in the lib directory and not a subdirectory; this is just as in the integration tests bootstrap.php:

. str_replace(
'\\',
'/',
preg_replace(
'/IntegrationTests\\\\?/',
'',
$className
)
) . '.php';

However, now that I'm looking at it again, I think I can submit another PR to address an inconsistency between the directory structure and the integration test namespaces that would make these lines in the bootstrap.php files be unnecessary; stay tuned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After more digging, I think it is indeed necessary to have code in the bootstrap.php files that resolves namespace prefixes (e.g., IntegrationTests) to base directories (e.g., tests/integration/lib). However, there are also namespace and directory inconsistencies that can be addressed separately in #1789.

@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch 2 times, most recently from e6644f8 to ee4d2e3 Compare October 19, 2023 13:25
@aaronweeden aaronweeden mentioned this pull request Nov 3, 2023
3 tasks
@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch 2 times, most recently from 5820bbb to 59953ef Compare November 7, 2023 16:55
@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch from 59953ef to 00e877b Compare November 20, 2023 20:37
eiffel777
eiffel777 previously approved these changes Nov 28, 2023
@aaronweeden aaronweeden force-pushed the add-raw-data-regression-tests branch from 30f82f6 to beb96e3 Compare December 5, 2023 18:33
@aaronweeden aaronweeden merged commit e5c8e4e into ubccr:xdmod11.0 Dec 5, 2023
@aaronweeden aaronweeden deleted the add-raw-data-regression-tests branch December 5, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa / testing Updates/additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants