Skip to content

Commit 7bcea75

Browse files
committed
test: use clustermachineconfig sha for omni upgrade e2e test
Save `ClusterMachineConfigStatus.ClusterMachineConfigSha256` on SaveClusterStatus e2e test. We will later compare this with actual value on AssertClusterStatus e2e test. Signed-off-by: Oguz Kilcan <[email protected]>
1 parent 2ac9ed1 commit 7bcea75

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

internal/backend/grpc/support.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ func (s *managementServer) collectClusterResources(ctx context.Context, cluster
295295
rt: omni.RedactedClusterMachineConfigType,
296296
listOptions: clusterQuery,
297297
},
298+
{
299+
rt: omni.ClusterMachineConfigStatusType,
300+
listOptions: clusterQuery,
301+
},
298302
{
299303
rt: omni.ClusterMachineTalosVersionType,
300304
listOptions: clusterQuery,

internal/backend/runtime/omni/state_access.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ var (
5757
// clusterLabelTypeSet is the set of resource types which have the related cluster's ID as a label.
5858
clusterLabelTypeSet = xslices.ToSet([]resource.Type{
5959
omni.ClusterMachineConfigType,
60-
omni.ClusterMachineConfigStatusType,
6160
omni.ClusterMachineIdentityType,
6261
omni.ClusterMachineType,
6362
omni.ClusterMachineConfigPatchesType,
@@ -382,6 +381,7 @@ func filterAccess(ctx context.Context, access state.Access) error {
382381
omni.ClusterMachineTalosVersionType,
383382
omni.ClusterMachineType,
384383
omni.ClusterMachineConfigPatchesType,
384+
omni.ClusterMachineConfigStatusType,
385385
omni.ClusterMachineTemplateType,
386386
omni.ClusterStatusType,
387387
omni.ClusterDiagnosticsType,
@@ -546,6 +546,7 @@ func filterAccessByType(access state.Access) error {
546546
omni.ClusterMachineTalosVersionType,
547547
omni.ClusterMachineType,
548548
omni.ClusterMachineConfigPatchesType,
549+
omni.ClusterMachineConfigStatusType,
549550
omni.ClusterMachineTemplateType,
550551
omni.ClusterStatusMetricsType,
551552
omni.ClusterStatusType,

internal/integration/auth_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ func AssertResourceAuthz(rootCtx context.Context, rootCli *client.Client, client
804804
resource: omni.NewClusterMachine(resources.DefaultNamespace, uuid.New().String()),
805805
allowedVerbSet: readOnlyVerbSet,
806806
},
807+
{
808+
resource: omni.NewClusterMachineConfigStatus(resources.DefaultNamespace, uuid.New().String()),
809+
allowedVerbSet: readOnlyVerbSet,
810+
},
807811
{
808812
resource: omni.NewClusterMachineRequestStatus(resources.DefaultNamespace, uuid.New().String()),
809813
allowedVerbSet: readOnlyVerbSet,
@@ -1082,9 +1086,6 @@ func AssertResourceAuthz(rootCtx context.Context, rootCli *client.Client, client
10821086
{
10831087
resource: authres.NewPublicKey(resources.DefaultNamespace, uuid.New().String()),
10841088
},
1085-
{
1086-
resource: omni.NewClusterMachineConfigStatus(resources.DefaultNamespace, uuid.New().String()),
1087-
},
10881089
{
10891090
resource: omni.NewEtcdAuditResult(resources.DefaultNamespace, uuid.New().String()),
10901091
},

internal/integration/omni_upgrade_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
const annotationSnapshot = "snapshot"
3232

3333
type clusterSnapshot struct {
34-
Versions map[string]string
34+
Versions map[string]string // TODO: remove after we switch to sha sums
3535
BootTimes map[string]time.Time
36+
ShaSums map[string]string
3637
}
3738

3839
func (vs clusterSnapshot) saveVersion(res resource.Resource) {
@@ -45,6 +46,16 @@ func (vs clusterSnapshot) getVersion(res resource.Resource) (string, bool) {
4546
return val, ok
4647
}
4748

49+
func (vs clusterSnapshot) saveShaSum(res resource.Resource, shaSum string) {
50+
vs.ShaSums[res.Metadata().Type()+"/"+res.Metadata().ID()] = shaSum
51+
}
52+
53+
func (vs clusterSnapshot) getShaSum(res resource.Resource) (string, bool) {
54+
val, ok := vs.ShaSums[res.Metadata().Type()+"/"+res.Metadata().ID()]
55+
56+
return val, ok
57+
}
58+
4859
// SaveClusterSnapshot saves resources versions as the annotations for the given cluster.
4960
func SaveClusterSnapshot(testCtx context.Context, client *client.Client, clusterName string) TestFunc {
5061
return func(t *testing.T) {
@@ -56,6 +67,7 @@ func SaveClusterSnapshot(testCtx context.Context, client *client.Client, cluster
5667
snapshot := clusterSnapshot{
5768
Versions: map[string]string{},
5869
BootTimes: map[string]time.Time{},
70+
ShaSums: map[string]string{},
5971
}
6072

6173
ids := rtestutils.ResourceIDs[*omni.RedactedClusterMachineConfig](ctx, t, st,
@@ -66,6 +78,14 @@ func SaveClusterSnapshot(testCtx context.Context, client *client.Client, cluster
6678
snapshot.saveVersion(res)
6779
})
6880

81+
cmcss := rtestutils.ResourceIDs[*omni.ClusterMachineConfigStatus](ctx, t, st,
82+
state.WithLabelQuery(resource.LabelEqual(omni.LabelCluster, clusterName)),
83+
)
84+
85+
rtestutils.AssertResources(ctx, t, st, cmcss, func(res *omni.ClusterMachineConfigStatus, _ *assert.Assertions) {
86+
snapshot.saveShaSum(res, res.TypedSpec().Value.ClusterMachineConfigSha256)
87+
})
88+
6989
require := require.New(t)
7090
assert := assert.New(t)
7191

0 commit comments

Comments
 (0)