From 86625143c93789dbcafdfc0637e7f207052815d4 Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Thu, 25 Jul 2024 21:15:13 +0300 Subject: [PATCH] test: add parallel destroy test to the conformance suite It verifies that parallel destroy doesn't break underlying state implementations. Signed-off-by: Artem Chernyshev --- pkg/state/conformance/state.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/state/conformance/state.go b/pkg/state/conformance/state.go index cf2deab..6fc21be 100644 --- a/pkg/state/conformance/state.go +++ b/pkg/state/conformance/state.go @@ -859,6 +859,32 @@ loop: } } +// TestParallelDestroy runs several parallel destroy calls. +func (suite *StateSuite) TestParallelDestroy() { + res := NewPathResource("default", "/") + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + var eg errgroup.Group + + err := suite.State.Create(ctx, res) + suite.Require().NoError(err) + + for range 10 { + eg.Go(func() error { + err := suite.State.Destroy(ctx, res.Metadata()) + if err != nil && !state.IsNotFoundError(err) { + return err + } + + return nil + }) + } + + suite.Require().NoError(eg.Wait()) +} + // TestTeardownDestroy verifies finalizers, teardown and destroy. func (suite *StateSuite) TestTeardownDestroy() { ns := suite.getNamespace()