diff --git a/dev-tools/packaging/testing/package_test.go b/dev-tools/packaging/testing/package_test.go index 0be4386a7d7..c2d96cc61ef 100644 --- a/dev-tools/packaging/testing/package_test.go +++ b/dev-tools/packaging/testing/package_test.go @@ -372,7 +372,7 @@ func checkNpcapNotices(pkg, file string, contents io.Reader) error { } func checkDocker(t *testing.T, file string, fipsPackage bool) { - p, info, err := readDocker(file) + p, info, err := readDocker(file, true) if err != nil { t.Errorf("error reading file %v: %v", file, err) return @@ -391,6 +391,19 @@ func checkDocker(t *testing.T, file string, fipsPackage bool) { checkModulesDPresent(t, "", p) checkHintsInputsD(t, "hints.inputs.d", hintsInputsDFilePattern, p) checkLicensesPresent(t, "licenses/", p) + + if strings.Contains(file, "-complete") { + checkCompleteDocker(t, file) + } +} + +func checkCompleteDocker(t *testing.T, file string) { + p, _, err := readDocker(file, false) + if err != nil { + t.Errorf("error reading file %v: %v", file, err) + } + + checkSyntheticsDeps(t, "usr", p) } // Verify that the main configuration file is installed with a 0600 file mode. @@ -605,6 +618,23 @@ func checkLicensesPresent(t *testing.T, prefix string, p *packageFile) { } } +func checkSyntheticsDeps(t *testing.T, prefix string, p *packageFile) { + syntheticsDeps := []string{"node", "npm", "elastic-synthetics", "chrome"} + for _, dep := range syntheticsDeps { + t.Run("Binary file "+dep, func(t *testing.T) { + for _, entry := range p.Contents { + if strings.HasPrefix(entry.File, prefix) && strings.HasSuffix(entry.File, "/"+dep) { + return + } + } + if prefix != "" { + t.Fatalf("%s not found under %s", dep, prefix) + } + t.Fatal("not found") + }) + } +} + func checkDockerEntryPoint(t *testing.T, p *packageFile, info *dockerInfo) { expectedMode := os.FileMode(0755) @@ -942,7 +972,7 @@ func openZip(zipFile string) (*zip.ReadCloser, error) { return r, nil } -func readDocker(dockerFile string) (*packageFile, *dockerInfo, error) { +func readDocker(dockerFile string, filterWorkingDir bool) (*packageFile, *dockerInfo, error) { // Read the manifest file first so that the config file and layer // names are known in advance. manifest, err := getDockerManifest(dockerFile) @@ -1009,7 +1039,7 @@ func readDocker(dockerFile string) (*packageFile, *dockerInfo, error) { continue } // Check only files in working dir and entrypoint - if strings.HasPrefix("/"+name, workingDir) || "/"+name == entrypoint { + if !filterWorkingDir || strings.HasPrefix("/"+name, workingDir) || "/"+name == entrypoint { p.Contents[name] = entry } // Add also licenses