Skip to content

fix(test): use local apt repo with fake packages to avoid flakiness in TestExtraPackages - #8323

Merged
rfay merged 3 commits into
ddev:mainfrom
stasadev:20260416_stasadev_test_extra_packages
Apr 16, 2026
Merged

fix(test): use local apt repo with fake packages to avoid flakiness in TestExtraPackages#8323
rfay merged 3 commits into
ddev:mainfrom
stasadev:20260416_stasadev_test_extra_packages

Conversation

@stasadev

@stasadev stasadev commented Apr 16, 2026

Copy link
Copy Markdown
Member

The Issue

  • Refs https://github.com/ddev/ddev/actions/runs/24502796076/job/71627009789
      > [db 4/4] RUN (timeout 120 apt-get update || true) && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests sudo:
     123.9 Need to get 998 kB of archives.
     123.9 After this operation, 3669 kB of additional disk space will be used.
     123.9 Err:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libapparmor1 amd64 4.0.1really4.0.1-0ubuntu0.24.04.5
     123.9   404  Not Found [IP: 91.189.91.83 80]
     123.9 Ign:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 sudo amd64 1.9.15p5-3ubuntu5.24.04.1
     127.8 Err:2 http://security.ubuntu.com/ubuntu noble-updates/main amd64 sudo amd64 1.9.15p5-3ubuntu5.24.04.1
     127.8   404  Not Found [IP: 91.189.91.83 80]
     127.8 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apparmor/libapparmor1_4.0.1really4.0.1-0ubuntu0.24.04.5_amd64.deb  404  Not Found [IP: 91.189.91.83 80]
     127.8 E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/s/sudo/sudo_1.9.15p5-3ubuntu5.24.04.1_amd64.deb  404  Not Found [IP: 91.189.91.83 80]
     127.8 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
     ------
     ', stderr=' Image ddev/ddev-dbserver-mariadb-11.8:v1.25.1-TestPkgDrupal11-built Building 
      Image ddev/ddev-webserver:20260410_stasadev_yarn_timeout-TestPkgDrupal11-built Building 
     Dockerfile:25
    
  • When upstream Debian/Ubuntu apt repositories are down (e.g. https://status.canonical.com/#/incident/KNms6QK9ewuzz-7xUsPsNylV20jEt5kyKsd8A-3ptQG-0Dp5D6IWR-Dw5G2pjG-aXrj_4QfzB2lRNFJhfuReyQ== incident), TestExtraPackages fails because it tries to install real packages (sudo, bind9-dnsutils) from the network during the Docker image build.

How This PR Solves The Issue

A pre.Dockerfile.fake-ddev-test is written to web-build/ and db-build/ before the test starts. It runs inside the container build after FROM $BASE_IMAGE but before the injected apt-get install step.

The Dockerfile fragment uses dpkg-deb (part of the dpkg package, always present in Debian images — no network needed) to create minimal fake .deb packages and registers them as a local deb822 apt source (file:///var/local-apt-repo). When the extra_packages apt-get install runs it finds the packages locally regardless of external repo availability.

The test packages are renamed fake-ddev-test-sudo / fake-ddev-test-bind9-dnsutils so they cannot be mistaken for real system packages.

Manual Testing Instructions

Automated Testing Overview

Release/Deployment Notes

…n TestExtraPackages [skip buildkite]

## The Issue

- Refs https://github.com/ddev/ddev/actions/runs/24502796076/job/71627009789
- When upstream Debian/Ubuntu apt repositories are down (e.g. https://status.canonical.com incident), TestExtraPackages fails because it tries to install real packages (`sudo`, `bind9-dnsutils`) from the network during the Docker image build.

## How This PR Solves The Issue

A `pre.Dockerfile.fake-ddev-test` is written to `web-build/` and `db-build/` before the test starts. It runs inside the container build after `FROM $BASE_IMAGE` but before the injected `apt-get install` step.

The Dockerfile fragment uses `dpkg-deb` (part of the `dpkg` package, always present in Debian images — no network needed) to create minimal fake `.deb` packages and registers them as a local deb822 apt source (`file:///var/local-apt-repo`). When the extra_packages `apt-get install` runs it finds the packages locally regardless of external repo availability.

The test packages are renamed `fake-ddev-test-sudo` / `fake-ddev-test-bind9-dnsutils` so they cannot be mistaken for real system packages. A latent bug is also fixed: the post-install `command -v` check was hardcoded to `sudo` instead of using the `addedDBPackage` variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stasadev
stasadev requested a review from a team as a code owner April 16, 2026 14:01

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice idea, completely safe, great step forward, thanks!

@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is test-only, and a good idea, and it passed the key tests. I'm going to go aheaad and pull it. I think the Canonical archive problem is over, but we have lots of tests to fix.

@rfay
rfay merged commit 54b9a06 into ddev:main Apr 16, 2026
31 of 36 checks passed
@rfay
rfay deleted the 20260416_stasadev_test_extra_packages branch April 16, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants