diff --git a/tests/asset-store/testsuite/asset.go b/tests/asset-store/testsuite/asset.go index e3c26b31f45e..0d41a212944a 100644 --- a/tests/asset-store/testsuite/asset.go +++ b/tests/asset-store/testsuite/asset.go @@ -35,8 +35,8 @@ func newAsset(dynamicCli dynamic.Interface, namespace string, bucketName string, } } -func (a *asset) CreateMany(assets []assetData, testId string, callbacks ...func(...interface{})) ([]string, error) { - var resourceVersions []string +func (a *asset) CreateMany(assets []assetData, testId string, callbacks ...func(...interface{})) (string, error) { + var initialResourceVersion string for _, asset := range assets { asset := &v1alpha2.Asset{ TypeMeta: metav1.TypeMeta{ @@ -67,14 +67,17 @@ func (a *asset) CreateMany(assets []assetData, testId string, callbacks ...func( if err != nil { return err } - resourceVersions = append(resourceVersions, resourceVersion) + if initialResourceVersion != "" { + return nil + } + initialResourceVersion = resourceVersion return nil }, callbacks...) if err != nil { - return nil, errors.Wrapf(err, "while creating Asset %s in namespace %s", asset.Name, a.Namespace) + return initialResourceVersion, errors.Wrapf(err, "while creating Asset %s in namespace %s", asset.Name, a.Namespace) } } - return resourceVersions, nil + return initialResourceVersion, nil } func (a *asset) WaitForStatusesReady(assets []assetData, resourceVersion string) error { diff --git a/tests/asset-store/testsuite/clusterasset.go b/tests/asset-store/testsuite/clusterasset.go index 99e7422a1f2e..12168c640665 100644 --- a/tests/asset-store/testsuite/clusterasset.go +++ b/tests/asset-store/testsuite/clusterasset.go @@ -57,7 +57,7 @@ func (a *clusterAsset) CreateMany(assets []assetData, testId string, callbacks . }, }, } - //FIXME Handle this + //FIXME Handle this | not _, err := a.resCli.Create(asset, callbacks...) if err != nil { return errors.Wrapf(err, "while creating ClusterAsset %s", asset.Name) @@ -67,26 +67,16 @@ func (a *clusterAsset) CreateMany(assets []assetData, testId string, callbacks . return nil } -func (a *clusterAsset) WaitForStatusesReady(assets []assetData) error { - //FIXME - err := waiter.WaitAtMost(func() (bool, error) { - for _, asset := range assets { - res, err := a.Get(asset.Name) - if err != nil { - return false, err - } - - if res.Status.Phase != v1alpha2.AssetReady { - return false, nil - } - } - - return true, nil - }, a.waitTimeout) +func (a *clusterAsset) WaitForStatusesReady(assets []assetData, initialResourceVersion string) error { + var assetNames []string + for _, asset := range assets { + assetNames = append(assetNames, asset.Name) + } + waitForStatusesReady := buildWaitForStatusesReady(a.resCli.ResCli, a.waitTimeout, assetNames...) + err := waitForStatusesReady(initialResourceVersion) if err != nil { - return errors.Wrapf(err, "while waiting for ready ClusterAsset resources") + return errors.Wrapf(err, "while waiting for ready Asset resources") } - return nil } diff --git a/tests/asset-store/testsuite/testsuite.go b/tests/asset-store/testsuite/testsuite.go index c6de2ff02780..740a7cc06d2a 100644 --- a/tests/asset-store/testsuite/testsuite.go +++ b/tests/asset-store/testsuite/testsuite.go @@ -134,17 +134,17 @@ func (t *TestSuite) Run() { err = t.clusterAsset.DeleteLeftovers(t.testId) failOnError(t.g, err) + // FIXME break to 2 different methods due to resourceVersion t.t.Log("Creating assets...") - var assetVersions []string - assetVersions, err = t.createAssets(uploadResult) + resourceVersion, err = t.createAssets(uploadResult) failOnError(t.g, err) t.t.Log("Waiting for assets to have ready phase...") - err = t.asset.WaitForStatusesReady(t.assetDetails, assetVersions[0]) + err = t.asset.WaitForStatusesReady(t.assetDetails, resourceVersion) failOnError(t.g, err) t.t.Log("Waiting for cluster assets to have ready phase...") - err = t.clusterAsset.WaitForStatusesReady(t.assetDetails) + err = t.clusterAsset.WaitForStatusesReady(t.assetDetails, resourceVersion) failOnError(t.g, err) files, err := t.populateUploadedFiles() @@ -172,7 +172,7 @@ func (t *TestSuite) Cleanup() { err := t.clusterBucket.Delete() failOnError(t.g, err) - err = t.deleteBuckets() + err = t.bucket.Delete() failOnError(t.g, err) err = t.namespace.Delete() @@ -195,20 +195,20 @@ func (t *TestSuite) uploadTestFiles() (*upload.Response, error) { return uploadResult, nil } -func (t *TestSuite) createAssets(uploadResult *upload.Response) ([]string, error) { +func (t *TestSuite) createAssets(uploadResult *upload.Response) (string, error) { t.assetDetails = convertToAssetResourceDetails(uploadResult, t.cfg.CommonAssetPrefix) - resourceVersions, err := t.asset.CreateMany(t.assetDetails, t.testId, t.t.Log) + assetVersion, err := t.asset.CreateMany(t.assetDetails, t.testId, t.t.Log) if err != nil { - return nil, err + return assetVersion, err } err = t.clusterAsset.CreateMany(t.assetDetails, t.testId, t.t.Log) if err != nil { - return nil, err + return assetVersion, err } - return resourceVersions, nil + return assetVersion, nil } func (t *TestSuite) populateUploadedFiles() ([]uploadedFile, error) { @@ -250,14 +250,6 @@ func (t *TestSuite) verifyDeletedFiles(files []uploadedFile) error { return nil } -func (t *TestSuite) deleteBuckets() error { - err := t.bucket.Delete() - if err != nil { - return err - } - return nil -} - func failOnError(g *gomega.GomegaWithT, err error) { g.Expect(err).NotTo(gomega.HaveOccurred()) }