-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cnf ran: ztp acm crs and clusters app tests
This PR adds the first two tests cases for the ZTP functional test suite along with the helpers they require. Additionally, the OCP versions of each cluster are now logged.
- Loading branch information
Showing
13 changed files
with
446 additions
and
3 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,56 @@ | ||
package helper | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/golang/glog" | ||
"github.com/openshift-kni/eco-goinfra/pkg/clients" | ||
"github.com/openshift-kni/eco-goinfra/pkg/ocm" | ||
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/ztp/internal/tsparams" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
) | ||
|
||
// WaitForPolicyToExist waits for up to the specified timeout until the policy exists. | ||
func WaitForPolicyToExist( | ||
client *clients.Settings, name, namespace string, timeout time.Duration) (*ocm.PolicyBuilder, error) { | ||
var policy *ocm.PolicyBuilder | ||
|
||
err := wait.PollUntilContextTimeout( | ||
context.TODO(), tsparams.ArgoCdChangeInterval, timeout, true, func(ctx context.Context) (bool, error) { | ||
var err error | ||
policy, err = ocm.PullPolicy(client, name, namespace) | ||
|
||
if err == nil { | ||
return true, nil | ||
} | ||
|
||
if strings.Contains(err.Error(), "does not exist") { | ||
return false, nil | ||
} | ||
|
||
return false, err | ||
}) | ||
|
||
return policy, err | ||
} | ||
|
||
// WaitUntilSearchCollectorEnabled waits up to timeout until the KAC has the search collector addon enabled. | ||
func WaitUntilSearchCollectorEnabled(kac *ocm.KACBuilder, timeout time.Duration) error { | ||
glog.V(tsparams.LogLevel).Infof( | ||
"Waiting until search collector is enabled for KAC %s in namespace %s", kac.Definition.Name, kac.Definition.Namespace) | ||
|
||
return wait.PollUntilContextTimeout( | ||
context.TODO(), tsparams.ArgoCdChangeInterval, timeout, true, func(ctx context.Context) (bool, error) { | ||
if !kac.Exists() { | ||
glog.V(tsparams.LogLevel).Infof( | ||
"KAC %s in namespace %s does not exist", kac.Definition.Name, kac.Definition.Namespace) | ||
|
||
return false, fmt.Errorf("kac %s in namespace %s does not exist", kac.Definition.Name, kac.Definition.Namespace) | ||
} | ||
|
||
return kac.Definition.Spec.SearchCollectorConfig.Enabled, nil | ||
}) | ||
} |
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
Oops, something went wrong.