datalad / datalad-installer

Installation script for Datalad and related components
MIT License
6 stars 3 forks source link

test_download_specific_git_annex_release_asset on windows downloads incomplete file without error #150

Closed yarikoptic closed 1 year ago

yarikoptic commented 1 year ago

happened in one recent run https://github.com/datalad/datalad-installer/actions/runs/4351210903/jobs/7602645257 where the other matrix runs were all good. I would have expected some error instead of some incomplete download

================================== FAILURES ===================================
_ test_download_specific_git_annex_release_asset[ubuntu-8.20211231-git-annex-standalone_8.20211231-1.ndall+1_amd64.deb-49966540] _

ostype = 'ubuntu', version = '8.20211231'
filename = 'git-annex-standalone_8.20211231-1.ndall+1_amd64.deb'
size = 49966540
tmp_path = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-unknown/pytest-0/test_download_specific_git_ann0')

    @pytest.mark.ghauth
    @pytest.mark.parametrize(
        "ostype,version,filename,size",
        [
            (
                "ubuntu",
                "8.20211231",
                "git-annex-standalone_8.20211231-1.ndall+1_amd64.deb",
                49966540,
            ),
            ("macos", "8.20211123", "git-annex_8.20211123_x64.dmg", 28809446),
            ("windows", "8.20211117", "git-annex-installer_8.20211117_x64.exe", 18156853),
        ],
    )
    def test_download_specific_git_annex_release_asset(
        ostype: str, version: str, filename: str, size: int, tmp_path: Path
    ) -> None:
        DataladGitAnnexReleaseBuildInstaller.download(
            ostype=ostype,
            target_dir=tmp_path,
            version=version,
        )
        (p,) = tmp_path.iterdir()
        assert p.is_file()
        assert p.name == filename
