Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions dev-tools/packaging/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
}

func checkDocker(t *testing.T, file string) {
p, info, err := readDocker(file)
p, info, err := readDocker(file, true)
if err != nil {
t.Errorf("error reading file %v: %v", file, err)
return
Expand All @@ -300,6 +300,19 @@
checkModulesPresent(t, "", p)
checkModulesDPresent(t, "", 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.
Expand Down Expand Up @@ -499,6 +512,23 @@
}
}

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)

Expand Down Expand Up @@ -713,7 +743,7 @@
File: header.Name,
UID: header.Uid,
GID: header.Gid,
Mode: os.FileMode(header.Mode),

Check failure on line 746 in dev-tools/packaging/package_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int64 -> uint32 (gosec)

Check failure on line 746 in dev-tools/packaging/package_test.go

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

G115: integer overflow conversion int64 -> uint32 (gosec)
}
}

Expand Down Expand Up @@ -765,7 +795,7 @@
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)
Expand Down Expand Up @@ -832,7 +862,7 @@
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
Expand Down
Loading