Skip to content

Commit

Permalink
Merge branch 'main' into hotrod
Browse files Browse the repository at this point in the history
  • Loading branch information
hellspawn679 committed Jul 16, 2024
2 parents 5c64603 + 67ddb2c commit 046501a
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 107 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions .github/workflows/ci-e2e-memory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CIT Memory

on:
push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
memory-v2:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.22.x

- name: Run Memory storage integration tests
run: |
STORAGE=memory_v2 make jaeger-v2-storage-integration-test
- name: Upload coverage to codecov
uses: ./.github/actions/upload-codecov
with:
files: cover.out
flags: memory_v2
File renamed without changes.
File renamed without changes.
File renamed without changes.
95 changes: 0 additions & 95 deletions .github/workflows/ci-release-testing.yml

This file was deleted.

File renamed without changes.
5 changes: 4 additions & 1 deletion cmd/jaeger/internal/integration/e2e_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func createStorageCleanerConfig(t *testing.T, configFile string, storage string)

func purge(t *testing.T) {
addr := fmt.Sprintf("http://0.0.0.0:%s%s", storagecleaner.Port, storagecleaner.URL)
t.Logf("Purging storage via %s", addr)
r, err := http.NewRequestWithContext(context.Background(), http.MethodPost, addr, nil)
require.NoError(t, err)

Expand All @@ -185,6 +186,8 @@ func purge(t *testing.T) {
resp, err := client.Do(r)
require.NoError(t, err)
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

require.Equal(t, http.StatusOK, resp.StatusCode)
require.Equal(t, http.StatusOK, resp.StatusCode, "body: %s", string(body))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage/integration"
)

func TestESStorage(t *testing.T) {
func TestElasticsearchStorage(t *testing.T) {
integration.SkipUnlessEnv(t, "elasticsearch")

s := &E2EStorageIntegration{
Expand Down
27 changes: 27 additions & 0 deletions cmd/jaeger/internal/integration/memory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package integration

import (
"testing"

"github.com/jaegertracing/jaeger/plugin/storage/integration"
)

func TestMemoryStorage(t *testing.T) {
integration.SkipUnlessEnv(t, "memory_v2")

s := &E2EStorageIntegration{
ConfigFile: "../../config.yaml",
StorageIntegration: integration.StorageIntegration{
SkipArchiveTest: true,
CleanUp: purge,
},
}
s.e2eInitialize(t, "memory")
t.Cleanup(func() {
s.e2eCleanUp(t)
})
s.RunAll(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage/integration"
)

func TestOSStorage(t *testing.T) {
func TestOpenSearchStorage(t *testing.T) {
integration.SkipUnlessEnv(t, "opensearch")
s := &E2EStorageIntegration{
ConfigFile: "../../config-opensearch.yaml",
Expand Down
16 changes: 9 additions & 7 deletions cmd/jaeger/internal/integration/storagecleaner/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gorilla/mux"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
"github.com/jaegertracing/jaeger/storage"
Expand All @@ -29,15 +30,15 @@ const (
)

type storageCleaner struct {
config *Config
server *http.Server
settings component.TelemetrySettings
config *Config
server *http.Server
telset component.TelemetrySettings
}

func newStorageCleaner(config *Config, telemetrySettings component.TelemetrySettings) *storageCleaner {
func newStorageCleaner(config *Config, telset component.TelemetrySettings) *storageCleaner {
return &storageCleaner{
config: config,
settings: telemetrySettings,
config: config,
telset: telset,
}
}

Expand Down Expand Up @@ -74,10 +75,11 @@ func (c *storageCleaner) Start(_ context.Context, host component.Host) error {
Handler: r,
ReadHeaderTimeout: 3 * time.Second,
}
c.telset.Logger.Info("Starting storage cleaner server", zap.String("addr", c.server.Addr))
go func() {
if err := c.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
err = fmt.Errorf("error starting cleaner server: %w", err)
c.settings.ReportStatus(component.NewFatalErrorEvent(err))
c.telset.ReportStatus(component.NewFatalErrorEvent(err))
}
}()

Expand Down
10 changes: 8 additions & 2 deletions cmd/jaeger/internal/integration/storagecleaner/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.uber.org/zap/zaptest"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
"github.com/jaegertracing/jaeger/storage"
Expand Down Expand Up @@ -84,7 +85,9 @@ func TestStorageCleanerExtension(t *testing.T) {
TraceStorage: "storage",
Port: Port,
}
s := newStorageCleaner(config, component.TelemetrySettings{})
s := newStorageCleaner(config, component.TelemetrySettings{
Logger: zaptest.NewLogger(t),
})
require.NotEmpty(t, s.Dependencies())
host := storagetest.NewStorageHost()
host.WithExtension(jaegerstorage.ID, &mockStorageExt{
Expand All @@ -110,7 +113,9 @@ func TestStorageCleanerExtension(t *testing.T) {

func TestGetStorageFactoryError(t *testing.T) {
config := &Config{}
s := newStorageCleaner(config, component.TelemetrySettings{})
s := newStorageCleaner(config, component.TelemetrySettings{
Logger: zaptest.NewLogger(t),
})
host := storagetest.NewStorageHost()
host.WithExtension(jaegerstorage.ID, &mockStorageExt{
name: "storage",
Expand All @@ -128,6 +133,7 @@ func TestStorageExtensionStartError(t *testing.T) {
}
var startStatus atomic.Pointer[component.StatusEvent]
s := newStorageCleaner(config, component.TelemetrySettings{
Logger: zaptest.NewLogger(t),
ReportStatus: func(status *component.StatusEvent) {
startStatus.Store(status)
},
Expand Down
9 changes: 9 additions & 0 deletions plugin/storage/memory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package memory

import (
"context"
"flag"

"github.com/spf13/viper"
Expand All @@ -36,6 +37,7 @@ var ( // interface comformance checks
_ storage.ArchiveFactory = (*Factory)(nil)
_ storage.SamplingStoreFactory = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
_ storage.Purger = (*Factory)(nil)
)

// Factory implements storage.Factory and creates storage components backed by memory store.
Expand Down Expand Up @@ -126,3 +128,10 @@ func (*Factory) CreateLock() (distributedlock.Lock, error) {
func (f *Factory) publishOpts() {
safeexpvar.SetInt("jaeger_storage_memory_max_traces", int64(f.options.Configuration.MaxTraces))
}

// Purge removes all data from the Factory's underlying Memory store.
// This function is intended for testing purposes only and should not be used in production environments.
func (f *Factory) Purge(ctx context.Context) error {
f.store.purge(ctx)
return nil
}
7 changes: 7 additions & 0 deletions plugin/storage/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,10 @@ func flattenTags(span *model.Span) model.KeyValues {
}
return retMe
}

// purge supports Purger interface.
func (st *Store) purge(context.Context) {
st.Lock()
st.perTenant = make(map[string]*Tenant)
st.Unlock()
}

0 comments on commit 046501a

Please sign in to comment.