mirror of
https://github.com/siderolabs/talos.git
synced 2025-11-01 00:41:40 +01:00
Now the latest value for CPU and Memory is also represented as COSI resources. Was going back and forth in the implementation but in the end decided to use dedicated yaml structures for both CPU and Memory stats because: - JSON tags are ignored by `go-yaml`, so the output is not really great. - protobuf Talos definition contains fields which we don't really need in the YAML output of `talosctl get`. - current state of Talos resource service does not support protobuf encoding for resources. So the plan for Theila is to just use the structure as a dynamic object without relying on protobufs. At least for now. Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
34 lines
956 B
Go
34 lines
956 B
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 perf_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"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/talos-systems/talos/pkg/resources/perf"
|
|
)
|
|
|
|
func TestRegisterResource(t *testing.T) {
|
|
ctx := context.TODO()
|
|
|
|
resources := state.WrapCore(namespaced.NewState(inmem.Build))
|
|
resourceRegistry := registry.NewResourceRegistry(resources)
|
|
|
|
for _, resource := range []resource.Resource{
|
|
&perf.Memory{},
|
|
&perf.CPU{},
|
|
} {
|
|
assert.NoError(t, resourceRegistry.Register(ctx, resource))
|
|
}
|
|
}
|