@@ -23,7 +23,6 @@ import (
23
23
"os"
24
24
"path/filepath"
25
25
"runtime"
26
- "strings"
27
26
"syscall"
28
27
"testing"
29
28
"time"
@@ -89,25 +88,24 @@ func jmxCassandraAutoDiscoveryHelper(t *testing.T, ctx context.Context, configFi
89
88
return nil , err
90
89
}
91
90
92
- var path string
93
- var mountPath string
94
- testDirName := "tests"
95
- if path , err = filepath .Abs ("." ); err == nil {
91
+ coverDest := os .Getenv ("CONTAINER_COVER_DEST" )
92
+ coverSrc := os .Getenv ("CONTAINER_COVER_SRC" )
93
+ var coverDirBind string
94
+ if coverSrc != "" && coverDest != "" {
95
+ coverDirBind = fmt .Sprintf ("%s:%s" , coverSrc , coverDest )
96
+
96
97
// Coverage should all be under the top-level `tests/coverage` dir that's mounted
97
98
// to the container. This string parsing logic is to ensure different sub-directory
98
99
// tests all put their coverage in the top-level directory.
99
- index := strings .Index (path , testDirName )
100
- mountPath = filepath .Join (path [0 :index + len (testDirName )], "coverage" )
101
- fmt .Printf ("PWD: %s, Container mount, source: %s, destination: %s\n " , path , mountPath , "/etc/otel/collector/coverage" )
102
- if fileStat , err := os .Stat (filepath .Join (path [0 :index + len (testDirName )], "coverage" )); err == nil {
100
+ fmt .Printf ("Container mount, source: %s, destination: %s\n " , coverSrc , coverDest )
101
+ if fileStat , err := os .Stat (coverSrc ); err == nil {
103
102
fmt .Printf ("Coverage dir from source stat succeeded, is dir? %v, mode: %v\n " , fileStat .IsDir (), fileStat .Mode ())
104
103
} else {
105
104
fmt .Printf ("coverdir stat err: %v\n " , err )
106
105
}
107
106
} else {
108
- fmt .Printf ("Container mount err: %v \n " , err )
107
+ fmt .Printf ("coversrc or coverdest not set" )
109
108
}
110
- coverDirBind := fmt .Sprintf ("%s:/etc/otel/collector/coverage" , mountPath )
111
109
112
110
currPath , err := filepath .Abs (filepath .Join ("." , "testdata" ))
113
111
if err != nil {
@@ -128,7 +126,7 @@ func jmxCassandraAutoDiscoveryHelper(t *testing.T, ctx context.Context, configFi
128
126
"SPLUNK_OTEL_COLLECTOR_IMAGE" : "otelcol:latest" ,
129
127
"USERNAME" : "hello" ,
130
128
"PASSWORD" : "world" ,
131
- "GOCOVERDIR" : "/etc/otel/collector/coverage" ,
129
+ "GOCOVERDIR" : coverDest ,
132
130
},
133
131
Entrypoint : []string {"/otelcol" , "--config" , "/home/otel-local-config.yaml" },
134
132
Files : []testcontainers.ContainerFile {
0 commit comments