Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End to end tests in Golang #951

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
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
865 changes: 774 additions & 91 deletions functional_tests/functional_test.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions functional_tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/docker/docker v23.0.3+incompatible
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.86.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.86.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver v0.86.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/splunkhecreceiver v0.86.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.86.0
go.opentelemetry.io/collector/consumer v0.86.0
Expand All @@ -35,6 +37,7 @@ require (
github.com/Microsoft/hcsshim v0.11.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/containerd v1.7.6 // indirect
Expand All @@ -61,6 +64,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
Expand Down Expand Up @@ -105,6 +109,9 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/mostynb/go-grpc-compression v1.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.86.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk v0.86.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx v0.86.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -118,6 +125,7 @@ require (
github.com/rubenv/sql-migrate v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
Expand All @@ -138,9 +146,11 @@ require (
go.opentelemetry.io/collector/config/configtls v0.86.0 // indirect
go.opentelemetry.io/collector/config/internal v0.86.0 // indirect
go.opentelemetry.io/collector/confmap v0.86.0 // indirect
go.opentelemetry.io/collector/exporter v0.86.0 // indirect
go.opentelemetry.io/collector/extension v0.86.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.86.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0015 // indirect
go.opentelemetry.io/collector/semconv v0.86.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect
go.opentelemetry.io/otel v1.18.0 // indirect
Expand Down
29 changes: 29 additions & 0 deletions functional_tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuP
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
Expand Down Expand Up @@ -740,6 +742,7 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
Expand Down Expand Up @@ -964,6 +967,7 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o=
Expand Down Expand Up @@ -1047,11 +1051,26 @@ github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnu
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.86.0 h1:LjDMbehWLH+t6fkp6uQdpiu9sc3XgyG9Wjve4qV+wOU=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter v0.86.0 h1:xqoxs6rG6G+klvzEyeEo0T35V0GFC900zJANj8sFJjM=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.86.0 h1:g7HlND105lwm7NW8JCxAfbpaFyk1WKcEUUVwchIo9zE=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.86.0 h1:HEuJ7hCbLVfoL7xLrGQ2QORvocyFfWuaoDuzyTLwTdc=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.86.0 h1:S6b7ToTSFZvVzcabjqoUBqAwair7YuELvBS6mOAopHs=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.86.0/go.mod h1:aLQB8gu7vJ1lokUeWoZs9ExpduamPrD3oRbDk7hNg/g=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk v0.86.0 h1:hPwD5f77ZFaXgbX1/HwB5xcHCdPSbEUaz72Vy9ttxSs=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk v0.86.0/go.mod h1:yALAKkORvMeaaMGFhKIzuHGPdDCjEpBahWL+zTxfCuc=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchperresourceattr v0.86.0 h1:2/KuYugX/jjjj+KRvKKVDwTuTPrSEnZUsznnmFobP34=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata v0.86.0 h1:c0YrPA9p78Sqm3QWW5OFAuajdTWbTwVvawdvL1hbxvA=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.86.0 h1:EzGSvuCXAsGpwgeieTVcy1gs0hOlPidhFPcvwcPEU8s=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.86.0/go.mod h1:EL62K0jwPFXa3uxYeYMZGS1TSLR6AdGHRvM7RnRlosY=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.86.0 h1:xt/YvYpgssWk2Ix2C9SSXrILIzRqyWe+r5RE348m1fE=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.86.0/go.mod h1:fjK1kn7PIDP+TqOIFVEth3w0Eiexx5jIk411c//fYkM=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx v0.86.0 h1:qR/wCuXENMydERtUBpTMCDuQIkGA+x2zh8vUy+bOGq0=
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx v0.86.0/go.mod h1:yrtyAYeuyUdaP6xfywqu1XPtkWqq3vlpUvNX3YSEL8Y=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver v0.86.0 h1:6dKEwMkm/hxwxPQy4ClVArX2QL8Vuj5fHSgVB6iTNVY=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver v0.86.0/go.mod h1:M6s2jpCHtoqS2DS/PNbuiJ1yy2edZ3lX2gyDajIwsRY=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/splunkhecreceiver v0.86.0 h1:0e9nClcszdZjBScBkYHY92ejuSZDzfB/XbUexskUfL0=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/splunkhecreceiver v0.86.0/go.mod h1:XIb6MhFQ4wK1WlTFZcB8ywuaYl7MXIak/JQwmchYrEY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0=
Expand All @@ -1078,6 +1097,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down Expand Up @@ -1126,9 +1146,13 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 h1:32k2QLgsKhcEs55q4REPKyIadvid5FPy2+VMgvbmKJ0=
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3/go.mod h1:gJrXWi7wSGXfiC7+VheQaz+ypdCt5SmZNL+BRxUe7y4=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
Expand Down Expand Up @@ -1161,6 +1185,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand All @@ -1175,6 +1201,7 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI=
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE=
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY=
Expand Down Expand Up @@ -1215,6 +1242,7 @@ go.opentelemetry.io/collector/confmap v0.86.0/go.mod h1:vJms49x98lXUR7Mj6/28eXV+
go.opentelemetry.io/collector/consumer v0.86.0 h1:8AL9I30tJV01KfcSaa+8DTiARIiUDA8o2p7yQoSFUCs=
go.opentelemetry.io/collector/consumer v0.86.0/go.mod h1:SvoV1eto4VZzQ3ILKQ1rv4qgN8rUMJqupn78hoXLHRw=
go.opentelemetry.io/collector/exporter v0.86.0 h1:LFmBb7S4Fkj5fv/nrUkLOy50GT6s4R/BLrv6uTb+GNo=
go.opentelemetry.io/collector/exporter v0.86.0/go.mod h1:+PKZrFV4sVgS2TVFnfZ+RCJqXexEENjW1riWaqkxsN4=
go.opentelemetry.io/collector/extension v0.86.0 h1:oXnZarkh1aBgnr/U3JSj/lPpBJUquOQ3DHMXXP4Jacc=
go.opentelemetry.io/collector/extension v0.86.0/go.mod h1:EPAloXQ+48577GvHTP5wGDvV4OyHPuldvM+2rYbM/fw=
go.opentelemetry.io/collector/extension/auth v0.86.0 h1:VwKbeElL8sBnvRDC565EWOw4ixMG/t0oXjIphNsRszU=
Expand All @@ -1229,6 +1257,7 @@ go.opentelemetry.io/collector/receiver v0.86.0/go.mod h1:oFpofH/OG4HqmaVsb8ftnIA
go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0 h1:Iv6q/11whpWUVmnC2cyZOlhhCzlQK+SkJQfsQcxa13E=
go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0/go.mod h1:dHh1SnS0BKxbZF+9+xeWTwI7CbQVzGHfzt4LYMIGYNE=
go.opentelemetry.io/collector/semconv v0.86.0 h1:bLlPe/JYNjQHo744cqi7iIEybuLv+M5DntUwQPTrvZo=
go.opentelemetry.io/collector/semconv v0.86.0/go.mod h1:j/8THcqVxFna1FpvA2zYIsUperEtOaRaqoLYIN4doWw=
go.opentelemetry.io/collector/service v0.86.0 h1:vyoynxNY2Oc6XET2ZvFkRC+Fpc1oMl9qQkORyX5LoWg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0 h1:b8xjZxHbLrXAum4SxJd1Rlm7Y/fKaB+6ACI7/e5EfSA=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0/go.mod h1:1ei0a32xOGkFoySu7y1DAHfcuIhC0pNZpvY2huXuMy4=
Expand Down
34 changes: 34 additions & 0 deletions functional_tests/internal/api_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package internal

import (
"context"
"errors"
"fmt"
"net/http"
"testing"

"github.com/stretchr/testify/require"
)

func CreateApiServer(t *testing.T, port int) {
mux := http.NewServeMux()
mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(200)
})

_, cancelCtx := context.WithCancel(context.Background())
s := &http.Server{
Addr: fmt.Sprintf("0.0.0.0:%d", port),
Handler: mux,
}

t.Cleanup(func() {
cancelCtx()
})

go func() {
if err := s.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
require.NoError(t, err)
}
}()
}
39 changes: 39 additions & 0 deletions functional_tests/internal/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -93,3 +94,41 @@ func writeLogs(filePath string, logs plog.Logs) error {
}
return os.WriteFile(filePath, b, 0600)
}

// WriteTraces writes a ptrace.Traces to the specified file in YAML format.
func WriteTraces(t *testing.T, filePath string, traces ptrace.Traces) error {
if err := writeTraces(filePath, traces); err != nil {
return err
}
t.Logf("Golden file successfully written to %s.", filePath)
t.Log("NOTE: The WriteLogs call must be removed in order to pass the test.")
t.Fail()
return nil
}

func marshalTraces(traces ptrace.Traces) ([]byte, error) {
marshaler := &ptrace.JSONMarshaler{}
fileBytes, err := marshaler.MarshalTraces(traces)
if err != nil {
return nil, err
}
var jsonVal map[string]interface{}
if err = json.Unmarshal(fileBytes, &jsonVal); err != nil {
return nil, err
}
b := &bytes.Buffer{}
enc := yaml.NewEncoder(b)
enc.SetIndent(2)
if err := enc.Encode(jsonVal); err != nil {
return nil, err
}
return b.Bytes(), nil
}

func writeTraces(filePath string, traces ptrace.Traces) error {
b, err := marshalTraces(traces)
if err != nil {
return err
}
return os.WriteFile(filePath, b, 0600)
}
Loading
Loading