diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 29619769ba..27174e425e 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -9,6 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '~1.16' - run: make e2e-local NODES=2 JUNIT_DIRECTORY=./artifacts/ - name: Archive Test Artifacts # test results, failed or not, are always uploaded. if: ${{ always() }} diff --git a/test/e2e/bundle_e2e_test.go b/test/e2e/bundle_e2e_test.go index 8354834a4d..4552d80db3 100644 --- a/test/e2e/bundle_e2e_test.go +++ b/test/e2e/bundle_e2e_test.go @@ -2,6 +2,7 @@ package e2e import ( "context" + _ "embed" "encoding/json" "github.com/ghodss/yaml" @@ -19,9 +20,11 @@ import ( "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient" "github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx" - "github.com/operator-framework/operator-lifecycle-manager/test/e2e/testdata/vpa" ) +//go:embed testdata/vpa/crd.yaml +var vpaCRDraw []byte + var _ = Describe("Installing bundles with new object types", func() { var ( kubeClient operatorclient.ClientInterface @@ -56,10 +59,8 @@ var _ = Describe("Installing bundles with new object types", func() { ) // create VPA CRD on cluster - y, err := vpa.Asset("test/e2e/testdata/vpa/crd.yaml") - Expect(err).ToNot(HaveOccurred(), "could not read vpa bindata") - - data, err := yaml.YAMLToJSON(y) + Expect(vpaCRDraw).ToNot(BeEmpty(), "could not read vpa bindata") + data, err := yaml.YAMLToJSON(vpaCRDraw) Expect(err).ToNot(HaveOccurred(), "could not convert vpa crd to json") err = json.Unmarshal(data, &vpaCRD) diff --git a/test/e2e/testdata/vpa/crd.yaml b/test/e2e/testdata/vpa/crd.yaml index 77547abe42..ff43cb096b 100644 --- a/test/e2e/testdata/vpa/crd.yaml +++ b/test/e2e/testdata/vpa/crd.yaml @@ -1,4 +1,4 @@ -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: verticalpodautoscalers.autoscaling.k8s.io @@ -13,52 +13,40 @@ spec: kind: VerticalPodAutoscaler shortNames: - vpa - version: v1beta1 versions: - name: v1beta1 served: false storage: false + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + name: + type: string - name: v1beta2 served: true storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + name: + type: string - name: v1 served: true storage: false - validation: - # openAPIV3Schema is the schema for validating custom objects. - openAPIV3Schema: - type: object - properties: - spec: + schema: + openAPIV3Schema: type: object - required: [] properties: - targetRef: - type: object - updatePolicy: + spec: type: object properties: - updateMode: + name: type: string - resourcePolicy: - type: object - properties: - containerPolicies: - type: array - items: - type: object - properties: - containerName: - type: string - mode: - type: string - enum: ["Auto", "Off"] - minAllowed: - type: object - maxAllowed: - type: object - controlledResources: - type: array - items: - type: string - enum: ["cpu", "memory"] \ No newline at end of file diff --git a/test/e2e/testdata/vpa/vpa_bindata.go b/test/e2e/testdata/vpa/vpa_bindata.go deleted file mode 100644 index 4518ba6373..0000000000 --- a/test/e2e/testdata/vpa/vpa_bindata.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by go-bindata. (@generated) DO NOT EDIT. - - //Package vpa generated by go-bindata.// sources: -// test/e2e/testdata/vpa/crd.yaml -package vpa - -import ( - "bytes" - "compress/gzip" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - "time" -) - -func bindataRead(data []byte, name string) ([]byte, error) { - gz, err := gzip.NewReader(bytes.NewBuffer(data)) - if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) - } - - var buf bytes.Buffer - _, err = io.Copy(&buf, gz) - clErr := gz.Close() - - if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) - } - if clErr != nil { - return nil, err - } - - return buf.Bytes(), nil -} - -type asset struct { - bytes []byte - info os.FileInfo -} - -type bindataFileInfo struct { - name string - size int64 - mode os.FileMode - modTime time.Time -} - -// Name return file name -func (fi bindataFileInfo) Name() string { - return fi.name -} - -// Size return file size -func (fi bindataFileInfo) Size() int64 { - return fi.size -} - -// Mode return file mode -func (fi bindataFileInfo) Mode() os.FileMode { - return fi.mode -} - -// ModTime return file modify time -func (fi bindataFileInfo) ModTime() time.Time { - return fi.modTime -} - -// IsDir return file whether a directory -func (fi bindataFileInfo) IsDir() bool { - return fi.mode&os.ModeDir != 0 -} - -// Sys return file is sys mode -func (fi bindataFileInfo) Sys() interface{} { - return nil -} - -var _testE2eTestdataVpaCrdYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x55\xc1\x6e\xdb\x30\x0c\xbd\xe7\x2b\x08\xef\xba\x26\xe8\x0a\xac\x9b\x6f\xc5\x76\xd9\x61\x5d\xd1\x01\xbd\x14\x3d\x30\x32\xe3\x68\x95\x45\x8d\xa2\xb2\xe6\xef\x07\x39\x76\x9c\xb4\x71\x92\x43\x79\xb2\xc9\xf7\x1e\xa9\x47\x2b\xc1\x60\x1f\x48\xa2\x65\x5f\x02\x06\x4b\x2f\x4a\x3e\xbf\xc5\xe9\xf3\x97\x38\xb5\x3c\x5b\x5d\xce\x49\xf1\x72\xf2\x6c\x7d\x55\xc2\xb7\x14\x95\x9b\x7b\x8a\x9c\xc4\xd0\x77\x5a\x58\x6f\xd5\xb2\x9f\x34\xa4\x58\xa1\x62\x39\x01\xf0\xd8\x50\x09\x2b\x12\xb5\x06\x5d\xe0\x0a\x93\x72\x34\xe8\x48\xe2\xb4\x7f\xb6\xbe\xee\x5a\x4c\x00\xd0\x7b\x56\xcc\x42\x31\x0b\x00\x14\x18\xec\x05\x86\x20\xbc\xa2\x6a\xfa\x9c\xe6\x24\x9e\x94\x32\xbc\x28\xa1\x58\xaa\x86\x58\xce\x66\xb5\xd5\x65\x9a\x4f\x0d\x37\xb3\x01\xb3\xfb\x18\x92\x73\xb3\xcf\x57\xd7\x5f\xaf\x8b\x49\x0c\x64\xb2\x7a\x2d\x9c\x42\x09\x07\x07\x89\x86\x03\x95\x70\x8b\x0d\xc5\x80\x86\xaa\xee\x38\xdd\x58\xc1\x25\x41\x37\x76\xb6\x16\x12\xad\xaf\x93\x43\x19\x01\xb5\x98\x8d\x97\x0f\x5d\xfd\x8e\xab\x9b\xfd\x7a\x5c\xb2\xe8\xed\xd0\x16\xe0\x02\x56\x01\x27\x90\x35\x37\xbb\xea\xd7\xb2\x4d\x75\xd0\x8b\xde\xfd\x6d\xbd\x15\x24\x59\x51\x55\xc2\x02\x5d\xa4\x3e\xa7\x2c\x58\xd3\x6e\x72\x9f\xfc\xe9\x15\x59\x25\xbd\xe1\x6e\x73\x03\xf5\x0c\x56\xdf\x71\x85\xce\x56\xed\xda\x37\xc3\x7f\x00\x0e\xe4\x6f\xee\x7e\x3c\x5c\xfd\x36\x4b\x6a\x10\x6c\x04\x5d\x12\xc4\xcd\xdb\x82\x65\xcb\xf1\x35\x98\xf6\x63\x04\x9e\xff\x21\xa3\x71\xda\x4a\xbc\x12\xe8\xfd\xd3\x75\x5e\xeb\x06\xd9\xa5\x82\x70\xc8\x1b\x18\x4c\x06\xe8\x3f\x91\x3e\x0e\xd0\x72\x08\xfd\x4d\x56\xf2\xe9\x1e\x9f\x76\xd2\x87\x14\x5b\x15\x94\x9a\xf4\x9e\x16\xfb\xe9\x51\x79\x80\x14\x2a\x54\xba\x63\x67\xcd\xfa\x6c\xd2\xf8\x00\x83\xe4\x4f\xae\xe8\x6d\xad\x17\x8d\x2a\xd6\xd7\x7b\x65\xe9\xae\xfa\xbb\xce\x62\xd8\x2b\x5a\x4f\xd2\xaa\x1e\x84\xf4\xda\x28\x82\xeb\x03\x55\xab\xd4\x1c\xa4\x1d\x1d\xea\xf4\x68\xaf\x06\xcc\x97\x70\x0c\x74\xc4\xb5\x21\x9a\x11\xc3\xcf\x16\x00\x20\x9f\x9a\x12\x1e\x8b\xfc\x23\x51\x7c\x84\xe2\xd7\x62\x51\x3c\x8d\xb5\xb3\xfe\xc6\x39\xfe\x47\xd5\xa9\xa6\x47\xfc\x01\x68\xf0\xe5\x3d\x64\xb2\x8d\xc2\xce\x51\xd5\xff\x63\x8c\x3a\x7e\x6a\xdf\x9b\x38\xb2\xf5\x5d\x91\x13\x86\x0e\x96\x9a\x90\xb2\xa3\x0d\x35\x2c\xeb\xe2\xe9\x7f\x00\x00\x00\xff\xff\xf5\x75\x22\xd7\x0d\x07\x00\x00") - -func testE2eTestdataVpaCrdYamlBytes() ([]byte, error) { - return bindataRead( - _testE2eTestdataVpaCrdYaml, - "test/e2e/testdata/vpa/crd.yaml", - ) -} - -func testE2eTestdataVpaCrdYaml() (*asset, error) { - bytes, err := testE2eTestdataVpaCrdYamlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "test/e2e/testdata/vpa/crd.yaml", size: 1805, mode: os.FileMode(420), modTime: time.Unix(1594757779, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - -// Asset loads and returns the asset for the given name. -// It returns an error if the asset could not be found or -// could not be loaded. -func Asset(name string) ([]byte, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { - a, err := f() - if err != nil { - return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) - } - return a.bytes, nil - } - return nil, fmt.Errorf("Asset %s not found", name) -} - -// MustAsset is like Asset but panics when Asset would return an error. -// It simplifies safe initialization of global variables. -func MustAsset(name string) []byte { - a, err := Asset(name) - if err != nil { - panic("asset: Asset(" + name + "): " + err.Error()) - } - - return a -} - -// AssetInfo loads and returns the asset info for the given name. -// It returns an error if the asset could not be found or -// could not be loaded. -func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { - a, err := f() - if err != nil { - return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) - } - return a.info, nil - } - return nil, fmt.Errorf("AssetInfo %s not found", name) -} - -// AssetNames returns the names of the assets. -func AssetNames() []string { - names := make([]string, 0, len(_bindata)) - for name := range _bindata { - names = append(names, name) - } - return names -} - -// _bindata is a table, holding each asset generator, mapped to its name. -var _bindata = map[string]func() (*asset, error){ - "test/e2e/testdata/vpa/crd.yaml": testE2eTestdataVpaCrdYaml, -} - -// AssetDir returns the file names below a certain -// directory embedded in the file by go-bindata. -// For example if you run go-bindata on data/... and data contains the -// following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png -// then AssetDir("data") would return []string{"foo.txt", "img"} -// AssetDir("data/img") would return []string{"a.png", "b.png"} -// AssetDir("foo.txt") and AssetDir("notexist") would return an error -// AssetDir("") will return []string{"data"}. -func AssetDir(name string) ([]string, error) { - node := _bintree - if len(name) != 0 { - cannonicalName := strings.Replace(name, "\\", "/", -1) - pathList := strings.Split(cannonicalName, "/") - for _, p := range pathList { - node = node.Children[p] - if node == nil { - return nil, fmt.Errorf("Asset %s not found", name) - } - } - } - if node.Func != nil { - return nil, fmt.Errorf("Asset %s not found", name) - } - rv := make([]string, 0, len(node.Children)) - for childName := range node.Children { - rv = append(rv, childName) - } - return rv, nil -} - -type bintree struct { - Func func() (*asset, error) - Children map[string]*bintree -} - -var _bintree = &bintree{nil, map[string]*bintree{ - "test": &bintree{nil, map[string]*bintree{ - "e2e": &bintree{nil, map[string]*bintree{ - "testdata": &bintree{nil, map[string]*bintree{ - "vpa": &bintree{nil, map[string]*bintree{ - "crd.yaml": &bintree{testE2eTestdataVpaCrdYaml, map[string]*bintree{}}, - }}, - }}, - }}, - }}, -}} - -// RestoreAsset restores an asset under the given directory -func RestoreAsset(dir, name string) error { - data, err := Asset(name) - if err != nil { - return err - } - info, err := AssetInfo(name) - if err != nil { - return err - } - err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) - if err != nil { - return err - } - err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) - if err != nil { - return err - } - err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) - if err != nil { - return err - } - return nil -} - -// RestoreAssets restores an asset under the given directory recursively -func RestoreAssets(dir, name string) error { - children, err := AssetDir(name) - // File - if err != nil { - return RestoreAsset(dir, name) - } - // Dir - for _, child := range children { - err = RestoreAssets(dir, filepath.Join(name, child)) - if err != nil { - return err - } - } - return nil -} - -func _filePath(dir, name string) string { - cannonicalName := strings.Replace(name, "\\", "/", -1) - return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) -}