func (m *MetricsTestCase) LoadOTLPMetricsInput(
	t testing.TB,
	startTime time.Time,
	endTime time.Time,
) pdata.Metrics {
	bytes, err := ioutil.ReadFile(m.OTLPInputFixturePath)
	require.NoError(t, err)
	metrics, err := otlp.NewJSONMetricsUnmarshaler().UnmarshalMetrics(bytes)
	require.NoError(t, err)
	for i := 0; i < metrics.ResourceMetrics().Len(); i++ {
		rm := metrics.ResourceMetrics().At(i)
		for i := 0; i < rm.InstrumentationLibraryMetrics().Len(); i++ {
			rmi := rm.InstrumentationLibraryMetrics().At(i)
			for i := 0; i < rmi.Metrics().Len(); i++ {
				m := rmi.Metrics().At(i)
				points := []point{}
				switch m.DataType() {
				case pdata.MetricDataTypeGauge:
					for i := 0; i < m.Gauge().DataPoints().Len(); i++ {
						points = append(points, m.Gauge().DataPoints().At(i))
					}
				case pdata.MetricDataTypeSum:
					for i := 0; i < m.Sum().DataPoints().Len(); i++ {
						points = append(points, m.Sum().DataPoints().At(i))
					}
				case pdata.MetricDataTypeHistogram:
					for i := 0; i < m.Histogram().DataPoints().Len(); i++ {
						points = append(points, m.Histogram().DataPoints().At(i))
					}
				case pdata.MetricDataTypeSummary:
					for i := 0; i < m.Summary().DataPoints().Len(); i++ {
						points = append(points, m.Summary().DataPoints().At(i))
					}
				}
				for _, p := range points {
					if p.StartTimestamp() != 0 {
						p.SetStartTimestamp(pdata.NewTimestampFromTime(startTime))
					}
					if p.Timestamp() != 0 {
						p.SetTimestamp(pdata.NewTimestampFromTime(endTime))
					}
				}
			}
		}
	}
	return metrics
}
Load OTLP metric fixture, test expectation fixtures and modify them so they're suitable for
testing. Currently, this just updates the timestamps.
package integrationtest
import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"testing"
	"time"
	"github.com/stretchr/testify/require"
	"go.opentelemetry.io/collector/model/otlp"
	"go.opentelemetry.io/collector/model/pdata"
	"google.golang.org/protobuf/encoding/protojson"
	"google.golang.org/protobuf/types/known/timestamppb"
)
type point interface {
	StartTimestamp() pdata.Timestamp
	Timestamp() pdata.Timestamp
	SetStartTimestamp(pdata.Timestamp)
	SetTimestamp(pdata.Timestamp)
}
type MetricsTestCase struct {
	Name string
	OTLPInputFixturePath string
	ExpectFixturePath string
}