Skip to content

Commit 6d6e22a

Browse files
[8.18] (backport #8605) [Synthetics] Add e2e test for synthetics deps in complete variants (#8678)
* [Synthetics] Add e2e test for synthetics deps in complete variants (#8605) * Add docker integration test for synthetics deps (cherry picked from commit f8c1f2e) # Conflicts: # dev-tools/packaging/package_test.go * Fix merge conflicts --------- Co-authored-by: Emilio Alvarez Piñeiro <[email protected]> Co-authored-by: emilioalvap <[email protected]>
1 parent 10b12af commit 6d6e22a

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

dev-tools/packaging/package_test.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func checkNpcapNotices(pkg, file string, contents io.Reader) error {
303303
}
304304

305305
func checkDocker(t *testing.T, file string) {
306-
p, info, err := readDocker(file)
306+
p, info, err := readDocker(file, true)
307307
if err != nil {
308308
t.Errorf("error reading file %v: %v", file, err)
309309
return
@@ -319,6 +319,19 @@ func checkDocker(t *testing.T, file string) {
319319
checkModulesDPresent(t, "", p)
320320
checkHintsInputsD(t, "hints.inputs.d", hintsInputsDFilePattern, p)
321321
checkLicensesPresent(t, "licenses/", p)
322+
323+
if strings.Contains(file, "-complete") {
324+
checkCompleteDocker(t, file)
325+
}
326+
}
327+
328+
func checkCompleteDocker(t *testing.T, file string) {
329+
p, _, err := readDocker(file, false)
330+
if err != nil {
331+
t.Errorf("error reading file %v: %v", file, err)
332+
}
333+
334+
checkSyntheticsDeps(t, "usr", p)
322335
}
323336

324337
// Verify that the main configuration file is installed with a 0600 file mode.
@@ -533,6 +546,23 @@ func checkLicensesPresent(t *testing.T, prefix string, p *packageFile) {
533546
}
534547
}
535548

549+
func checkSyntheticsDeps(t *testing.T, prefix string, p *packageFile) {
550+
syntheticsDeps := []string{"node", "npm", "elastic-synthetics", "chrome"}
551+
for _, dep := range syntheticsDeps {
552+
t.Run("Binary file "+dep, func(t *testing.T) {
553+
for _, entry := range p.Contents {
554+
if strings.HasPrefix(entry.File, prefix) && strings.HasSuffix(entry.File, "/"+dep) {
555+
return
556+
}
557+
}
558+
if prefix != "" {
559+
t.Fatalf("%s not found under %s", dep, prefix)
560+
}
561+
t.Fatal("not found")
562+
})
563+
}
564+
}
565+
536566
func checkDockerEntryPoint(t *testing.T, p *packageFile, info *dockerInfo) {
537567
expectedMode := os.FileMode(0755)
538568

@@ -848,7 +878,7 @@ func openZip(zipFile string) (*zip.ReadCloser, error) {
848878
return r, nil
849879
}
850880

851-
func readDocker(dockerFile string) (*packageFile, *dockerInfo, error) {
881+
func readDocker(dockerFile string, filterWorkingDir bool) (*packageFile, *dockerInfo, error) {
852882
// Read the manifest file first so that the config file and layer
853883
// names are known in advance.
854884
manifest, err := getDockerManifest(dockerFile)
@@ -915,7 +945,7 @@ func readDocker(dockerFile string) (*packageFile, *dockerInfo, error) {
915945
continue
916946
}
917947
// Check only files in working dir and entrypoint
918-
if strings.HasPrefix("/"+name, workingDir) || "/"+name == entrypoint {
948+
if !filterWorkingDir || strings.HasPrefix("/"+name, workingDir) || "/"+name == entrypoint {
919949
p.Contents[name] = entry
920950
}
921951
// Add also licenses

0 commit comments

Comments
 (0)