Files
my-rook-config/tests/framework/installer/settings.go
T
Travis Nielsen 9ff0753514 test: run all integration tests against the local build
The integration tests must always be run against the local
build of rook, and an image should never be pulled from dockerhub.
To prevent pulling a release or master tag, the local build
will use a tag specific to the build and not ever published
elsewhere.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit a8a40428b0)
2021-09-22 07:39:42 -06:00

73 lines
2.1 KiB
Go

/*
Copyright 2021 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package installer
import (
"fmt"
"io/ioutil"
"net/http"
"path"
"regexp"
"time"
"github.com/pkg/errors"
"github.com/rook/rook/tests/framework/utils"
)
var imageMatch = regexp.MustCompile(`image: rook\/ceph:[a-z0-9.-]+`)
func readManifest(provider, filename string) string {
rootDir, err := utils.FindRookRoot()
if err != nil {
panic(err)
}
manifest := path.Join(rootDir, "cluster/examples/kubernetes/", provider, filename)
logger.Infof("Reading manifest: %s", manifest)
contents, err := ioutil.ReadFile(manifest)
if err != nil {
panic(errors.Wrapf(err, "failed to read manifest at %s", manifest))
}
return imageMatch.ReplaceAllString(string(contents), "image: rook/ceph:"+LocalBuildTag)
}
func readManifestFromGithub(rookVersion, provider, filename string) string {
url := fmt.Sprintf("https://raw.githubusercontent.com/rook/rook/%s/cluster/examples/kubernetes/%s/%s", rookVersion, provider, filename)
logger.Infof("Retrieving manifest: %s", url)
var response *http.Response
var err error
for i := 1; i <= 3; i++ {
// #nosec G107 This is only test code and is expected to read from a url
response, err = http.Get(url)
if err != nil {
if i == 3 {
panic(errors.Wrapf(err, "failed to read manifest from %s", url))
}
logger.Warningf("failed to read manifest from %s. retrying in 1sec. %v", url, err)
time.Sleep(time.Second)
continue
}
break
}
defer response.Body.Close()
content, err := ioutil.ReadAll(response.Body)
if err != nil {
panic(errors.Wrapf(err, "failed to read content from %s", url))
}
return string(content)
}