From dc880c2a99ddeb7ddde3ad72583fdb3887430e0b Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 9 May 2023 15:48:55 +0200 Subject: [PATCH] connectivity: Add GetTest method Signed-off-by: Fabio Falzoi --- connectivity/check/context.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/connectivity/check/context.go b/connectivity/check/context.go index 78e33d8c7c..8e7301280e 100644 --- a/connectivity/check/context.go +++ b/connectivity/check/context.go @@ -239,6 +239,22 @@ func (ct *ConnectivityTest) NewTest(name string) *Test { return t } +// GetTest returns the test scope for test named "name" if found, +// a non-nil error otherwise. +func (ct *ConnectivityTest) GetTest(name string) (*Test, error) { + if _, ok := ct.testNames[name]; !ok { + return nil, fmt.Errorf("test %s not found", name) + } + + for _, t := range ct.tests { + if t.name == name { + return t, nil + } + } + + panic("missing test descriptor for a registered name") +} + // SetupAndValidate sets up and validates the connectivity test infrastructure // such as the client pods and validates the deployment of them along with // Cilium. This must be run before Run() is called.