@@ -2,12 +2,15 @@ package e2e_techpreview_test
2
2
3
3
import (
4
4
"bytes"
5
+ "context"
5
6
"os/exec"
6
7
"testing"
7
8
8
9
"github.com/openshift/machine-config-operator/test/framework"
9
10
"github.com/openshift/machine-config-operator/test/helpers"
10
11
"github.com/stretchr/testify/require"
12
+
13
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
14
)
12
15
13
16
func TestMCNScopeSadPath (t * testing.T ) {
@@ -53,3 +56,37 @@ func TestMCNScopeHappyPath(t *testing.T) {
53
56
// This oc command effectively use the service account of the nodeUnderTest's MCD pod, which should only be able to edit nodeUnderTest's MCN.
54
57
helpers .ExecCmdOnNode (t , cs , nodeUnderTest , "chroot" , "/rootfs" , "oc" , "patch" , "machineconfignodes" , nodeUnderTest .Name , "--type=merge" , "-p" , "{\" spec\" :{\" configVersion\" :{\" desired\" :\" rendered-worker-test\" }}}" )
55
58
}
59
+
60
+ // `TestMCNPoolNameDefault` checks that the MCP name is correctly populated in a node's MCN object for default MCPs
61
+ func TestMCNPoolNameDefault (t * testing.T ) {
62
+
63
+ cs := framework .NewClientSet ("" )
64
+
65
+ // Grab a random node from each default pool
66
+ workerNode := helpers .GetRandomNode (t , cs , "worker" )
67
+ masterNode := helpers .GetRandomNode (t , cs , "master" )
68
+
69
+ // Test that MCN pool name value matches MCP association
70
+ workerNodeMCN , workerErr := cs .MachineconfigurationV1alpha1Interface .MachineConfigNodes ().Get (context .TODO (), workerNode .Name , metav1.GetOptions {})
71
+ require .Equal (t , "worker" , workerNodeMCN .Spec .Pool .Name )
72
+ require .NoError (t , workerErr )
73
+ masterNodeMCN , masterErr := cs .MachineconfigurationV1alpha1Interface .MachineConfigNodes ().Get (context .TODO (), masterNode .Name , metav1.GetOptions {})
74
+ require .Equal (t , "master" , masterNodeMCN .Spec .Pool .Name )
75
+ require .NoError (t , masterErr )
76
+ }
77
+
78
+ // `TestMCNPoolNameDefault` checks that the MCP name is correctly populated in a node's MCN object for custom MCPs
79
+ func TestMCNPoolNameCustom (t * testing.T ) {
80
+
81
+ cs := framework .NewClientSet ("" )
82
+
83
+ // Create a custom MCP and assign a worker node to it
84
+ customMCPName := "infra"
85
+ customNode := helpers .GetRandomNode (t , cs , "worker" )
86
+ helpers .CreatePoolWithNode (t , cs , customMCPName , customNode )
87
+
88
+ // Test that MCN pool name value matches MCP association
89
+ customNodeMCN , customErr := cs .MachineconfigurationV1alpha1Interface .MachineConfigNodes ().Get (context .TODO (), customNode .Name , metav1.GetOptions {})
90
+ require .Equal (t , customMCPName , customNodeMCN .Spec .Pool .Name )
91
+ require .NoError (t , customErr )
92
+ }
0 commit comments