github.com/oam-dev/kubevela@v1.9.11/e2e/registry/registry_test.go (about)

     1  /*
     2  Copyright 2021 The KubeVela Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package e2e
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/oam-dev/kubevela/e2e"
    23  	"github.com/oam-dev/kubevela/references/cli"
    24  
    25  	. "github.com/onsi/ginkgo/v2"
    26  	. "github.com/onsi/gomega"
    27  )
    28  
    29  var (
    30  	registryConfigs = []cli.RegistryConfig{
    31  		{
    32  			Name:  "e2e-oss-registry",
    33  			URL:   "oss://registry.e2e.net",
    34  			Token: "",
    35  		},
    36  		{
    37  			Name:  "e2e-github-registry",
    38  			URL:   "https://github.com/oam-dev/catalog/tree/master/traits",
    39  			Token: "",
    40  		},
    41  	}
    42  )
    43  
    44  // TODO: change this into a mock UT to avoid remote call.
    45  
    46  var _ = Describe("test registry and trait/comp command", func() {
    47  	Context("registry", func() {
    48  		It("add and remove registry config", func() {
    49  			for _, config := range registryConfigs {
    50  				cli := fmt.Sprintf("vela registry config %s %s", config.Name, config.URL)
    51  				output, err := e2e.Exec(cli)
    52  				Expect(err).NotTo(HaveOccurred())
    53  				Expect(output).To(ContainSubstring(fmt.Sprintf("Successfully configured registry %s", config.Name)))
    54  			}
    55  		})
    56  
    57  		It("list registry config", func() {
    58  			cli := "vela registry ls"
    59  			output, err := e2e.Exec(cli)
    60  			Expect(err).NotTo(HaveOccurred())
    61  			Expect(output).To(ContainSubstring("NAME"))
    62  			Expect(output).To(ContainSubstring("URL"))
    63  			for _, config := range registryConfigs {
    64  				Expect(output).To(ContainSubstring(config.Name))
    65  				Expect(output).To(ContainSubstring(config.URL))
    66  			}
    67  		})
    68  
    69  		It("remove registry config", func() {
    70  			for _, config := range registryConfigs {
    71  				cli := fmt.Sprintf("vela registry remove %s", config.Name)
    72  				output, err := e2e.Exec(cli)
    73  				Expect(err).NotTo(HaveOccurred())
    74  				Expect(output).To(ContainSubstring(fmt.Sprintf("Successfully remove registry %s", config.Name)))
    75  			}
    76  
    77  		})
    78  	})
    79  
    80  	Context("list and install trait from registry", func() {
    81  		It("list trait from cluster", func() {
    82  			cli := "vela trait"
    83  			output, err := e2e.Exec(cli)
    84  			Expect(err).NotTo(HaveOccurred())
    85  			Expect(output).To(ContainSubstring("NAME"))
    86  			Expect(output).To(ContainSubstring("APPLIES-TO"))
    87  			Expect(output).To(ContainSubstring("pvc"))
    88  			Expect(output).To(ContainSubstring("[deployments.apps]"))
    89  		})
    90  		It("list trait from default registry", func() {
    91  			cli := "vela trait --discover"
    92  			output, err := e2e.Exec(cli)
    93  			Expect(err).NotTo(HaveOccurred())
    94  			Expect(output).To(ContainSubstring("Showing trait definition from registry: default"))
    95  			Expect(output).To(ContainSubstring("NAME"))
    96  			Expect(output).To(ContainSubstring("APPLIES-TO"))
    97  			Expect(output).To(ContainSubstring("STATUS"))
    98  			Expect(output).To(ContainSubstring("autoscale"))
    99  			Expect(output).To(ContainSubstring("[deployments.apps]"))
   100  		})
   101  
   102  		It("test list trait in raw url", func() {
   103  			cli := "vela trait --discover --url=oss://registry.kubevela.net"
   104  			output, err := e2e.Exec(cli)
   105  			Expect(err).NotTo(HaveOccurred())
   106  			Expect(output).To(SatisfyAll(ContainSubstring("Showing trait definition from url"), ContainSubstring("oss://registry.kubevela.net")))
   107  		})
   108  
   109  	})
   110  
   111  	Context("test list component definition", func() {
   112  		It("test list installed component definition", func() {
   113  			cli := "vela comp"
   114  			output, err := e2e.Exec(cli)
   115  			Expect(err).NotTo(HaveOccurred())
   116  			Expect(output).To(ContainSubstring("NAME"))
   117  			Expect(output).To(ContainSubstring("DEFINITION"))
   118  			Expect(output).To(ContainSubstring("raw"))
   119  			Expect(output).To(ContainSubstring("deployments.apps"))
   120  		})
   121  		It("test list with label", func() {
   122  			cli := "vela comp --label type=terraform"
   123  			output, err := e2e.Exec(cli)
   124  			Expect(err).NotTo(HaveOccurred())
   125  			Expect(output).NotTo(ContainSubstring("raw"))
   126  			Expect(output).To(ContainSubstring("alibaba-ack"))
   127  		})
   128  	})
   129  })