Skip to content

Commit

Permalink
Create tmp dir in scratch docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
crobert-1 committed Jul 19, 2023
1 parent 8977299 commit 7670fff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cmd/otelcol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ COPY --from=otelcol --chown=999 /otel/collector /etc/otel/collector
COPY --from=agent-bundle --chown=999 /usr/lib/splunk-otel-collector /usr/lib/splunk-otel-collector
COPY --from=jmx --chown=999 /tmp/opentelemetry-jmx-metrics.jar /opt/opentelemetry-java-contrib-jmx-metrics.jar

COPY --from=otelcol --chown=999 /tmp /tmp
ENV TMPDIR=/tmp

COPY --from=journalctl --chown=999 /bin/journalctl /bin/journalctl
COPY --from=journalctl --chown=999 /opt/journalctl /

Expand Down
20 changes: 7 additions & 13 deletions tests/receivers/jmxreceiver/jmxreceiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
package tests

import (
"os"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"

"github.com/signalfx/splunk-otel-collector/tests/testutils"
)

Expand All @@ -35,12 +31,12 @@ func TestJMXReceiverProvidesAllJVMMetrics(t *testing.T) {
).WithExposedPorts("7199:7199").WithName("jmx").WillWaitForPorts("7199"),
}

tmp_dir := "/etc/otel/collector/tmp"
local_tmp := filepath.Join(".", "tmp")
mount_dir, err := filepath.Abs(local_tmp)
require.NoError(t, err)
os.MkdirAll(mount_dir, 1777)
defer os.RemoveAll(local_tmp)
//tmp_dir := "/etc/otel/collector/tmp"
//local_tmp := filepath.Join(".", "tmp")
//mount_dir, err := filepath.Abs(local_tmp)
//require.NoError(t, err)
//os.MkdirAll(mount_dir, 1777)
//defer os.RemoveAll(local_tmp)

testutils.AssertAllMetricsReceived(t, "all.yaml",
"all_metrics_config.yaml", containers,
Expand All @@ -49,9 +45,7 @@ func TestJMXReceiverProvidesAllJVMMetrics(t *testing.T) {
// JMX requires a local directory that can be written to, so we must mount a local dir
// that the collector has write access to.

return collector.WithEnv(map[string]string{
"TMPDIR": tmp_dir,
}).WithMount(mount_dir, tmp_dir).WillFail(true)
return collector.WillFail(true)
},
})
}

0 comments on commit 7670fff

Please sign in to comment.