diff --git a/apptest/tests/export_import_test.go b/apptest/tests/export_import_test.go index c76f27d67e..6f778c6cdd 100644 --- a/apptest/tests/export_import_test.go +++ b/apptest/tests/export_import_test.go @@ -1,16 +1,17 @@ package tests import ( - "os" "testing" - at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestSingleExportImportNative(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() @@ -21,7 +22,7 @@ func TestSingleExportImportNative(t *testing.T) { } func TestClusterExportImportNative(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() diff --git a/apptest/tests/ingestprotocols_test.go b/apptest/tests/ingestprotocols_test.go index f85170ab1c..0745052294 100644 --- a/apptest/tests/ingestprotocols_test.go +++ b/apptest/tests/ingestprotocols_test.go @@ -1,18 +1,18 @@ package tests import ( - "os" "testing" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" pb "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal" ) func TestSingleIngestionProtocols(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() sut := tc.MustStartDefaultVmsingle() @@ -249,7 +249,7 @@ func TestSingleIngestionProtocols(t *testing.T) { } func TestClusterIngestionProtocols(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() vmstorage := tc.MustStartVmstorage("vmstorage", []string{ diff --git a/apptest/tests/metric_names_stats_test.go b/apptest/tests/metric_names_stats_test.go index e7f0a8c0a9..baeea532f2 100644 --- a/apptest/tests/metric_names_stats_test.go +++ b/apptest/tests/metric_names_stats_test.go @@ -2,7 +2,6 @@ package tests import ( "fmt" - "os" "strings" "testing" @@ -10,10 +9,11 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestSingleMetricNamesStats(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() sut := tc.MustStartVmsingle("vmsingle", []string{"-storage.trackMetricNamesStats=true", "-retentionPeriod=100y"}) @@ -136,8 +136,7 @@ func TestSingleMetricNamesStats(t *testing.T) { } func TestClusterMetricNamesStats(t *testing.T) { - - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() diff --git a/apptest/tests/multitenant_test.go b/apptest/tests/multitenant_test.go index 2dd9d528b2..1a10482c06 100644 --- a/apptest/tests/multitenant_test.go +++ b/apptest/tests/multitenant_test.go @@ -1,17 +1,17 @@ package tests import ( - "os" "testing" - "github.com/VictoriaMetrics/VictoriaMetrics/apptest" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestClusterMultiTenantSelect(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) cmpOpt := cmpopts.IgnoreFields(apptest.PrometheusAPIV1QueryResponse{}, "Status", "Data.ResultType") cmpSROpt := cmpopts.IgnoreFields(apptest.PrometheusAPIV1SeriesResponse{}, "Status", "IsPartial") diff --git a/apptest/tests/query_resource_limit_test.go b/apptest/tests/query_resource_limit_test.go index 29102b1a8f..d98bf5ec1e 100644 --- a/apptest/tests/query_resource_limit_test.go +++ b/apptest/tests/query_resource_limit_test.go @@ -1,17 +1,17 @@ package tests import ( - "os" "testing" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestClusterMaxUniqueTimeseries(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) cmpOpt := cmpopts.IgnoreFields(apptest.PrometheusAPIV1QueryResponse{}, "Status", "Data.ResultType") @@ -121,7 +121,7 @@ func TestClusterMaxUniqueTimeseries(t *testing.T) { } func TestClusterMaxSeries(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) cmpSROpt := cmpopts.IgnoreFields(apptest.PrometheusAPIV1SeriesResponse{}, "Status", "IsPartial") diff --git a/apptest/tests/rollup_result_cache_test.go b/apptest/tests/rollup_result_cache_test.go index e745a7cfc5..d5f6d5a682 100644 --- a/apptest/tests/rollup_result_cache_test.go +++ b/apptest/tests/rollup_result_cache_test.go @@ -1,17 +1,17 @@ package tests import ( - "os" "testing" - "github.com/VictoriaMetrics/VictoriaMetrics/apptest" - "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestClusterRollupResultCache(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) cmpOpt := cmpopts.IgnoreFields(apptest.PrometheusAPIV1QueryResponse{}, "Status", "Data.ResultType") diff --git a/apptest/tests/special_query_regression_test.go b/apptest/tests/special_query_regression_test.go index 6a8fa30b66..4ea0158e8b 100644 --- a/apptest/tests/special_query_regression_test.go +++ b/apptest/tests/special_query_regression_test.go @@ -1,20 +1,21 @@ package tests import ( - "os" "path/filepath" "testing" - at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) // TestSingleSpecialQueryRegression is used to test queries that have experienced issues for specific data sets. // These test cases were migrated from `app/victoria-metrics/main_test.go`. // Most of these cases are based on user feedback. Refer to the corresponding GitHub issue for details on each case. func TestSingleSpecialQueryRegression(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() diff --git a/apptest/tests/vmctl_native_migration_test.go b/apptest/tests/vmctl_native_migration_test.go index fe3ea191f6..536c232364 100644 --- a/apptest/tests/vmctl_native_migration_test.go +++ b/apptest/tests/vmctl_native_migration_test.go @@ -2,7 +2,6 @@ package tests import ( "fmt" - "os" "path/filepath" "testing" @@ -10,10 +9,11 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestSingleToSingleVmctlNativeProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := apptest.NewTestCase(t) defer tc.Stop() @@ -44,7 +44,7 @@ func TestSingleToSingleVmctlNativeProtocol(t *testing.T) { } func TestClusterTenantsToTenantsVmctlNativeProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := apptest.NewTestCase(t) defer tc.Stop() diff --git a/apptest/tests/vmctl_prometheus_migration_test.go b/apptest/tests/vmctl_prometheus_migration_test.go index 438020d6d4..1a98d3d387 100644 --- a/apptest/tests/vmctl_prometheus_migration_test.go +++ b/apptest/tests/vmctl_prometheus_migration_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) const ( @@ -19,7 +20,7 @@ const ( ) func TestSingleVmctlPrometheusProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := apptest.NewTestCase(t) defer tc.Stop() @@ -37,7 +38,7 @@ func TestSingleVmctlPrometheusProtocol(t *testing.T) { } func TestClusterVmctlPrometheusProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := apptest.NewTestCase(t) defer tc.Stop() diff --git a/apptest/tests/vmctl_remote_read_mogration_test.go b/apptest/tests/vmctl_remote_read_mogration_test.go index b2ea971fdc..c0fe761782 100644 --- a/apptest/tests/vmctl_remote_read_mogration_test.go +++ b/apptest/tests/vmctl_remote_read_mogration_test.go @@ -2,7 +2,6 @@ package tests import ( "fmt" - "os" "testing" "github.com/google/go-cmp/cmp" @@ -10,10 +9,11 @@ import ( "github.com/prometheus/prometheus/prompb" at "github.com/VictoriaMetrics/VictoriaMetrics/apptest" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/fs" ) func TestSingleVmctlRemoteReadProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() @@ -33,7 +33,7 @@ func TestSingleVmctlRemoteReadProtocol(t *testing.T) { } func TestSingleVmctlRemoteReadStreamProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop() @@ -54,7 +54,7 @@ func TestSingleVmctlRemoteReadStreamProtocol(t *testing.T) { } func TestClusterVmctlRemoteReadProtocol(t *testing.T) { - os.RemoveAll(t.Name()) + fs.MustRemoveDir(t.Name()) tc := at.NewTestCase(t) defer tc.Stop()