lifecycle icon indicating copy to clipboard operation
lifecycle copied to clipboard

Make Detector tests work on Windows

Open natalieparellano opened this issue 5 years ago • 6 comments

Currently, the acceptance tests don't work on Windows. We should fix that!

Known issues with analyzer acceptance tests (https://github.com/buildpacks/lifecycle/pull/319):

  • Can't connect to insecure registry. Because --network host does not work on Windows, the analyzer (running in a container) will need to access the test registry via the registry's container IP + port 5000. But, the test registry is an insecure registry, and the docker daemon will not allow this unless it has been explicitly configured to trust the registry at that IP. According to here, we aren't able to configure the docker daemon in a GHA action runner. A self-hosted runner may be necessary.
  • Can't seed docker volume via a stopped container. For the tests that use a cache directory, we need a way to create a docker volume and seed it with the cache directory fixture contents. The current recommendation for how to do this is to use an intermediary container. This approach does not work on Windows. There are two options (copied from Slack): 1.) docker cp into the stopped container in a non-volume mount path, then start the container with a command to copy from the non-volume path to the volume path 2) Stream the content into the container with something like a tar -c -f- my-stuff | docker run -v my-vol:c:/vol img tar.exe -x -f- -C c:/vol

Other needed things:

  • Convert paths to Windows paths if running on Windows (e.g., /some/path -> C:\some\path)
  • Convert mount target paths to Windows paths if running on Windows (e.g., /some/target -> C:/some/target)
  • Add the Windows equivalent to acceptance/variables/variables.go:
package variables

const (
	ContainerBaseImage = "mcr.microsoft.com/windows/nanoserver:1809"
	DockerfileName     = "Dockerfile.windows"
	VolumeHelperImage  = "mcr.microsoft.com/windows/nanoserver:1809"
)

var DummyCommand = []string{"cmd", "/c", "dir"}

var DockerSocketMount = []string{
	"--volume", "\\\\.\\pipe\\docker_engine:\\\\.\\pipe\\docker_engine",
	"--user", "ContainerAdministrator",
}
  • Add the Windows equivalent to acceptance/testdata/analyzer/analyze-image/Dockerfile:
FROM mcr.microsoft.com/windows/nanoserver:1809

COPY container /

WORKDIR /layers

ENV CNB_USER_ID=2222

ENV CNB_GROUP_ID=3333

natalieparellano avatar Jul 16 '20 21:07 natalieparellano

I think this issue should cover making all acceptance tests run on Windows.

yaelharel avatar Aug 12 '20 13:08 yaelharel

#524 may be able to assist with the first bullet point here if the non-daemon case is used.

jromero avatar Feb 09 '21 22:02 jromero

@jromero why not add templates for new APIs in advance of support in all suggested builders? Users can still choose an older API template right?

ekcasey avatar Feb 16 '21 19:02 ekcasey

@jromero why not add templates for new APIs in advance of support in all suggested builders? Users can still choose an older API template right?

Not sure I understand the question in relation to this issue. In what context should I be thinking about these questions?

jromero avatar Feb 16 '21 19:02 jromero

@jromero I failed at tabs and posted that in the wrong issue I think, apologies

ekcasey avatar Feb 18 '21 15:02 ekcasey

Updated issue title as we currently have a PR to add Windows support to Analyzer acceptance tests.

natalieparellano avatar Mar 23 '21 16:03 natalieparellano