talos/pkg/machinery/resources/runtime/runtime_test.go
Dmitriy Matrenichev 6eade3d5ef
chore: add ability to rewrite uuids and set unique tokens for Talos
This PR does those things:
- It allows API calls `MetaWrite` and `MetaRead` in maintenance mode.
- SystemInformation resource now waits for available META
- SystemInformation resource now overwrites UUID from META if there is an override
- META now supports "UUID override" and "unique token" keys
- ProvisionRequest now includes unique token and Talos version

For #7694

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
2023-11-10 18:17:54 +03:00

48 lines
1.4 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package runtime_test
import (
"context"
"testing"
"github.com/cosi-project/runtime/pkg/resource/meta"
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/cosi-project/runtime/pkg/state/registry"
"github.com/stretchr/testify/assert"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)
func TestRegisterResource(t *testing.T) {
ctx := context.TODO()
resources := state.WrapCore(namespaced.NewState(inmem.Build))
resourceRegistry := registry.NewResourceRegistry(resources)
for _, resource := range []meta.ResourceWithRD{
&runtime.DevicesStatus{},
&runtime.EventSinkConfig{},
&runtime.ExtensionStatus{},
&runtime.KernelModuleSpec{},
&runtime.KernelParamSpec{},
&runtime.KernelParamStatus{},
&runtime.KmsgLogConfig{},
&runtime.MachineStatus{},
&runtime.MaintenanceServiceConfig{},
&runtime.MaintenanceServiceRequest{},
&runtime.MetaKey{},
&runtime.MetaLoaded{},
&runtime.MountStatus{},
&runtime.PlatformMetadata{},
&runtime.SecurityState{},
&runtime.UniqueMachineToken{},
} {
assert.NoError(t, resourceRegistry.Register(ctx, resource))
}
}