From 090598c07d64c35192263f77042e1bef0a7f1246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nick=20M=C3=BCller?= Date: Mon, 31 Oct 2022 22:26:42 +0100 Subject: [PATCH 1/5] NewDefaultProtobufStore accepts scope instead of metrics again (#141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Required in propeller tests (protoMetrics are not exported) Added NewDefaultProtobufStoreWithMetrics for package internal usage Ran make generate Signed-off-by: Nick Müller Signed-off-by: Nick Müller --- storage/mocks/composed_protobuf_store.go | 32 ++++++++++++++++++++++++ storage/mocks/raw_store.go | 32 ++++++++++++++++++++++++ storage/protobuf_store.go | 6 ++++- storage/protobuf_store_test.go | 2 +- storage/rawstores.go | 2 +- 5 files changed, 71 insertions(+), 3 deletions(-) diff --git a/storage/mocks/composed_protobuf_store.go b/storage/mocks/composed_protobuf_store.go index 6e28fbb..0b645ed 100644 --- a/storage/mocks/composed_protobuf_store.go +++ b/storage/mocks/composed_protobuf_store.go @@ -89,6 +89,38 @@ func (_m *ComposedProtobufStore) CreateSignedURL(ctx context.Context, reference return r0, r1 } +type ComposedProtobufStore_Delete struct { + *mock.Call +} + +func (_m ComposedProtobufStore_Delete) Return(_a0 error) *ComposedProtobufStore_Delete { + return &ComposedProtobufStore_Delete{Call: _m.Call.Return(_a0)} +} + +func (_m *ComposedProtobufStore) OnDelete(ctx context.Context, reference storage.DataReference) *ComposedProtobufStore_Delete { + c := _m.On("Delete", ctx, reference) + return &ComposedProtobufStore_Delete{Call: c} +} + +func (_m *ComposedProtobufStore) OnDeleteMatch(matchers ...interface{}) *ComposedProtobufStore_Delete { + c := _m.On("Delete", matchers...) + return &ComposedProtobufStore_Delete{Call: c} +} + +// Delete provides a mock function with given fields: ctx, reference +func (_m *ComposedProtobufStore) Delete(ctx context.Context, reference storage.DataReference) error { + ret := _m.Called(ctx, reference) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, storage.DataReference) error); ok { + r0 = rf(ctx, reference) + } else { + r0 = ret.Error(0) + } + + return r0 +} + type ComposedProtobufStore_GetBaseContainerFQN struct { *mock.Call } diff --git a/storage/mocks/raw_store.go b/storage/mocks/raw_store.go index 9bda818..cb9d9b1 100644 --- a/storage/mocks/raw_store.go +++ b/storage/mocks/raw_store.go @@ -87,6 +87,38 @@ func (_m *RawStore) CreateSignedURL(ctx context.Context, reference storage.DataR return r0, r1 } +type RawStore_Delete struct { + *mock.Call +} + +func (_m RawStore_Delete) Return(_a0 error) *RawStore_Delete { + return &RawStore_Delete{Call: _m.Call.Return(_a0)} +} + +func (_m *RawStore) OnDelete(ctx context.Context, reference storage.DataReference) *RawStore_Delete { + c := _m.On("Delete", ctx, reference) + return &RawStore_Delete{Call: c} +} + +func (_m *RawStore) OnDeleteMatch(matchers ...interface{}) *RawStore_Delete { + c := _m.On("Delete", matchers...) + return &RawStore_Delete{Call: c} +} + +// Delete provides a mock function with given fields: ctx, reference +func (_m *RawStore) Delete(ctx context.Context, reference storage.DataReference) error { + ret := _m.Called(ctx, reference) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, storage.DataReference) error); ok { + r0 = rf(ctx, reference) + } else { + r0 = ret.Error(0) + } + + return r0 +} + type RawStore_GetBaseContainerFQN struct { *mock.Call } diff --git a/storage/protobuf_store.go b/storage/protobuf_store.go index 1eca509..e9a284d 100644 --- a/storage/protobuf_store.go +++ b/storage/protobuf_store.go @@ -92,7 +92,11 @@ func newProtoMetrics(scope promutils.Scope) *protoMetrics { } } -func NewDefaultProtobufStore(store RawStore, metrics *protoMetrics) DefaultProtobufStore { +func NewDefaultProtobufStore(store RawStore, scope promutils.Scope) DefaultProtobufStore { + return NewDefaultProtobufStoreWithMetrics(store, newProtoMetrics(scope)) +} + +func NewDefaultProtobufStoreWithMetrics(store RawStore, metrics *protoMetrics) DefaultProtobufStore { return DefaultProtobufStore{ RawStore: store, metrics: metrics, diff --git a/storage/protobuf_store_test.go b/storage/protobuf_store_test.go index d662ef5..78b10ba 100644 --- a/storage/protobuf_store_test.go +++ b/storage/protobuf_store_test.go @@ -157,7 +157,7 @@ func TestDefaultProtobufStore_HardErrors(t *testing.T) { return nil, fmt.Errorf(dummyReadErrorMsg) }, } - pbErroneousStore := NewDefaultProtobufStore(store, metrics.protoMetrics) + pbErroneousStore := NewDefaultProtobufStoreWithMetrics(store, metrics.protoMetrics) t.Run("Test if hard write errors are handled correctly", func(t *testing.T) { err := pbErroneousStore.WriteProtobuf(ctx, k1, Options{}, &mockProtoMessage{X: 5}) assert.False(t, IsFailedWriteToCache(err)) diff --git a/storage/rawstores.go b/storage/rawstores.go index f99cd8e..eafeff5 100644 --- a/storage/rawstores.go +++ b/storage/rawstores.go @@ -106,7 +106,7 @@ func (ds *DataStore) RefreshConfig(cfg *Config) error { } rawStore = newCachedRawStore(cfg, rawStore, ds.metrics.cacheMetrics) - protoStore := NewDefaultProtobufStore(rawStore, ds.metrics.protoMetrics) + protoStore := NewDefaultProtobufStoreWithMetrics(rawStore, ds.metrics.protoMetrics) newDS := NewCompositeDataStore(NewURLPathConstructor(), protoStore) newDS.metrics = ds.metrics *ds = *newDS From bc6c604c3aa44e7649f4b42f53ddd1082cd7ef65 Mon Sep 17 00:00:00 2001 From: Dan Rammer Date: Wed, 2 Nov 2022 11:12:08 -0500 Subject: [PATCH 2/5] bump go versions to 1.18 (#142) Signed-off-by: Dan Rammer Signed-off-by: Dan Rammer --- .github/workflows/master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a69588c..34294a3 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -35,7 +35,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.17' + go-version: '1.18' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: @@ -54,7 +54,7 @@ jobs: fetch-depth: "0" - uses: actions/setup-go@v2 with: - go-version: '1.17' + go-version: '1.18' - name: Unit Tests run: make mod_download && make test_unit_codecov - name: Push CodeCov @@ -65,7 +65,7 @@ jobs: fail_ci_if_error: true - uses: actions/setup-go@v2 with: - go-version: '1.17' + go-version: '1.18' - name: Lint run: make install && make lint - name: Bench tests From 173686434faac828eba89e5a4e52a84c0ad18769 Mon Sep 17 00:00:00 2001 From: Ali Abbas Jaffri Date: Mon, 7 Nov 2022 23:43:03 +0100 Subject: [PATCH 3/5] codecov action version bump (#143) * Updated codecov action version to 3.1.1 Signed-off-by: Ali Abbas Jaffri * Removed codecov updater utility Signed-off-by: Ali Abbas Jaffri Signed-off-by: Ali Abbas Jaffri --- .github/workflows/master.yml | 2 +- Makefile | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 34294a3..3209583 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -58,7 +58,7 @@ jobs: - name: Unit Tests run: make mod_download && make test_unit_codecov - name: Push CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3.1.1 with: file: coverage.txt flags: unittests diff --git a/Makefile b/Makefile index 80ed5f0..0b5dae5 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,3 @@ compile: .PHONY: test_unit_codecov test_unit_codecov: go test ./... -race -coverprofile=coverage.txt -covermode=atomic - curl -s https://codecov.io/bash > codecov_bash.sh && bash codecov_bash.sh From ab2318746d40e78ecb7577391059497e07c2d5d8 Mon Sep 17 00:00:00 2001 From: Dan Rammer Date: Mon, 14 Nov 2022 10:47:51 -0600 Subject: [PATCH 4/5] Ignore codecov upload failures (#144) * disable codecov Signed-off-by: Dan Rammer * bump codecov action verison Signed-off-by: Dan Rammer Signed-off-by: Dan Rammer --- .github/workflows/master.yml | 2 +- .github/workflows/pull_request.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 3209583..fdfb76d 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -62,7 +62,7 @@ jobs: with: file: coverage.txt flags: unittests - fail_ci_if_error: true + fail_ci_if_error: false - uses: actions/setup-go@v2 with: go-version: '1.18' diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fbc7b27..88d81f6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,11 +17,11 @@ jobs: - name: Unit Tests run: make mod_download && make test_unit_codecov - name: Push CodeCov - uses: codecov/codecov-action@v1.5.2 + uses: codecov/codecov-action@v3.1.1 with: file: coverage.txt flags: unittests - fail_ci_if_error: true + fail_ci_if_error: false - name: Bench tests run: make install && make test_benchmark lint: From 80d16247a8a9c8b05a5692b80db965ddda9c183d Mon Sep 17 00:00:00 2001 From: Dan Rammer Date: Fri, 2 Dec 2022 15:58:53 -0600 Subject: [PATCH 5/5] adding signal to context (#137) Signed-off-by: Daniel Rammer Signed-off-by: Daniel Rammer --- contextutils/context.go | 6 ++++++ contextutils/context_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/contextutils/context.go b/contextutils/context.go index 9bc6a48..3b8224a 100644 --- a/contextutils/context.go +++ b/contextutils/context.go @@ -24,6 +24,7 @@ const ( RoutineLabelKey Key = "routine" LaunchPlanIDKey Key = "lp" ResourceVersionKey Key = "res_ver" + SignalIDKey Key = "signal" ) func (k Key) String() string { @@ -126,6 +127,11 @@ func WithTaskType(ctx context.Context, taskType string) context.Context { return context.WithValue(ctx, TaskTypeKey, taskType) } +// Gets a new context with SignalID set. +func WithSignalID(ctx context.Context, signalID string) context.Context { + return context.WithValue(ctx, SignalIDKey, signalID) +} + // Gets a new context with Go Routine label key set and a label assigned to the context using pprof.Labels. // You can then call pprof.SetGoroutineLabels(ctx) to annotate the current go-routine and have that show up in // pprof analysis. diff --git a/contextutils/context_test.go b/contextutils/context_test.go index e2effe3..f6cb842 100644 --- a/contextutils/context_test.go +++ b/contextutils/context_test.go @@ -102,6 +102,13 @@ func TestWithTaskID(t *testing.T) { assert.Equal(t, "task", ctx.Value(TaskIDKey)) } +func TestWithSignalID(t *testing.T) { + ctx := context.Background() + assert.Nil(t, ctx.Value(SignalIDKey)) + ctx = WithSignalID(ctx, "signal") + assert.Equal(t, "signal", ctx.Value(SignalIDKey)) +} + func TestGetFields(t *testing.T) { ctx := context.Background() ctx = WithJobID(WithNamespace(ctx, "ns123"), "job123")