-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom disable or enable scheduler plugin
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
- Loading branch information
1 parent
5ecb4ba
commit 87a42a1
Showing
5 changed files
with
120 additions
and
1 deletion.
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
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
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
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,59 @@ | ||
package runtime | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/karmada-io/karmada/pkg/scheduler/framework" | ||
) | ||
|
||
func TestRegistry_Filter(t *testing.T) { | ||
plugins := []string{"bar", "foo", "fuzz"} | ||
var r = make(Registry) | ||
for _, name := range plugins { | ||
_ = r.Register(name, func() (framework.Plugin, error) { | ||
return nil, nil | ||
}) | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
curPlugins []string | ||
r Registry | ||
expectedPlugins []string | ||
}{ | ||
{ | ||
name: "enable foo", | ||
curPlugins: []string{"foo"}, // --plugins=foo | ||
r: r, | ||
expectedPlugins: []string{"foo"}, | ||
}, | ||
{ | ||
name: "enable all", | ||
curPlugins: []string{"*"}, // --plugins=* | ||
r: r, | ||
expectedPlugins: []string{"bar", "foo", "fuzz"}, | ||
}, | ||
{ | ||
name: "disable foo", | ||
curPlugins: []string{"*", "-foo"}, // --plugins=*,-foo | ||
r: r, | ||
expectedPlugins: []string{"bar", "fuzz"}, | ||
}, | ||
{ | ||
name: "wrong disable foo", | ||
curPlugins: []string{"-foo", "*"}, // --plugins=-foo,* | ||
r: r, | ||
expectedPlugins: []string{"bar", "foo", "fuzz"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.r.Filter(tt.curPlugins); !reflect.DeepEqual(got.FactoryNames(), tt.expectedPlugins) { | ||
t.Errorf("Filter() = %v, want %v", got.FactoryNames(), tt.expectedPlugins) | ||
} | ||
}) | ||
} | ||
|
||
} |
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