...

Text file src/edge-infra.dev/pkg/edge/controllers/clusterctl/README.md

Documentation: edge-infra.dev/pkg/edge/controllers/clusterctl

     1# Clusterctl test guide
     2
     3- All controllers tests are to check that all the resources we expect to be created are present in the kubernetes cluster after reconcilation.
     4
     5- You will set up the according test variables for your own test case and then set up your cluster specs
     6
     7- Let's use `TestClusterControllerSDSDistributed` as an example from `cluster_controller_test.go`
     8
     9
    10- First, set up your test function:
    11
    12```
    13func (s *Suite) TestClusterControllerSDSDistributed() {
    14
    15}
    16```
    17
    18**Note: for SDS/DSDS cluster, you will need to add `integration.SkipIf(s.Framework)`, but for GKE you won't**
    19
    20- Set up your test cluster:
    21
    22```
    23    cluster := clusterApi.NewCluster(uuid.New().String(),
    24		s.ProjectID,
    25		s.Organization,
    26		fleet.Store,
    27		clusterConstant.DSDS,
    28		// for non gke clusters below fields are ignored
    29		s.Location, "", "", uuid.NewString(), 0, s.Banner)
    30
    31	s.createCluster(cluster)
    32	defer s.deleteCluster(cluster)
    33
    34```
    35
    36- Check to see if your `shipment(s)` is/are created:
    37
    38
    39```
    40    s.checkShipment(cluster)
    41```
    42
    43- Check to see if `infra_status` is `READY`:
    44
    45```
    46    s.checkInfraStatusDatabaseValue(cluster, edgedb.InfraStatusReady)
    47```
    48
    49- Check for cluster namespace creation:
    50
    51```
    52    ns := &corev1.Namespace{}
    53	s.Eventually(func() bool {
    54		err := s.Client.Get(s.ctx, types.NamespacedName{Name: cluster.Name}, ns)
    55		return !errors.IsNotFound(err)
    56	}, s.timeout, s.tick, "expected namespace was never created")
    57
    58	s.Eventually(func() bool {
    59		return checkNSOwnerReference(cluster, ns.GetOwnerReferences())
    60	}, s.timeout, s.tick, "expected namespace owner reference was not found")
    61
    62```
    63
    64- Check for `grub` or `grub2 resources` store-credentials plugin:
    65
    66```
    67    s.checkHashedGrubSecret(cluster)
    68```
    69
    70- Check for `IEN host OS user resources` store-credentials plugin: 
    71
    72```
    73    s.checkHashedBreakGlassSecret(cluster)
    74```
    75
    76- Verify the cluster you've just created and check if a `DSDS` type created, not a `GKE` type since we're trying to create a dsds one:
    77
    78```
    79    gkeCluster := &gkeClusterApi.GKECluster{}
    80	s.Never(func() bool {
    81		err := s.Client.Get(s.ctx, types.NamespacedName{Name: cluster.Name, Namespace: cluster.Name}, gkeCluster)
    82		return !errors.IsNotFound(err)
    83	}, time.Second, 100*time.Millisecond, "GKECluster should not exits for non-gke clusters")
    84```
    85
    86
    87
    88# If you have any further question, please reach out to the platform team via #ncr-edge-api or #ncr-edge-backend :)

View as plain text