mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-06 17:46:59 +02:00
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
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>
57 lines
1.8 KiB
Go
57 lines
1.8 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"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"github.com/cosi-project/runtime/pkg/resource/rtestutils"
|
|
"github.com/cosi-project/runtime/pkg/safe"
|
|
"github.com/cosi-project/runtime/pkg/state"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
|
|
)
|
|
|
|
const testPatch = `apiVersion: v1alpha1
|
|
kind: EventSinkConfig
|
|
endpoint: '[fdae:41e4:649b:9303::1]:8090'`
|
|
|
|
// AssertMaintenanceTestConfigIsPresent asserts that the test configuration is present on a machine in maintenance mode.
|
|
func AssertMaintenanceTestConfigIsPresent(ctx context.Context, omniState state.State, cluster resource.ID, machineIndex int) TestFunc {
|
|
return func(t *testing.T) {
|
|
machineStatusList, err := safe.StateListAll[*omni.MachineStatus](ctx, omniState, state.WithLabelQuery(resource.LabelEqual(omni.LabelCluster, cluster)))
|
|
require.NoError(t, err)
|
|
|
|
ids := make([]resource.ID, 0, machineStatusList.Len())
|
|
|
|
machineStatusList.ForEach(func(status *omni.MachineStatus) { ids = append(ids, status.Metadata().ID()) })
|
|
|
|
slices.Sort(ids)
|
|
|
|
require.Less(t, machineIndex, len(ids), "machine index out of range")
|
|
|
|
machineID := ids[machineIndex]
|
|
|
|
rtestutils.AssertResource[*omni.RedactedClusterMachineConfig](ctx, t, omniState, machineID, func(r *omni.RedactedClusterMachineConfig, assertion *assert.Assertions) {
|
|
buffer, bufferErr := r.TypedSpec().Value.GetUncompressedData()
|
|
assertion.NoError(bufferErr)
|
|
|
|
defer buffer.Free()
|
|
|
|
data := string(buffer.Data())
|
|
|
|
assertion.Contains(data, testPatch)
|
|
})
|
|
}
|
|
}
|