-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mateusz Gozdek <[email protected]>
Showing
3 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package controllers_test | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/tinkerbell/cluster-api-provider-tinkerbell/controllers" | ||
) | ||
|
||
func Test_Cluster_reconciliation(t *testing.T) { | ||
t.Run("is_requeued_when", func(t *testing.T) { | ||
// This is introduced in v1alpha3 of CAPI even though behavior diagram does not reflect it. | ||
t.Run("cluster_is_paused", cluster_reconciliation_is_requeued_when_cluster_is_paused) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior. | ||
t.Run("cluster_has_no_owner_set", cluster_reconciliation_is_requeued_when_cluster_has_no_owner_set) | ||
}) | ||
|
||
// To avoid sending patch request on every reconcilation. | ||
t.Run("does_not_patch_cluster_object_when_there_is_no_pending_changes", | ||
cluster_reconciliation_does_not_patch_cluster_object_when_there_is_no_pending_changes) | ||
|
||
t.Run("fails_when", func(t *testing.T) { | ||
// At least one available hardware is required to be reserved for controlplane endpoinnt. | ||
t.Run("there_is_no_hardware_available", cluster_reconciliation_fails_when_there_is_no_hardware_available) | ||
}) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior. | ||
t.Run("sets_controlplane_endpoint_using_available_hardware", | ||
cluster_reconciliation_sets_controlplane_endpoint_using_available_hardware) | ||
|
||
// When multiple clusters are created simultaneously, each should get different IP address. | ||
t.Run("assigns_unique_controlplane_endpoint_for_each_cluster", | ||
cluster_reconciliation_assigns_unique_hardware_for_controlplane_endpoint) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior. | ||
t.Run("ensures_status_is_ready_when_hardware_is_available", | ||
cluster_reconciliation_ensures_status_is_ready_when_hardware_is_available) | ||
} | ||
|
||
func cluster_reconciliation_fails_when_there_is_no_hardware_available(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func cluster_reconciliation_is_requeued_when_cluster_is_paused(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func cluster_reconciliation_is_requeued_when_cluster_has_no_owner_set(t *testing.T) { | ||
t.Fatalf("not implemenetd") | ||
} | ||
|
||
func cluster_reconciliation_does_not_patch_cluster_object_when_there_is_no_pending_changes(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func cluster_reconciliation_assigns_unique_hardware_for_controlplane_endpoint(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func cluster_reconciliation_ensures_status_is_ready_when_hardware_is_available(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func cluster_reconciliation_sets_controlplane_endpoint_using_available_hardware(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package controllers_test | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/tinkerbell/cluster-api-provider-tinkerbell/controllers" | ||
) | ||
|
||
func not_implemented(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func Test_Machine_reconciliation(t *testing.T) { | ||
// From https://cluster-api.sigs.k8s.io/developer/providers/machine-infrastructure.html#behavior | ||
t.Run("removes_tinkerbell_finalizer_when_machine_is_scheduled_for_removal", not_implemented) | ||
|
||
t.Run("is_requeued_when", func(t *testing.T) { | ||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior | ||
t.Run("machine_has_no_owner_set", machine_reconciliation_is_requeued_when_machine_has_no_owner_set) | ||
|
||
// TinkerbellMachine must be created by MachineDeployment controller, as we must set providerID field in it. | ||
t.Run("associated_tinkerbell_machine_does_not_exist_yet", not_implemented) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior | ||
t.Run("bootstrap_secret_is_not_ready", not_implemented) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior | ||
t.Run("cluster_infrastructure_is_not_ready", not_implemented) | ||
}) | ||
|
||
t.Run("fails_when", func(t *testing.T) { | ||
// CAPI spec says this is optional, but @detiber says it's effectively required, so treat it as so. | ||
t.Run("machine_has_no_version_set", not_implemented) | ||
|
||
t.Run("there_is_no_hardware_available", not_implemented) | ||
|
||
// If for example CAPI changes key used to store bootstrap date, we shouldn't try to create machines | ||
// with empty bootstrap config, we should fail early instead. | ||
// | ||
// TODO: Is this needed? | ||
t.Run("bootstrap_config_is_empty", not_implemented) | ||
|
||
// TODO: Should we test those cases? Those are implementation details. | ||
t.Run("cluster_object_is_not_available", not_implemented) | ||
t.Run("tinkerbell_cluster_object_is_not_available", not_implemented) | ||
}) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/machine-infrastructure.html#normal-resource. | ||
t.Run("sets_tinkerbell_machine_provider_id", not_implemented) | ||
|
||
// To avoid sending patch request on every reconcilation. | ||
t.Run("does_not_patch_machine_object_when_there_is_no_pending_changes", | ||
machine_reconciliation_does_not_patch_machine_object_when_there_is_no_pending_changes) | ||
|
||
t.Run("fails_when", func(t *testing.T) { | ||
// At least one available hardware is required to be reserved for controlplane endpoinnt. | ||
t.Run("there_is_no_hardware_available", machine_reconciliation_fails_when_there_is_no_hardware_available) | ||
}) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior. | ||
t.Run("sets_controlplane_endpoint_using_available_hardware", | ||
machine_reconciliation_sets_controlplane_endpoint_using_available_hardware) | ||
|
||
// When multiple machines are created simultaneously, each should get different IP address. | ||
t.Run("assigns_unique_controlplane_endpoint_for_each_machine", | ||
machine_reconciliation_assigns_unique_hardware_for_controlplane_endpoint) | ||
|
||
// From https://cluster-api.sigs.k8s.io/developer/providers/cluster-infrastructure.html#behavior. | ||
t.Run("ensures_status_is_ready_when_hardware_is_available", | ||
machine_reconciliation_ensures_status_is_ready_when_hardware_is_available) | ||
} | ||
|
||
func machine_reconciliation_fails_when_there_is_no_hardware_available(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func machine_reconciliation_is_requeued_when_machine_is_paused(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func machine_reconciliation_is_requeued_when_machine_has_no_owner_set(t *testing.T) { | ||
t.Fatalf("not implemenetd") | ||
} | ||
|
||
func machine_reconciliation_does_not_patch_machine_object_when_there_is_no_pending_changes(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func machine_reconciliation_assigns_unique_hardware_for_controlplane_endpoint(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func machine_reconciliation_ensures_status_is_ready_when_hardware_is_available(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} | ||
|
||
func machine_reconciliation_sets_controlplane_endpoint_using_available_hardware(t *testing.T) { | ||
t.Fatalf("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters