omni/internal/integration/cleanup_test.go
Artem Chernyshev c9c4c8e10d
Some checks failed
default / default (push) Has been cancelled
default / e2e-backups (push) Has been cancelled
default / e2e-forced-removal (push) Has been cancelled
default / e2e-scaling (push) Has been cancelled
default / e2e-short (push) Has been cancelled
default / e2e-short-secureboot (push) Has been cancelled
default / e2e-templates (push) Has been cancelled
default / e2e-upgrades (push) Has been cancelled
default / e2e-workload-proxy (push) Has been cancelled
test: use go test to build and run Omni integration tests
All test modules were moved under `integration` tag and are now in
`internal/integration` folder: no more `cmd/integration-test`
executable.

New Kres version is able to build the same executable from the tests
directory instead.

All Omni related flags were renamed, for example `--endpoint` ->
`--omni.endpoint`.

2 more functional changes:

- Enabled `--test.failfast` for all test runs.
- Removed finalizers, which were running if the test has failed.

Both of these changes should make it easier to understand the test
failure: Talos node logs won't be cluttered with the finalizer tearing
down the cluster.

Fixes: https://github.com/siderolabs/omni/issues/1171

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
2025-06-03 15:07:00 +03:00

36 lines
1.1 KiB
Go

// Copyright (c) 2025 Sidero Labs, Inc.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//go:build integration
package integration_test
import (
"context"
"testing"
"time"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/rtestutils"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
)
// DestroyAllClusterRelatedResources cleans up the state from the previous runs.
func DestroyAllClusterRelatedResources(testCtx context.Context, st state.State) TestFunc {
return func(t *testing.T) {
ctx, cancel := context.WithTimeout(testCtx, 300*time.Second)
defer cancel()
rtestutils.Teardown[*omni.MachineSet](ctx, t, st, rtestutils.ResourceIDs[*omni.MachineSet](ctx, t, st))
rtestutils.DestroyAll[*omni.MachineSetNode](ctx, t, st)
rtestutils.DestroyAll[*omni.ConfigPatch](ctx, t, st)
rtestutils.DestroyAll[*omni.MachineSet](ctx, t, st)
rtestutils.DestroyAll[*omni.Cluster](ctx, t, st)
rtestutils.Destroy[*omni.EtcdBackupS3Conf](ctx, t, st, []resource.ID{omni.EtcdBackupS3ConfID})
}
}