>       assert p.stat().st_size == size
E       AssertionError: assert 45[154](https://github.com/datalad/datalad-installer/actions/runs/4351210903/jobs/7602645257#step:5:155)03 == 49966540
E        +  where 4515403 = os.stat_result(st_mode=33206, st_ino=1125899908260822, st_dev=1879469748, st_nlink=1, st_uid=0, st_gid=0, st_size=4515403, st_atime=[167](https://github.com/datalad/datalad-installer/actions/runs/4351210903/jobs/7602645257#step:5:168)8[170](https://github.com/datalad/datalad-installer/actions/runs/4351210903/jobs/7602645257#step:5:171)736, st_mtime=1678170736, st_ctime=1678170629).st_size
E        +    where os.stat_result(st_mode=33206, st_ino=1125899908260822, st_dev=1879469748, st_nlink=1, st_uid=0, st_gid=0, st_size=4515403, st_atime=1678170736, st_mtime=1678170736, st_ctime=1678170629) = <bound method Path.stat of WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-unknown/pytest-0/test_download_specific_git_ann0/git-annex-standalone_8.20211231-1.ndall+1_amd64.deb')>()
E        +      where <bound method Path.stat of WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-unknown/pytest-0/test_download_specific_git_ann0/git-annex-standalone_8.20211231-1.ndall+1_amd64.deb')> = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-unknown/pytest-0/test_download_specific_git_ann0/git-annex-standalone_8.20211231-1.ndall+1_amd64.deb').stat

test\test_install.py:490: AssertionError
------------------------------ Captured log call ------------------------------
DEBUG    datalad_installer:datalad_installer.py:2342 HTTP request: GET https://api.github.com/repos/datalad/git-annex/releases/tags/8.20211231
INFO     datalad_installer:datalad_installer.py:2538 Downloading https://github.com/datalad/git-annex/releases/download/8.20211231/git-annex-standalone_8.20211231-1.ndall%2B1_amd64.deb
=========================== short test summary info ===========================
FAILED test/test_install.py::test_download_specific_git_annex_release_asset[ubuntu-8.20211231-git-annex-standalone_8.20211231-1.ndall+1_amd64.deb-49966540]
====== 1 failed, 92 passed, 10 skipped, 1 xpassed in 1304.24s (0:21:44) =======
py: exit 1 (1305.80 seconds) D:\a\datalad-installer\datalad-installer> pytest -vv --ci --cov-report=xml test pid=1188
.pkg: _exit> python C:\hostedtoolcache\windows\Python\3.11.2\x64\Lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta
  py: FAIL code 1 (1332.36=setup[26.56]+cmd[1305.80] seconds)
  evaluation failed :( (1332.67 seconds)
Error: Process completed with exit code 1.

Making a record to see if we run into it again.

yarikoptic commented 1 year ago

From all looks it happened again but now in ubuntu environment https://ci.appveyor.com/project/mih/datalad/builds/46630717/job/luwc0638irf4wb3g

[ -n "${INSTALL_GITANNEX}" ] && datalad-installer --sudo ok ${INSTALL_GITANNEX}
2023-03-28T15:09:22+0000 [INFO    ] datalad_installer Writing environment modifications to /home/appveyor/DLTMP/dl-env-ireh1b5s.sh
2023-03-28T15:09:22+0000 [INFO    ] datalad_installer Installing git-annex via deb-url
2023-03-28T15:09:22+0000 [INFO    ] datalad_installer URL: http://snapshot.debian.org/archive/debian/20210906T204127Z/pool/main/g/git-annex/git-annex_8.20210903-1_amd64.deb
2023-03-28T15:09:22+0000 [INFO    ] datalad_installer Extra args: None
2023-03-28T15:09:22+0000 [INFO    ] datalad_installer Downloading http://snapshot.debian.org/archive/debian/20210906T204127Z/pool/main/g/git-annex/git-annex_8.20210903-1_amd64.deb
2023-03-28T15:12:12+0000 [INFO    ] datalad_installer Running: sudo dpkg -i /home/appveyor/DLTMP/tmp_yul8d7_/git-annex.deb
Selecting previously unselected package git-annex.
(Reading database ... 306255 files and directories currently installed.)
Preparing to unpack .../tmp_yul8d7_/git-annex.deb ...
Unpacking git-annex (8.20210903-1) ...
dpkg-deb (subprocess): cannot copy archive member from '/home/appveyor/DLTMP/tmp_yul8d7_/git-annex.deb' to decompressor pipe: unexpected end of file or stream
dpkg-deb (subprocess): decompressing archive member: lzma error: unexpected end of input
dpkg-deb: error: <decompress> subprocess returned error exit status 2
dpkg: error processing archive /home/appveyor/DLTMP/tmp_yul8d7_/git-annex.deb (--install):
 cannot copy extracted data for './usr/bin/git-annex' to '/usr/bin/git-annex.dpkg-new': unexpected end of file or stream
Errors were encountered while processing:
 /home/appveyor/DLTMP/tmp_yul8d7_/git-annex.deb
Traceback (most recent call last):
  File "/home/appveyor/dlvenv/bin/datalad-installer", line 8, in <module>
    sys.exit(main())
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 1788, in main
    return manager.main(argv)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 657, in main
    self.addcomponent(name=cr.name, **cr.kwargs)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 690, in addcomponent
    component(self).provide(**kwargs)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 1032, in provide
    bins = self.get_installer(method).install(self.NAME, **kwargs)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 1118, in install
    bindir = self.install_package(package, **kwargs)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 1391, in install_package
    self.manager.sudo(*cmd)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 576, in sudo
    return runcmd("sudo", *args, **kwargs)
  File "/home/appveyor/dlvenv/lib/python3.8/site-packages/datalad_installer.py", line 1756, in runcmd
    return subprocess.run(arglist, check=True, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sudo', 'dpkg', '-i', '/home/appveyor/DLTMP/tmp_yul8d7_/git-annex.deb']' returned non-zero exit status 1.

can we add explicit "get size" via HEAD request, test for size and if downloaded size does not match -- cause it to retry @jwodder ? or do you see some other reason this might happen?