@@ -82,8 +82,10 @@ const (
8282 envDockerImage = "DOCKER_IMAGE"
8383 // envDockerTag is used to indicate tag for images produced by the docker:image target. Defaults to version. It
8484 envDockerTag = "DOCKER_IMAGE_TAG"
85- // envDockerBaseImage is the image:tag for the base elastic-agent-cloud images used by e2e tests.
85+ // envDockerBaseImage is the base image for elastic-agent-cloud images used by e2e tests.
8686 envDockerBaseImage = "DOCKER_BASE_IMAGE"
87+ // envDockerBaseImageTag is the tag for the base image used by e2e tests.
88+ envDockerBaseImageTag = "DOCKER_BASE_IMAGE_TAG"
8789)
8890
8991// const and vars used by magefile.
@@ -997,12 +999,17 @@ func (Docker) Image() error {
997999
9981000// Push pushs an image created by docker:image to the registry.
9991001// FIPS may be used to push a FIPS capable image.
1002+ // DOCKER_IMAGE may be used to specify the image name.
10001003// DOCKER_IMAGE_TAG may be used to specify the image tag.
10011004func (Docker ) Push () error {
10021005 image := dockerImage
10031006 if isFIPS () {
10041007 image += "-fips"
10051008 }
1009+ if v , ok := os .LookupEnv (envDockerImage ); ok && v != "" {
1010+ image = v
1011+ }
1012+
10061013 version := getVersion ()
10071014 if v , ok := os .LookupEnv (envDockerTag ); ok && v != "" {
10081015 version = v
@@ -1015,6 +1022,7 @@ func (Docker) Push() error {
10151022// This step requires a coverage enabled binary to be used.
10161023// FIPS is used to control if a FIPS compliant image should be created.
10171024// DOCKER_BASE_IMAGE may be used to specify the elastic-agent base image. docker.elastic.co/cloud-release/elastic-agent-cloud by default.
1025+ // DOCKER_BASE_IMAGE_TAG may be used to specify the elastic-agent base image tag. Uses the ELASTICESRCH version from dev-tools/integration/.env.
10181026// DOCKER_IMAGE is used to specify the resulting image name.
10191027// DOCKER_IMAGE_TAG is used to specify the resulting image tag.
10201028func (Docker ) CustomAgentImage () error {
@@ -1023,16 +1031,21 @@ func (Docker) CustomAgentImage() error {
10231031 return fmt .Errorf ("unable to read env file: %w" , err )
10241032 }
10251033
1026- baseImage := "docker.elastic.co/cloud-release/elastic-agent-cloud:" + env [ "ELASTICSEARCH_VERSION" ]
1034+ baseImage := "docker.elastic.co/cloud-release/elastic-agent-cloud"
10271035 if v , ok := os .LookupEnv (envDockerBaseImage ); ok && v != "" {
10281036 baseImage = v
10291037 }
1038+ baseImageTag := env ["ELASTICSEARCH_VERSION" ]
1039+ if v , ok := os .LookupEnv (envDockerBaseImageTag ); ok && v != "" {
1040+ baseImageTag = v
1041+ }
1042+
10301043 dockerEnv := map [string ]string {"DOCKER_BUILDKIT" : "1" }
1031- err = sh .RunWithV (dockerEnv , "docker" , "pull" , "--platform" , "linux/" + runtime .GOARCH , baseImage )
1044+ err = sh .RunWithV (dockerEnv , "docker" , "pull" , "--platform" , "linux/" + runtime .GOARCH , baseImage + ":" + baseImageTag )
10321045 if err != nil {
10331046 return fmt .Errorf ("failed to pull image: %w" , err )
10341047 }
1035- vcsRef , err := sh .OutputWith (dockerEnv , "docker" , "inspect" , "-f" , "{{index .Config.Labels \" org.label-schema.vcs-ref\" }}" , baseImage )
1048+ vcsRef , err := sh .OutputWith (dockerEnv , "docker" , "inspect" , "-f" , "{{index .Config.Labels \" org.label-schema.vcs-ref\" }}" , baseImage + ":" + baseImageTag )
10361049 if err != nil {
10371050 return fmt .Errorf ("unable to find vcs-ref label: %w" , err )
10381051 }
@@ -1050,7 +1063,7 @@ func (Docker) CustomAgentImage() error {
10501063 }
10511064 err = sh .RunWithV (dockerEnv , "docker" , "build" ,
10521065 "-f" , filepath .Join ("dev-tools" , "e2e" , "Dockerfile" ),
1053- "--build-arg" , "ELASTIC_AGENT_IMAGE=" + baseImage ,
1066+ "--build-arg" , "ELASTIC_AGENT_IMAGE=" + baseImage + ":" + baseImageTag ,
10541067 "--build-arg" , "STACK_VERSION=" + getVersion (),
10551068 "--build-arg" , "VCS_REF_SHORT=" + vcsRef [:6 ],
10561069 "--build-arg" , "FLEET_FIPS=" + fips ,
@@ -2027,6 +2040,7 @@ func (Test) CloudE2E() {
20272040// DOCKER_IMAGE can be used to specify the custom integration server image.
20282041// DOCKER_IMAGE_TAG can be used to specify the tag of the custom integration server.
20292042func (Test ) CloudE2EUp () error {
2043+ os .Setenv (envSnapshot , "true" )
20302044 imageName := dockerImage
20312045 imageTag := getVersion ()
20322046
@@ -2081,16 +2095,35 @@ func (Test) CloudE2EDown() error {
20812095
20822096// CloudE2ERun runs tests against the remote cloud deployment.
20832097func (Test ) CloudE2ERun () error {
2084- url , err := sh .Output ("terraform" , "output" , "--raw" , "--state=" + filepath .Join ("dev-tools" , "cloud" , "terraform" , "terraform.tfstate" ), "fleet_url" )
2098+ fleetURL , err := sh .Output ("terraform" , "output" , "--raw" , "--state=" + filepath .Join ("dev-tools" , "cloud" , "terraform" , "terraform.tfstate" ), "fleet_url" )
20852099 if err != nil {
20862100 return fmt .Errorf ("unable to retrive fleet-server cloud url: %w" , err )
20872101 }
20882102
2103+ kibanaURL , err := sh .Output ("terraform" , "output" , "--raw" , "--state=" + filepath .Join ("dev-tools" , "cloud" , "terraform" , "terraform.tfstate" ), "kibana_url" )
2104+ if err != nil {
2105+ return fmt .Errorf ("unable to retrive kibana cloud url: %w" , err )
2106+ }
2107+
2108+ user , err := sh .Output ("terraform" , "output" , "--raw" , "--state=" + filepath .Join ("dev-tools" , "cloud" , "terraform" , "terraform.tfstate" ), "elasticsearch_username" )
2109+ if err != nil {
2110+ return fmt .Errorf ("unable to retrive es username: %w" , err )
2111+ }
2112+ pass , err := sh .Output ("terraform" , "output" , "--raw" , "--state=" + filepath .Join ("dev-tools" , "cloud" , "terraform" , "terraform.tfstate" ), "elasticsearch_password" )
2113+ if err != nil {
2114+ return fmt .Errorf ("unable to retrive es password: %w" , err )
2115+ }
2116+
20892117 var b bytes.Buffer
20902118 w := io .MultiWriter (& b , os .Stdout )
20912119 cmd := exec .Command ("go" , "test" , "-v" , "-timeout" , "30m" , "-tags=cloude2e" , "-count=1" , "-p" , "1" , "./..." )
20922120 cmd .Dir = "testing"
2093- cmd .Env = append (os .Environ (), "FLEET_SERVER_URL=" + url )
2121+ cmd .Env = append (os .Environ (),
2122+ "FLEET_SERVER_URL=" + fleetURL ,
2123+ "KIBANA_URL=" + kibanaURL ,
2124+ "ELASTIC_USER=" + user ,
2125+ "ELASTIC_PASS=" + pass ,
2126+ )
20942127 cmd .Stdout = w
20952128 cmd .Stderr = w
20962129 err = cmd .Run ()
0 commit comments