Skip to content

Tests are dependent on state of environment #905

Description

@AndreRicardo-Zoetis

Expected Behavior

Tests should pass based on their setup, not on the underlying state of the environment. Or make sure that the test setup loads with a content downloader that does not exist.

In other words, a correctly setup environment should not trigger the tests to fail.

Current Behavior

Test fails if your environment is setup correctly. Currently they only work in CI because the CI environment does not have certain files setup.

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. Setup a content downloader for example:
## configure content downloader extension
so_name="libcurl_content_downloader"
base64digest=$(openssl dgst -binary "/var/lib/adu/extensions/sources/libcurl_content_downloader.so" | openssl base64)

parameters_to_expand="
    so_name
    base64digest
"
target_filepath="/var/lib/adu/extensions/content_downloader/extension.json"

mkdir -p "$(dirname "$target_filepath")"
cp "scripts/docker/templates/content_downloader.extension.template.json" "$target_filepath"
inline_expand_template_parameters "$parameters_to_expand" "$target_filepath"
  1. Test "LoadContentDownloaderLibrary fails when extension load fails and no cached" fails

  2. Removing the file /var/lib/adu/extensions/content_downloader/extension.json makes the test pass again.

rm /var/lib/adu/extensions/content_downloader/extension.json

Device Information

  • Host OS [e.g. Ubuntu 22.04]: Debian 12
  • Architecture [e.g. amd64, arm32, arm64]: amd64
  • Provisioning Method: Symmetric key
  • DU Agent Version (run 'sudo -u adu /usr/bin/AducIotAgent -v'):
    1.4.0

Logs

[ctest] LoadContentDownloaderLibrary fails when extension load fails and no cached
[ctest] -------------------------------------------------------------------------------
[ctest] /workspaces/iot-hub-device-update/src/extensions/extension_manager/tests/src/extension_manager_ut.cpp:417
[ctest] ...............................................................................
[ctest] 
[ctest] /workspaces/iot-hub-device-update/src/extensions/extension_manager/tests/src/extension_manager_ut.cpp:424: FAILED:
[ctest]   CHECK( result.ResultCode == 0 )
[ctest] with expansion:
[ctest]   1 == 0
[ctest] 
[ctest] ===============================================================================
[ctest] test cases: 1 | 1 failed
[ctest] assertions: 1 | 1 failed
[ctest] 
[ctest] 
[ctest] 
[ctest] 0% tests passed, 1 tests failed out of 1
[ctest] 
[ctest] Total Test time (real) =   0.02 sec
[ctest] 
[ctest] The following tests FAILED:
[ctest] 	310 - LoadContentDownloaderLibrary fails when extension load fails and no cached (Failed)

Additional Information

Please provide any additional information that may be helpful in understanding the issue.

If you setup your environment to be able to run AducIotAgent then try to run the tests, the following are failing

The following tests FAILED:
        310 - LoadContentDownloaderLibrary fails when extension load fails and no cached (Failed)
        311 - IsComponentsEnumeratorRegistered returns false when no enumerator loaded (Failed)
        312 - LoadComponentEnumeratorLibrary fails when extension not found (Failed)
        313 - InitializeContentDownloader fails when downloader lib not loaded (Failed)
        315 - GetAllComponents fails when component enumerator not loadable (Failed)
        316 - SelectComponents fails when component enumerator not loadable (Failed)
        318 - ExtensionManager_InitializeContentDownloader wrapper returns failure when no downloader (Failed)
        339 - GetDownloadTimeoutInMinutes returns downloadOptions value when config has zero timeout (Failed)
        342 - GetDownloadTimeoutInMinutes returns default when downloadOptions has zero timeout (Failed)
        343 - GetDownloadTimeoutInMinutes returns default for large timeout value in options (Failed)
        344 - Default_ExtensionManager_Download_Options can be modified and used (Failed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions