-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/karmadactl/addons: unit test install addons
In this commit, we unit test install addons to make sure the following addons `karmada-descheduler`, `karmada-metrics-adapter`, `karmada-scheduler-estimator`, and `karmada-search` are already configured. Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
- Loading branch information
1 parent
6c6281f
commit f7feac0
Showing
1 changed file
with
55 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,55 @@ | ||
package install | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/karmada-io/karmada/pkg/karmadactl/addons/descheduler" | ||
"github.com/karmada-io/karmada/pkg/karmadactl/addons/estimator" | ||
addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" | ||
"github.com/karmada-io/karmada/pkg/karmadactl/addons/metricsadapter" | ||
"github.com/karmada-io/karmada/pkg/karmadactl/addons/search" | ||
) | ||
|
||
func TestInstall(t *testing.T) { | ||
// Call the function to install addons. | ||
Install() | ||
|
||
tests := []struct { | ||
name string | ||
key string | ||
expectedAddon interface{} | ||
}{ | ||
{ | ||
name: "Install_WithKarmadaDeschedulerAddon_Installed", | ||
key: "karmada-descheduler", | ||
expectedAddon: descheduler.AddonDescheduler, | ||
}, | ||
{ | ||
name: "Install_WithKarmadaMetricsAdapterAddon_Installed", | ||
key: "karmada-metrics-adapter", | ||
expectedAddon: metricsadapter.AddonMetricsAdapter, | ||
}, | ||
{ | ||
name: "Install_WithKarmadaSchedulerEstimatorAddon_Installed", | ||
key: "karmada-scheduler-estimator", | ||
expectedAddon: estimator.AddonEstimator, | ||
}, | ||
{ | ||
name: "Install_WithKarmadaSearchAddon_Installed", | ||
key: "karmada-search", | ||
expectedAddon: search.AddonSearch, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
actualAddon, exists := addonsinit.Addons[tt.key] | ||
if !exists { | ||
t.Fatalf("Expected addon %s to be registered, but it was not found", tt.key) | ||
} | ||
if !reflect.DeepEqual(actualAddon, tt.expectedAddon) { | ||
t.Errorf("Expected addon %s to be %v, but got %v", tt.key, tt.expectedAddon, actualAddon) | ||
} | ||
}) | ||
} | ||
} |