Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/google.golang.org/grpc…
Browse files Browse the repository at this point in the history
…-1.68.0
  • Loading branch information
kruskall authored Nov 8, 2024
2 parents 2afb52d + bb272df commit 1ff4781
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 33 deletions.
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,11 @@ SOFTWARE

--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-libs
Version: v0.17.1
Version: v0.17.2
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].1/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].2/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ x-logging: &default-logging
services:
elasticsearch:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-8f0a2811-SNAPSHOT
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-6e0d547d-SNAPSHOT
ports:
- 9200:9200
healthcheck:
Expand Down Expand Up @@ -43,7 +43,7 @@ services:

kibana:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
image: docker.elastic.co/kibana/kibana:9.0.0-8f0a2811-SNAPSHOT
image: docker.elastic.co/kibana/kibana:9.0.0-6e0d547d-SNAPSHOT
ports:
- 5601:5601
healthcheck:
Expand All @@ -63,7 +63,7 @@ services:

metricbeat:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
image: docker.elastic.co/beats/metricbeat:9.0.0-8f0a2811-SNAPSHOT
image: docker.elastic.co/beats/metricbeat:9.0.0-6e0d547d-SNAPSHOT
environment:
ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]'
ELASTICSEARCH_USERNAME: "${KIBANA_ES_USER:-admin}"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/elastic/apm-data v1.14.1
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20241106142216-cf13781a6fca
github.com/elastic/elastic-agent-client/v7 v7.16.0
github.com/elastic/elastic-agent-libs v0.17.1
github.com/elastic/elastic-agent-libs v0.17.2
github.com/elastic/elastic-agent-system-metrics v0.11.3
github.com/elastic/gmux v0.3.2
github.com/elastic/go-docappender/v2 v2.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ github.com/elastic/elastic-agent-autodiscover v0.9.0 h1:+iWIKh0u3e8I+CJa3FfWe9h0
github.com/elastic/elastic-agent-autodiscover v0.9.0/go.mod h1:5iUxLHhVdaGSWYTveSwfJEY4RqPXTG13LPiFoxcpFd4=
github.com/elastic/elastic-agent-client/v7 v7.16.0 h1:yKGq2+CxAuW8Kh0EoNl202tqAyQKfBcPRawVKs2Jve0=
github.com/elastic/elastic-agent-client/v7 v7.16.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI=
github.com/elastic/elastic-agent-libs v0.17.1 h1:1MXoc1eHGE8hCdVJ9+qiGiZAGeHzT2QBVVzD/oxwqeU=
github.com/elastic/elastic-agent-libs v0.17.1/go.mod h1:5CR02awPrBr+tfmjBBK+JI+dMmHNQjpVY24J0wjbC7M=
github.com/elastic/elastic-agent-libs v0.17.2 h1:Wk2mzdyjC7TZNgXcIfht5r6nHbXP4uLEFNxAhIhhkLA=
github.com/elastic/elastic-agent-libs v0.17.2/go.mod h1:5CR02awPrBr+tfmjBBK+JI+dMmHNQjpVY24J0wjbC7M=
github.com/elastic/elastic-agent-system-metrics v0.11.3 h1:LDzRwP8kxvsYEtMDgMSKZs1TgPcSEukit+/EAP5Y28A=
github.com/elastic/elastic-agent-system-metrics v0.11.3/go.mod h1:saqLKe9fuyuAo6IADAnnuy1kaBI7VNlxfwMo8KzSRyQ=
github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA=
Expand Down
2 changes: 1 addition & 1 deletion systemtest/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var (
systemtestDir string
)

func init() {
func initContainers() {
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("could not locate systemtest directory")
Expand Down
2 changes: 1 addition & 1 deletion systemtest/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
Elasticsearch *espoll.Client
)

func init() {
func initElasticSearch() {
cfg := newElasticsearchConfig()
cfg.Username = adminElasticsearchUser
cfg.Password = adminElasticsearchPass
Expand Down
30 changes: 30 additions & 0 deletions systemtest/intake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
package systemtest_test

import (
"context"
"strings"
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/elastic/apm-server/systemtest"
"github.com/elastic/apm-server/systemtest/apmservertest"
Expand Down Expand Up @@ -73,3 +78,28 @@ func TestIntake(t *testing.T) {
}

}

func TestIntakeMalformed(t *testing.T) {
// Setup a custom ingest pipeline to test a malformed data ingestion.
r, err := systemtest.Elasticsearch.Ingest.PutPipeline(
"traces-apm@custom",
strings.NewReader(`{"processors":[{"set":{"field":"span.duration.us","value":"poison"}}]}`),
)
require.NoError(t, err)
require.False(t, r.IsError())
defer systemtest.Elasticsearch.Ingest.DeletePipeline("traces-apm@custom")
// Test malformed intake data.
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
srv := apmservertest.NewServerTB(t)
systemtest.CleanupElasticsearch(t)
response := systemtest.SendBackendEventsPayload(t, srv.URL, "../testdata/intake-v2/spans.ndjson")
_, err = systemtest.Elasticsearch.SearchIndexMinDocs(
ctx,
response.Accepted,
"traces-apm*",
nil,
espoll.WithTimeout(10*time.Second),
)
require.Error(t, err, "No traces should be indexed due to traces-apm@custom pipeline")
}
2 changes: 1 addition & 1 deletion systemtest/kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var (
IntegrationPackage *fleettest.Package
)

func init() {
func initKibana() {
kibanaConfig := apmservertest.DefaultConfig().Kibana
u, err := url.Parse(kibanaConfig.Host)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion systemtest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ import (

func TestMain(m *testing.M) {
log.Println("INFO: starting stack containers...")
initContainers()
if err := StartStackContainers(); err != nil {
log.Fatalf("failed to start stack containers: %v", err)
}

initElasticSearch()
initKibana()
initSettings()
initOTEL()
log.Println("INFO: running system tests...")
os.Exit(m.Run())
}
35 changes: 35 additions & 0 deletions systemtest/otlp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package systemtest

import "go.opentelemetry.io/otel"

var OtelErrors = make(chan error, 1)

func initOTEL() {
// otel.SetErrorHandler can only be called once per process.
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
if err == nil {
return
}
select {
case OtelErrors <- err:
default:
}
}))
}
20 changes: 2 additions & 18 deletions systemtest/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp"
semconv "go.opentelemetry.io/collector/semconv/v1.5.0"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
Expand All @@ -58,21 +57,6 @@ import (
"github.com/elastic/apm-tools/pkg/espoll"
)

var otelErrors = make(chan error, 1)

func init() {
// otel.SetErrorHandler can only be called once per process.
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
if err == nil {
return
}
select {
case otelErrors <- err:
default:
}
}))
}

func TestOTLPGRPCTraces(t *testing.T) {
systemtest.CleanupElasticsearch(t)
srv := apmservertest.NewServerTB(t)
Expand Down Expand Up @@ -623,7 +607,7 @@ func flushTracerProvider(ctx context.Context, tracerProvider *sdktrace.TracerPro
return err
}
select {
case err := <-otelErrors:
case err := <-systemtest.OtelErrors:
return err
default:
return nil
Expand Down Expand Up @@ -653,7 +637,7 @@ func sendOTLPMetrics(
return err
}
select {
case err := <-otelErrors:
case err := <-systemtest.OtelErrors:
return err
default:
return nil
Expand Down
55 changes: 55 additions & 0 deletions systemtest/settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package systemtest

import (
"fmt"
"log"
"strings"
)

func initSettings() {
// Proactively test with more strict
// "ignore_malformed" mode by default.
for _, t := range []string{
"traces",
"metrics",
"logs-apm.error",
"logs-apm.app",
} {
if err := DisableIgnoreMalformed(t); err != nil {
log.Fatalf("failed to configure ignore_malformed %v", err)
}
}
}

// DisableIgnoreMalformed updates component template index setting
// to disable "ignore_malformed" inside mappings.
func DisableIgnoreMalformed(componentTemplate string) error {
r, err := Elasticsearch.Cluster.PutComponentTemplate(
fmt.Sprintf("%s@custom", componentTemplate),
strings.NewReader(`{"template":{"settings":{"index":{"mapping":{"ignore_malformed":"false"}}}}}`),
)
if err != nil {
return err
}
if r.IsError() {
return fmt.Errorf(`request to update "ignore_malformed":"false" failed for %s`, componentTemplate)
}
return nil
}
2 changes: 1 addition & 1 deletion testing/infra/k8s/base/stack/apm-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: apm-server
spec:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
version: 9.0.0-8f0a2811-SNAPSHOT
version: 9.0.0-6e0d547d-SNAPSHOT
count: 1
http:
tls:
Expand Down
2 changes: 1 addition & 1 deletion testing/infra/k8s/base/stack/elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: elasticsearch
spec:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
version: 9.0.0-8f0a2811-SNAPSHOT
version: 9.0.0-6e0d547d-SNAPSHOT
auth:
fileRealm:
- secretName: elasticsearch-admin
Expand Down
2 changes: 1 addition & 1 deletion testing/infra/k8s/base/stack/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: kibana
spec:
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
version: 9.0.0-8f0a2811-SNAPSHOT
version: 9.0.0-6e0d547d-SNAPSHOT
count: 1
elasticsearchRef:
name: elasticsearch
Expand Down

0 comments on commit 1ff4781

Please sign in to comment.