mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
More tests without cluster (#6303)
* Run build-images command without cluster * Test odo remove binding without cluster * Make odo describe component work without cluster * Tests: configure cluster depending on nocluster label * Make odo list component work when --namespace is not used * Test odo list component before deployment without cluster * Some Generic tests * Unset KUBERNETES_SERVICE_HOST to disable in-cluster config * Set KUBECONFIG to empty file for no-cluster tests * Run no-cluster tests on Windows * Fix ListIngresses related changes * Add warning/error when no cluster connection is available
This commit is contained in:
@@ -80,9 +80,10 @@ function Run-Test {
|
|||||||
Shout "Create Binary"
|
Shout "Create Binary"
|
||||||
make install
|
make install
|
||||||
Shout "Running test"
|
Shout "Running test"
|
||||||
make test-integration-cluster | tee -a C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\$LOGFILE
|
make test-integration-no-cluster | tee -a C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\$LOGFILE
|
||||||
|
make test-integration-cluster | tee -a C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\$LOGFILE
|
||||||
Check-ExitCode $LASTEXITCODE
|
Check-ExitCode $LASTEXITCODE
|
||||||
make test-e2e | tee -a C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\$LOGFILE
|
make test-e2e | tee -a C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\$LOGFILE
|
||||||
Check-ExitCode $LASTEXITCODE
|
Check-ExitCode $LASTEXITCODE
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|||||||
@@ -205,9 +205,13 @@ func ListAllClusterComponents(client kclient.ClientInterface, namespace string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ListAllComponents(client kclient.ClientInterface, namespace string, devObj *parser.DevfileObj, componentName string) ([]api.ComponentAbstract, string, error) {
|
func ListAllComponents(client kclient.ClientInterface, namespace string, devObj *parser.DevfileObj, componentName string) ([]api.ComponentAbstract, string, error) {
|
||||||
devfileComponents, err := ListAllClusterComponents(client, namespace)
|
var devfileComponents []api.ComponentAbstract
|
||||||
if err != nil {
|
var err error
|
||||||
return nil, "", err
|
if client != nil {
|
||||||
|
devfileComponents, err = ListAllClusterComponents(client, namespace)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localComponent := api.ComponentAbstract{
|
localComponent := api.ComponentAbstract{
|
||||||
@@ -254,9 +258,13 @@ func getResourcesForComponent(
|
|||||||
// GetRunningModes returns the list of modes on which a "name" component is deployed, by looking into namespace
|
// GetRunningModes returns the list of modes on which a "name" component is deployed, by looking into namespace
|
||||||
// the resources deployed with matching labels, based on the "odo.dev/mode" label
|
// the resources deployed with matching labels, based on the "odo.dev/mode" label
|
||||||
func GetRunningModes(ctx context.Context, client kclient.ClientInterface, name string) (api.RunningModes, error) {
|
func GetRunningModes(ctx context.Context, client kclient.ClientInterface, name string) (api.RunningModes, error) {
|
||||||
|
if client == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
list, err := getResourcesForComponent(ctx, client, name, client.GetCurrentNamespace())
|
list, err := getResourcesForComponent(ctx, client, name, client.GetCurrentNamespace())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.RunningModes{}, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(list) == 0 {
|
if len(list) == 0 {
|
||||||
@@ -333,6 +341,10 @@ func GetDevfileInfoFromCluster(ctx context.Context, client kclient.ClientInterfa
|
|||||||
// it only returns the resources created with Deploy mode;
|
// it only returns the resources created with Deploy mode;
|
||||||
// it fetches resources from the cluster that match label and return.
|
// it fetches resources from the cluster that match label and return.
|
||||||
func ListRoutesAndIngresses(client kclient.ClientInterface, componentName, appName string) (ings []api.ConnectionData, routes []api.ConnectionData, err error) {
|
func ListRoutesAndIngresses(client kclient.ClientInterface, componentName, appName string) (ings []api.ConnectionData, routes []api.ConnectionData, err error) {
|
||||||
|
if client == nil {
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
selector := odolabels.GetSelector(componentName, appName, odolabels.ComponentDeployMode, false)
|
selector := odolabels.GetSelector(componentName, appName, odolabels.ComponentDeployMode, false)
|
||||||
|
|
||||||
k8sIngresses, err := client.ListIngresses(client.GetCurrentNamespace(), selector)
|
k8sIngresses, err := client.ListIngresses(client.GetCurrentNamespace(), selector)
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ func TestGetRunningModes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
name: "aname",
|
name: "aname",
|
||||||
},
|
},
|
||||||
want: api.RunningModes{},
|
want: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@@ -70,15 +70,20 @@ func (o *ComponentOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Name is passed, and odo does not have access to devfile.yaml; if Name is passed, then we assume that odo does not have access to the devfile.yaml
|
// 2. Name is passed, and odo does not have access to devfile.yaml; if Name is passed, then we assume that odo does not have access to the devfile.yaml
|
||||||
if o.namespaceFlag != "" {
|
if o.clientset.KubernetesClient != nil {
|
||||||
o.clientset.KubernetesClient.SetNamespace(o.namespaceFlag)
|
if o.namespaceFlag != "" {
|
||||||
} else {
|
o.clientset.KubernetesClient.SetNamespace(o.namespaceFlag)
|
||||||
o.namespaceFlag = o.clientset.KubernetesClient.GetCurrentNamespace()
|
} else {
|
||||||
|
o.namespaceFlag = o.clientset.KubernetesClient.GetCurrentNamespace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ComponentOptions) Validate(ctx context.Context) (err error) {
|
func (o *ComponentOptions) Validate(ctx context.Context) (err error) {
|
||||||
|
if o.clientset.KubernetesClient == nil {
|
||||||
|
log.Warning("No connection to cluster defined")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +110,10 @@ func (o *ComponentOptions) run(ctx context.Context) (result api.Component, devfi
|
|||||||
|
|
||||||
// describeNamedComponent describes a component given its name
|
// describeNamedComponent describes a component given its name
|
||||||
func (o *ComponentOptions) describeNamedComponent(ctx context.Context, name string) (result api.Component, devfileObj *parser.DevfileObj, err error) {
|
func (o *ComponentOptions) describeNamedComponent(ctx context.Context, name string) (result api.Component, devfileObj *parser.DevfileObj, err error) {
|
||||||
|
if o.clientset.KubernetesClient == nil {
|
||||||
|
return api.Component{}, nil, errors.New("cluster is non accessible")
|
||||||
|
}
|
||||||
|
|
||||||
runningIn, err := component.GetRunningModes(ctx, o.clientset.KubernetesClient, name)
|
runningIn, err := component.GetRunningModes(ctx, o.clientset.KubernetesClient, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Component{}, nil, err
|
return api.Component{}, nil, err
|
||||||
@@ -283,7 +292,7 @@ func NewCmdComponent(name, fullName string) *cobra.Command {
|
|||||||
}
|
}
|
||||||
componentCmd.Flags().StringVar(&o.nameFlag, "name", "", "Name of the component to describe, optional. By default, the component in the local devfile is described")
|
componentCmd.Flags().StringVar(&o.nameFlag, "name", "", "Name of the component to describe, optional. By default, the component in the local devfile is described")
|
||||||
componentCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace in which to find the component to describe, optional. By default, the current namespace defined in kubeconfig is used")
|
componentCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace in which to find the component to describe, optional. By default, the current namespace defined in kubeconfig is used")
|
||||||
clientset.Add(componentCmd, clientset.KUBERNETES, clientset.STATE)
|
clientset.Add(componentCmd, clientset.KUBERNETES_NULLABLE, clientset.STATE)
|
||||||
commonflags.UseOutputFlag(componentCmd)
|
commonflags.UseOutputFlag(componentCmd)
|
||||||
|
|
||||||
return componentCmd
|
return componentCmd
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -100,6 +101,14 @@ func (o *DevOptions) Validate(ctx context.Context) error {
|
|||||||
if o.debugFlag && !libdevfile.HasDebugCommand(devfileObj.Data) {
|
if o.debugFlag && !libdevfile.HasDebugCommand(devfileObj.Data) {
|
||||||
return clierrors.NewNoCommandInDevfileError("debug")
|
return clierrors.NewNoCommandInDevfileError("debug")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platform := fcontext.GetRunOn(ctx)
|
||||||
|
switch platform {
|
||||||
|
case commonflags.RunOnCluster:
|
||||||
|
if o.clientset.KubernetesClient == nil {
|
||||||
|
return errors.New("no connection to cluster defined")
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import (
|
|||||||
"github.com/redhat-developer/odo/pkg/odo/cli/ui"
|
"github.com/redhat-developer/odo/pkg/odo/cli/ui"
|
||||||
"github.com/redhat-developer/odo/pkg/odo/commonflags"
|
"github.com/redhat-developer/odo/pkg/odo/commonflags"
|
||||||
|
|
||||||
dfutil "github.com/devfile/library/pkg/util"
|
|
||||||
|
|
||||||
"github.com/redhat-developer/odo/pkg/component"
|
"github.com/redhat-developer/odo/pkg/component"
|
||||||
|
|
||||||
"github.com/redhat-developer/odo/pkg/log"
|
"github.com/redhat-developer/odo/pkg/log"
|
||||||
@@ -59,20 +57,14 @@ func (o *ListOptions) SetClientset(clientset *clientset.Clientset) {
|
|||||||
|
|
||||||
// Complete ...
|
// Complete ...
|
||||||
func (lo *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
func (lo *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {
|
||||||
|
|
||||||
// Check to see if KUBECONFIG exists, and if not, error the user that we would not be able to get cluster information
|
|
||||||
// Do this before anything else, or else we will just error out with the:
|
|
||||||
// invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
|
|
||||||
// instead
|
|
||||||
if !dfutil.CheckKubeConfigExist() {
|
|
||||||
return errors.New("KUBECONFIG not found. Unable to retrieve cluster information. Please set your Kubernetes configuration via KUBECONFIG env variable or ~/.kube/config")
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the namespace flag has been passed, we will search there.
|
// If the namespace flag has been passed, we will search there.
|
||||||
// if it hasn't, we will search from the default project / namespace.
|
// if it hasn't, we will search from the default project / namespace.
|
||||||
if lo.namespaceFlag != "" {
|
if lo.namespaceFlag != "" {
|
||||||
|
if lo.clientset.KubernetesClient == nil {
|
||||||
|
return errors.New("cluster is non accessible")
|
||||||
|
}
|
||||||
lo.namespaceFilter = lo.namespaceFlag
|
lo.namespaceFilter = lo.namespaceFlag
|
||||||
} else {
|
} else if lo.clientset.KubernetesClient != nil {
|
||||||
lo.namespaceFilter = odocontext.GetNamespace(ctx)
|
lo.namespaceFilter = odocontext.GetNamespace(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +73,9 @@ func (lo *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, ar
|
|||||||
|
|
||||||
// Validate ...
|
// Validate ...
|
||||||
func (lo *ListOptions) Validate(ctx context.Context) (err error) {
|
func (lo *ListOptions) Validate(ctx context.Context) (err error) {
|
||||||
|
if lo.clientset.KubernetesClient == nil {
|
||||||
|
log.Warning("No connection to cluster defined")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +132,7 @@ func NewCmdComponentList(name, fullName string) *cobra.Command {
|
|||||||
},
|
},
|
||||||
Aliases: []string{"components"},
|
Aliases: []string{"components"},
|
||||||
}
|
}
|
||||||
clientset.Add(listCmd, clientset.KUBERNETES, clientset.FILESYSTEM)
|
clientset.Add(listCmd, clientset.KUBERNETES_NULLABLE, clientset.FILESYSTEM)
|
||||||
|
|
||||||
listCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace for odo to scan for components")
|
listCmd.Flags().StringVar(&o.namespaceFlag, "namespace", "", "Namespace for odo to scan for components")
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ var _ = Describe("odo devfile supported tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
componentName = helper.RandString(6)
|
componentName = helper.RandString(6)
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
projectDirPath = commonVar.Context + projectDir
|
projectDirPath = commonVar.Context + projectDir
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
var _ = Describe("E2E Test", func() {
|
var _ = Describe("E2E Test", func() {
|
||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
})
|
})
|
||||||
var _ = AfterEach(func() {
|
var _ = AfterEach(func() {
|
||||||
helper.CommonAfterEach(commonVar)
|
helper.CommonAfterEach(commonVar)
|
||||||
|
|||||||
@@ -184,12 +184,9 @@ type CommonVar struct {
|
|||||||
testDuration float64
|
testDuration float64
|
||||||
}
|
}
|
||||||
|
|
||||||
const SetupClusterTrue = true
|
|
||||||
const SetupClusterFalse = false
|
|
||||||
|
|
||||||
// CommonBeforeEach is common function runs before every test Spec (It)
|
// CommonBeforeEach is common function runs before every test Spec (It)
|
||||||
// returns CommonVar values that are used within the test script
|
// returns CommonVar values that are used within the test script
|
||||||
func CommonBeforeEach(setupCluster bool) CommonVar {
|
func CommonBeforeEach() CommonVar {
|
||||||
SetDefaultEventuallyTimeout(10 * time.Minute)
|
SetDefaultEventuallyTimeout(10 * time.Minute)
|
||||||
SetDefaultConsistentlyDuration(30 * time.Second)
|
SetDefaultConsistentlyDuration(30 * time.Second)
|
||||||
|
|
||||||
@@ -198,9 +195,18 @@ func CommonBeforeEach(setupCluster bool) CommonVar {
|
|||||||
commonVar.ConfigDir = CreateNewContext()
|
commonVar.ConfigDir = CreateNewContext()
|
||||||
commonVar.CliRunner = GetCliRunner()
|
commonVar.CliRunner = GetCliRunner()
|
||||||
commonVar.OriginalKubeconfig = os.Getenv("KUBECONFIG")
|
commonVar.OriginalKubeconfig = os.Getenv("KUBECONFIG")
|
||||||
if setupCluster {
|
if NeedsCluster(CurrentSpecReport().Labels()) {
|
||||||
LocalKubeconfigSet(commonVar.ConfigDir)
|
LocalKubeconfigSet(commonVar.ConfigDir)
|
||||||
commonVar.Project = commonVar.CliRunner.CreateAndSetRandNamespaceProject()
|
commonVar.Project = commonVar.CliRunner.CreateAndSetRandNamespaceProject()
|
||||||
|
} else {
|
||||||
|
// Disable the use of in-cluster configuration (seen in IBM Cloud pipeline)
|
||||||
|
os.Unsetenv("KUBERNETES_SERVICE_HOST")
|
||||||
|
// Create an empty kubeconfig file in the config dir and point KUBECONFIG to this file
|
||||||
|
kubeconfig, err := os.CreateTemp(commonVar.ConfigDir, "kubeconfig")
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
err = kubeconfig.Close()
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
os.Setenv("KUBECONFIG", kubeconfig.Name())
|
||||||
}
|
}
|
||||||
commonVar.OriginalWorkingDirectory = Getwd()
|
commonVar.OriginalWorkingDirectory = Getwd()
|
||||||
|
|
||||||
|
|||||||
@@ -3,3 +3,12 @@ package helper
|
|||||||
const (
|
const (
|
||||||
LabelNoCluster = "nocluster"
|
LabelNoCluster = "nocluster"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func NeedsCluster(labels []string) bool {
|
||||||
|
for _, label := range labels {
|
||||||
|
if label == LabelNoCluster {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ var _ = Describe("odo add binding command tests", func() {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
// Ensure that the operators are installed
|
// Ensure that the operators are installed
|
||||||
commonVar.CliRunner.EnsureOperatorIsInstalled("service-binding-operator")
|
commonVar.CliRunner.EnsureOperatorIsInstalled("service-binding-operator")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ var _ = Describe("odo analyze command tests", Label(helper.LabelNoCluster), func
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterFalse)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo delete command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
cmpName = helper.RandString(6)
|
cmpName = helper.RandString(6)
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
getDeployArgs = []string{"get", "deployment", "-n", commonVar.Project}
|
getDeployArgs = []string{"get", "deployment", "-n", commonVar.Project}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
cmpName = helper.RandString(6)
|
cmpName = helper.RandString(6)
|
||||||
})
|
})
|
||||||
@@ -28,7 +28,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
helper.CommonAfterEach(commonVar)
|
helper.CommonAfterEach(commonVar)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should fail", func() {
|
It("should fail, without cluster", Label(helper.LabelNoCluster), func() {
|
||||||
By("running odo describe component -o json with namespace flag without name flag", func() {
|
By("running odo describe component -o json with namespace flag without name flag", func() {
|
||||||
res := helper.Cmd("odo", "describe", "component", "--namespace", "default", "-o", "json").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--namespace", "default", "-o", "json").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -45,14 +45,6 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
helper.JsonPathContentContain(stderr, "message", "The current directory does not represent an odo component")
|
helper.JsonPathContentContain(stderr, "message", "The current directory does not represent an odo component")
|
||||||
})
|
})
|
||||||
|
|
||||||
By("running odo describe component -o json with an unknown name", func() {
|
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "-o", "json").ShouldFail()
|
|
||||||
stdout, stderr := res.Out(), res.Err()
|
|
||||||
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
|
||||||
Expect(stdout).To(BeEmpty())
|
|
||||||
helper.JsonPathContentContain(stderr, "message", "no component found with name \"unknown-name\" in the namespace \""+commonVar.Project+"\"")
|
|
||||||
})
|
|
||||||
|
|
||||||
By("running odo describe component with namespace flag without name flag", func() {
|
By("running odo describe component with namespace flag without name flag", func() {
|
||||||
res := helper.Cmd("odo", "describe", "component", "--namespace", "default").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--namespace", "default").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -67,6 +59,17 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
Expect(stderr).To(ContainSubstring("The current directory does not represent an odo component"))
|
Expect(stderr).To(ContainSubstring("The current directory does not represent an odo component"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should fail, with cluster", func() {
|
||||||
|
By("running odo describe component -o json with an unknown name", func() {
|
||||||
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name", "-o", "json").ShouldFail()
|
||||||
|
stdout, stderr := res.Out(), res.Err()
|
||||||
|
Expect(helper.IsJSON(stderr)).To(BeTrue())
|
||||||
|
Expect(stdout).To(BeEmpty())
|
||||||
|
helper.JsonPathContentContain(stderr, "message", "no component found with name \"unknown-name\" in the namespace \""+commonVar.Project+"\"")
|
||||||
|
})
|
||||||
|
|
||||||
By("running odo describe component with an unknown name", func() {
|
By("running odo describe component with an unknown name", func() {
|
||||||
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name").ShouldFail()
|
res := helper.Cmd("odo", "describe", "component", "--name", "unknown-name").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -99,7 +102,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It("should describe the component in the current directory", func() {
|
It("should describe the component in the current directory", Label(helper.LabelNoCluster), func() {
|
||||||
By("running with json output", func() {
|
By("running with json output", func() {
|
||||||
res := helper.Cmd("odo", "describe", "component", "-o", "json").ShouldPass()
|
res := helper.Cmd("odo", "describe", "component", "-o", "json").ShouldPass()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -140,7 +143,7 @@ var _ = Describe("odo describe component command tests", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
When("renaming to hide devfile.yaml file", func() {
|
When("renaming to hide devfile.yaml file", Label(helper.LabelNoCluster), func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
err := os.Rename("devfile.yaml", ".devfile.yaml")
|
err := os.Rename("devfile.yaml", ".devfile.yaml")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo dev debug command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
cmpName = helper.RandString(6)
|
cmpName = helper.RandString(6)
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ var _ = Describe("odo dev command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
cmpName = helper.RandString(6)
|
cmpName = helper.RandString(6)
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ import (
|
|||||||
"github.com/redhat-developer/odo/tests/helper"
|
"github.com/redhat-developer/odo/tests/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("odo devfile build-images command tests", func() {
|
var _ = Describe("odo devfile build-images command tests", Label(helper.LabelNoCluster), func() {
|
||||||
|
|
||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ var _ = Describe("odo devfile deploy command tests", func() {
|
|||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ var _ = Describe("odo devfile init command tests", Label(helper.LabelNoCluster),
|
|||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterFalse)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var _ = Describe("odo list with devfile", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ var _ = Describe("odo list with devfile", func() {
|
|||||||
metadata = helper.GetMetadataFromDevfile(filepath.Join(commonVar.Context, "devfile.yaml"))
|
metadata = helper.GetMetadataFromDevfile(filepath.Join(commonVar.Context, "devfile.yaml"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should show the language for 'Type' in odo list", func() {
|
It("should show the language for 'Type' in odo list", Label(helper.LabelNoCluster), func() {
|
||||||
checkList(metadata.Language)
|
checkList(metadata.Language)
|
||||||
})
|
})
|
||||||
When("the component is pushed in dev mode", func() {
|
When("the component is pushed in dev mode", func() {
|
||||||
@@ -234,7 +234,7 @@ var _ = Describe("odo list with devfile", func() {
|
|||||||
helper.CreateLocalEnv(commonVar.Context, "aname", commonVar.Project)
|
helper.CreateLocalEnv(commonVar.Context, "aname", commonVar.Project)
|
||||||
metadata = helper.GetMetadataFromDevfile(filepath.Join(commonVar.Context, "devfile.yaml"))
|
metadata = helper.GetMetadataFromDevfile(filepath.Join(commonVar.Context, "devfile.yaml"))
|
||||||
})
|
})
|
||||||
It("should show 'Not available' for 'Type' in odo list", func() {
|
It("should show 'Not available' for 'Type' in odo list", Label(helper.LabelNoCluster), func() {
|
||||||
checkList("Not available")
|
checkList("Not available")
|
||||||
})
|
})
|
||||||
When("the component is pushed", func() {
|
When("the component is pushed", func() {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var _ = Describe("odo devfile registry command tests", Label(helper.LabelNoClust
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterFalse)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ var _ = Describe("odo list services tests", func() {
|
|||||||
var randomProject string
|
var randomProject string
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
|
|
||||||
// Ensure that the operators are installed
|
// Ensure that the operators are installed
|
||||||
commonVar.CliRunner.EnsureOperatorIsInstalled("service-binding-operator")
|
commonVar.CliRunner.EnsureOperatorIsInstalled("service-binding-operator")
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var _ = Describe("odo logs command tests", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
componentName = helper.RandString(6)
|
componentName = helper.RandString(6)
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ var _ = Describe("odo create/delete/list/set namespace/project tests", func() {
|
|||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var _ = Describe("odo preference and config command tests", Label(helper.LabelNo
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterFalse)
|
commonVar = helper.CommonBeforeEach()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clean up after the test
|
// Clean up after the test
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ var _ = Describe("odo remove binding command tests", func() {
|
|||||||
var commonVar helper.CommonVar
|
var commonVar helper.CommonVar
|
||||||
|
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
// Note: We do not add any operators here because `odo remove binding` is simply about removing the ServiceBinding from devfile.
|
// Note: We do not add any operators here because `odo remove binding` is simply about removing the ServiceBinding from devfile.
|
||||||
})
|
})
|
||||||
@@ -29,7 +29,7 @@ var _ = Describe("odo remove binding command tests", func() {
|
|||||||
helper.Cmd("odo", "init", "--name", "mynode", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-service-binding-files.yaml")).ShouldPass()
|
helper.Cmd("odo", "init", "--name", "mynode", "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-service-binding-files.yaml")).ShouldPass()
|
||||||
})
|
})
|
||||||
|
|
||||||
When("removing the binding", func() {
|
When("removing the binding", Label(helper.LabelNoCluster), func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
helper.Cmd("odo", "remove", "binding", "--name", bindingName).ShouldPass()
|
helper.Cmd("odo", "remove", "binding", "--name", bindingName).ShouldPass()
|
||||||
})
|
})
|
||||||
@@ -38,7 +38,7 @@ var _ = Describe("odo remove binding command tests", func() {
|
|||||||
Expect(components).To(BeNil())
|
Expect(components).To(BeNil())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
It("should fail to remove binding that does not exist", func() {
|
It("should fail to remove binding that does not exist", Label(helper.LabelNoCluster), func() {
|
||||||
helper.Cmd("odo", "remove", "binding", "--name", "my-binding").ShouldFail()
|
helper.Cmd("odo", "remove", "binding", "--name", "my-binding").ShouldFail()
|
||||||
})
|
})
|
||||||
When("odo dev is running", func() {
|
When("odo dev is running", func() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo generic", func() {
|
|||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
oc = helper.NewOcRunner("oc")
|
oc = helper.NewOcRunner("oc")
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clean up after the test
|
// Clean up after the test
|
||||||
@@ -26,7 +26,7 @@ var _ = Describe("odo generic", func() {
|
|||||||
helper.CommonAfterEach(commonVar)
|
helper.CommonAfterEach(commonVar)
|
||||||
})
|
})
|
||||||
|
|
||||||
When("running odo --help", func() {
|
When("running odo --help", Label(helper.LabelNoCluster), func() {
|
||||||
var output string
|
var output string
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
output = helper.Cmd("odo", "--help").ShouldPass().Out()
|
output = helper.Cmd("odo", "--help").ShouldPass().Out()
|
||||||
@@ -37,7 +37,7 @@ var _ = Describe("odo generic", func() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
When("running odo without subcommand and flags", func() {
|
When("running odo without subcommand and flags", Label(helper.LabelNoCluster), func() {
|
||||||
var output string
|
var output string
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
output = helper.Cmd("odo").ShouldPass().Out()
|
output = helper.Cmd("odo").ShouldPass().Out()
|
||||||
@@ -47,12 +47,12 @@ var _ = Describe("odo generic", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error when using an invalid command", func() {
|
It("returns error when using an invalid command", Label(helper.LabelNoCluster), func() {
|
||||||
output := helper.Cmd("odo", "hello").ShouldFail().Err()
|
output := helper.Cmd("odo", "hello").ShouldFail().Err()
|
||||||
Expect(output).To(ContainSubstring("Invalid command - see available commands/subcommands above"))
|
Expect(output).To(ContainSubstring("Invalid command - see available commands/subcommands above"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns JSON error", func() {
|
It("returns JSON error", Label(helper.LabelNoCluster), func() {
|
||||||
By("using an invalid command with JSON output", func() {
|
By("using an invalid command with JSON output", func() {
|
||||||
res := helper.Cmd("odo", "unknown-command", "-o", "json").ShouldFail()
|
res := helper.Cmd("odo", "unknown-command", "-o", "json").ShouldFail()
|
||||||
stdout, stderr := res.Out(), res.Err()
|
stdout, stderr := res.Out(), res.Err()
|
||||||
@@ -82,7 +82,7 @@ var _ = Describe("odo generic", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error when using an invalid command with --help", func() {
|
It("returns error when using an invalid command with --help", Label(helper.LabelNoCluster), func() {
|
||||||
output := helper.Cmd("odo", "hello", "--help").ShouldFail().Err()
|
output := helper.Cmd("odo", "hello", "--help").ShouldFail().Err()
|
||||||
Expect(output).To(ContainSubstring("unknown command 'hello', type --help for a list of all commands"))
|
Expect(output).To(ContainSubstring("unknown command 'hello', type --help for a list of all commands"))
|
||||||
})
|
})
|
||||||
@@ -119,6 +119,11 @@ var _ = Describe("odo generic", func() {
|
|||||||
serverURL := oc.GetCurrentServerURL()
|
serverURL := oc.GetCurrentServerURL()
|
||||||
Expect(odoVersion).Should(ContainSubstring("Server: " + serverURL))
|
Expect(odoVersion).Should(ContainSubstring("Server: " + serverURL))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should show the version of odo major components", Label(helper.LabelNoCluster), func() {
|
||||||
|
reOdoVersion := `^odo\s*v[0-9]+.[0-9]+.[0-9]+(?:-\w+)?\s*\(\w+\)`
|
||||||
|
Expect(odoVersion).Should(MatchRegexp(reOdoVersion))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Experimental Mode", func() {
|
Describe("Experimental Mode", func() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ var _ = Describe("odo add binding interactive command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
|
|
||||||
// We make EXPLICITLY sure that we are outputting with NO COLOR
|
// We make EXPLICITLY sure that we are outputting with NO COLOR
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo deploy interactive command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var _ = Describe("odo dev interactive command tests", func() {
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterTrue)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var _ = Describe("odo init interactive command tests", Label(helper.LabelNoClust
|
|||||||
|
|
||||||
// This is run before every Spec (It)
|
// This is run before every Spec (It)
|
||||||
var _ = BeforeEach(func() {
|
var _ = BeforeEach(func() {
|
||||||
commonVar = helper.CommonBeforeEach(helper.SetupClusterFalse)
|
commonVar = helper.CommonBeforeEach()
|
||||||
helper.Chdir(commonVar.Context)
|
helper.Chdir(commonVar.Context)
|
||||||
|
|
||||||
// We make EXPLICITLY sure that we are outputting with NO COLOR
|
// We make EXPLICITLY sure that we are outputting with NO COLOR
|
||||||
|
|||||||
Reference in New Issue
Block a user