Use staging Devfile registry for PR tests (#7129)

* Revert using a DEVFILE_PROXY env var

There is no proxy deployed in the internal test cluster.
As such, this env var no longer makes sense.

* To help troubleshoot, display the resolved Devfile registry URL

* Make interactive tests more resilient with stack versions

They are now able to determine if the "Select version" prompt
should be asked by "odo init" or not:

* Make sure doc automation tests do not rely on hard-coded namespaces

* Allow to run doc automation tests with more parallel Ginkgo nodes

This is possible now that those tests no longer
depend on a single hard-coded namespace.

* Remove occurrences of the DEVFILE_REGISTRY env var in IBM Pipelines scripts

* Reuse logic for determining the Devfile Registry URL in "odo registry" tests

* Clarify what openshiftci-config.sh is used for
This commit is contained in:
Armel Soro
2023-10-27 09:54:14 +02:00
committed by GitHub
parent d77ca3e95a
commit 5d4a6ef325
23 changed files with 180 additions and 147 deletions

View File

@@ -15,8 +15,6 @@ cleanup_namespaces
export SKIP_USER_LOGIN_TESTS=true
(
set -e
export DEVFILE_PROXY="$(kubectl get svc -n devfile-proxy nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' || true)"
echo Using Devfile proxy: ${DEVFILE_PROXY}
make install
make test-integration-cluster
) |& tee "/tmp/${LOGFILE}"

View File

@@ -13,7 +13,6 @@ ibmcloud target -r "${IBM_REGION}"
(
set -e
make install
echo Using Devfile Registry ${DEVFILE_REGISTRY}
make test-integration-no-cluster
) |& tee "/tmp/${LOGFILE}"

View File

@@ -16,8 +16,6 @@ cleanup_namespaces
(
set -e
export DEVFILE_PROXY="$(kubectl get svc -n devfile-proxy nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' || true)"
echo Using Devfile proxy: ${DEVFILE_PROXY}
make install
make test-integration-cluster
make test-e2e

View File

@@ -60,7 +60,6 @@ function Run-Test {
[Environment]::SetEnvironmentVariable("SKIP_SERVICE_BINDING_TESTS","$SKIP_SERVICE_BINDING_TESTS" )
# Integration tests detecting key press when running DevSession are not working on Windows
[Environment]::SetEnvironmentVariable("SKIP_KEY_PRESS","true")
[Environment]::SetEnvironmentVariable("DEVFILE_REGISTRY", "$DEVFILE_REGISTRY")
Shout "Login IBMcloud"
ibmcloud login --apikey ${API_KEY}
@@ -71,14 +70,6 @@ function Run-Test {
oc login -u apikey -p ${API_KEY} ${IBM_OPENSHIFT_ENDPOINT}
Check-ExitCode $LASTEXITCODE
Shout "Getting Devfile proxy address"
$DEVFILE_PROXY=$(oc get svc -n devfile-proxy nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
if ( $LASTEXITCODE -eq 0 )
{
Shout "Using Devfile proxy: $DEVFILE_PROXY"
[Environment]::SetEnvironmentVariable("DEVFILE_PROXY", "$DEVFILE_PROXY")
}
Shout "Create Binary"
make install
Shout "Running test"
@@ -109,8 +100,7 @@ $LOGFILE=$args[4]
$REPO=$args[5]
$CLUSTER_ID=$args[6]
$TEST_EXEC_NODES=$args[7]
$DEVFILE_REGISTRY=$args[8]
$SKIP_SERVICE_BINDING_TESTS=$args[9]
$SKIP_SERVICE_BINDING_TESTS=$args[8]
Shout "Args Recived"

View File

@@ -18,7 +18,7 @@ sshpass -p $WINDOWS_PASSWORD scp -o StrictHostKeyChecking=no ./.ibm/pipelines/wi
#execute test from the test script
export TEST_EXEC_NODES=${TEST_EXEC_NODES:-"16"}
sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no powershell /tmp/windows-test-script.ps1 "${GIT_PR_NUMBER}" "${BUILD_NUMBER}" "${API_KEY_QE}" "${IBM_OPENSHIFT_ENDPOINT}" "${LOGFILE}" "${REPO}" "${CLUSTER_ID}" "${TEST_EXEC_NODES}" "${DEVFILE_REGISTRY}" "${SKIP_SERVICE_BINDING_TESTS}"
sshpass -p $WINDOWS_PASSWORD ssh Administrator@$WINDOWS_IP -o StrictHostKeyChecking=no powershell /tmp/windows-test-script.ps1 "${GIT_PR_NUMBER}" "${BUILD_NUMBER}" "${API_KEY_QE}" "${IBM_OPENSHIFT_ENDPOINT}" "${LOGFILE}" "${REPO}" "${CLUSTER_ID}" "${TEST_EXEC_NODES}" "${SKIP_SERVICE_BINDING_TESTS}"
RESULT=$?
echo "RESULT: $RESULT"

View File

@@ -238,7 +238,7 @@ test-e2e:
.PHONY: test-doc-automation
test-doc-automation:
$(RUN_GINKGO) $(GINKGO_FLAGS_ONE) --junit-report="test-doc-automation.xml" tests/documentation/...
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-doc-automation.xml" tests/documentation/...
# Generate OpenAPISpec library based on ododevapispec.yaml inside pkg/apiserver-gen; this will only generate interfaces

View File

@@ -15,7 +15,8 @@ Interactive mode enabled, please answer the following questions:
? Select architectures to filter by: amd64
? Select language: Java
? Select project type: Maven Java
✓ Downloading devfile "java-maven" from registry "DefaultDevfileRegistry" [4s]
? Select version: 1.2.0
✓ Downloading devfile "java-maven:1.2.0" from registry "DefaultDevfileRegistry" [4s]
↪ Container Configuration "tools":
OPEN PORTS:
@@ -30,7 +31,7 @@ Interactive mode enabled, please answer the following questions:
✓ Downloading starter project "springbootproject" [1s]
You can automate this command by executing:
odo init --name my-java-maven-app --devfile java-maven --devfile-registry DefaultDevfileRegistry --starter springbootproject
odo init --name my-java-maven-app --devfile java-maven --devfile-registry DefaultDevfileRegistry --devfile-version 1.2.0 --starter springbootproject
Your new component 'my-java-maven-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.

View File

@@ -189,7 +189,6 @@ Options here are mostly used for debugging and testing `odo` behavior.
| `ODO_DISABLE_TELEMETRY` | Useful for disabling [telemetry collection](https://github.com/redhat-developer/odo/blob/main/USAGE_DATA.md). **Deprecated in v3.2.0**. Use `ODO_TRACKING_CONSENT` instead. | v2.1.0 | `true` |
| `GLOBALODOCONFIG` | Useful for setting a different location of global preference file `preference.yaml`. | v0.0.19 | `~/.config/odo/preference.yaml` |
| `ODO_DEBUG_TELEMETRY_FILE` | Useful for debugging [telemetry](https://github.com/redhat-developer/odo/blob/main/USAGE_DATA.md). When set it will save telemetry data to a file instead of sending it to the server. | v3.0.0-alpha1 | `/tmp/telemetry_data.json` |
| `DEVFILE_PROXY` | Integration tests will use this address as Devfile registry instead of `registry.stage.devfile.io` | v3.0.0-beta3 | `my-registry.example.com` |
| `TELEMETRY_CALLER` | Caller identifier passed to [telemetry](https://github.com/redhat-developer/odo/blob/main/USAGE_DATA.md). Case-insensitive. Acceptable values: `vscode`, `intellij`, `jboss`. | v3.1.0 | `intellij` |
| `ODO_TRACKING_CONSENT` | Useful for controlling [telemetry](https://github.com/redhat-developer/odo/blob/main/USAGE_DATA.md). Acceptable values: `yes` ([enables telemetry](https://github.com/redhat-developer/odo/blob/main/USAGE_DATA.md) and skips consent prompt), `no` (disables telemetry and consent prompt). Takes precedence over the [`ConsentTelemetry`](#preference-key-table) preference. | v3.2.0 | `yes` |
| `ODO_PUSH_IMAGES` | Whether to push the images once built; this is used only when applying Devfile image components as part of a Dev Session running on Podman; this is useful for integration tests running on Podman. `true` by default | v3.7.0 | `false` |

View File

@@ -12,7 +12,7 @@ Based on the files in the current directory odo detected
Supported architectures: all
Language: .NET
Project type: dotnet
The devfile "dotnet50:1.0.3" from the registry "DefaultDevfileRegistry" will be downloaded.
The devfile "dotnet60:1.0.2" from the registry "DefaultDevfileRegistry" will be downloaded.
? Is this correct? No
? Select architectures to filter by: [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
> [x] amd64

View File

@@ -12,9 +12,9 @@ Based on the files in the current directory odo detected
Supported architectures: all
Language: Java
Project type: springboot
The devfile "java-springboot:1.2.0" from the registry "DefaultDevfileRegistry" will be downloaded.
The devfile "java-springboot:1.3.0" from the registry "DefaultDevfileRegistry" will be downloaded.
? Is this correct? Yes
✓ Downloading devfile "java-springboot:1.2.0" from registry "DefaultDevfileRegistry" [3s]
✓ Downloading devfile "java-springboot:1.3.0" from registry "DefaultDevfileRegistry" [3s]
↪ Container Configuration "tools":
OPEN PORTS:
@@ -27,7 +27,7 @@ The devfile "java-springboot:1.2.0" from the registry "DefaultDevfileRegistry" w
? Enter component name: my-java-app
You can automate this command by executing:
odo init --name my-java-app --devfile java-springboot --devfile-registry DefaultDevfileRegistry --devfile-version 1.2.0
odo init --name my-java-app --devfile java-springboot --devfile-registry DefaultDevfileRegistry --devfile-version 1.3.0
Your new component 'my-java-app' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.

View File

@@ -8,7 +8,6 @@ import (
)
type Configuration struct {
DevfileProxy *string `env:"DEVFILE_PROXY,noinit"`
DockerCmd string `env:"DOCKER_CMD,default=docker"`
Globalodoconfig *string `env:"GLOBALODOCONFIG,noinit"`
OdoDebugTelemetryFile *string `env:"ODO_DEBUG_TELEMETRY_FILE,noinit"`

View File

@@ -18,7 +18,6 @@ func TestDefaultValues(t *testing.T) {
checkDefaultBoolValue(t, "OdoExperimentalMode", cfg.OdoExperimentalMode, false)
// Use noinit to set non initialized value as nil instead of zero-value
checkNilString(t, "DevfileProxy", cfg.DevfileProxy)
checkNilString(t, "Globalodoconfig", cfg.Globalodoconfig)
checkNilString(t, "Globalodoconfig", cfg.Globalodoconfig)
checkNilString(t, "OdoDebugTelemetryFile", cfg.OdoDebugTelemetryFile)

View File

@@ -1 +1,4 @@
# This is used in openshiftci-presubmit-all-tests.sh, used by Interop tests.
# Since these interop tests are managed by a different team, we intentionally want to use a stable Devfile registry.
# But our own internal tests make use of the staging Devfile registry.
export DEVFILE_REGISTRY=https://devfile-registry-ci-devfile-registry.odo-test-kubernete-449701-49529fc6e6a4a9fe7ebba9a3db5b55c4-0000.eu-de.containers.appdomain.cloud/

View File

@@ -8,6 +8,7 @@ import (
"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/redhat-developer/odo/tests/helper"
)
@@ -15,11 +16,12 @@ var _ = Describe("doc command reference odo create namespace", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("command-reference", "docs-mdx", "create-namespace")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"
var ns string
BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
ns = helper.GenerateProjectName()
})
AfterEach(func() {
@@ -29,13 +31,16 @@ var _ = Describe("doc command reference odo create namespace", func() {
Context("To create a namespace resource", func() {
AfterEach(func() {
commonVar.CliRunner.DeleteNamespaceProject("odo-dev", true)
if commonVar.CliRunner.HasNamespaceProject(ns) {
commonVar.CliRunner.DeleteNamespaceProject(ns, false)
}
})
It("Creates a namespace resource for a kubernetes cluster", func() {
args := []string{"create", "namespace", "odo-dev"}
args := []string{"create", "namespace", ns}
out := helper.Cmd("odo", args...).ShouldPass().Out()
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
got = strings.ReplaceAll(got, ns, "odo-dev")
file := "create_namespace.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
@@ -43,9 +48,10 @@ var _ = Describe("doc command reference odo create namespace", func() {
})
It("Creates a project resource for a kubernetes cluster", func() {
args := []string{"create", "project", "odo-dev"}
args := []string{"create", "project", ns}
out := helper.Cmd("odo", args...).ShouldPass().Out()
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
got = strings.ReplaceAll(got, ns, "odo-dev")
file := "create_project.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)

View File

@@ -3,6 +3,7 @@ package docautomation
import (
"fmt"
"path/filepath"
"strings"
"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo/v2"
@@ -15,11 +16,12 @@ var _ = Describe("doc command reference odo delete namespace", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("command-reference", "docs-mdx", "delete-namespace")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"
var ns string
BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
Expect(helper.VerifyFileExists(".odo/env/env.yaml")).To(BeFalse())
ns = helper.GenerateProjectName()
})
AfterEach(func() {
@@ -29,18 +31,19 @@ var _ = Describe("doc command reference odo delete namespace", func() {
Context("To delete a namespace resource", func() {
BeforeEach(func() {
helper.Cmd("odo", "create", "namespace", "odo-dev").ShouldPass()
helper.Cmd("odo", "create", "namespace", ns).ShouldPass()
})
AfterEach(func() {
commonVar.CliRunner.DeleteNamespaceProject("odo-dev", true)
if commonVar.CliRunner.HasNamespaceProject(ns) {
commonVar.CliRunner.DeleteNamespaceProject(ns, false)
}
})
It("Deletes a namespace resource for a kubernetes cluster", func() {
args := []string{"odo", "delete", "namespace", "odo-dev"}
args := []string{"odo", "delete", "namespace", ns}
out, err := helper.RunInteractive(args, []string{"ODO_LOG_LEVEL=0"}, func(ctx helper.InteractiveContext) {
helper.ExpectString(ctx, "? Are you sure you want to delete namespace \"odo-dev\"?")
helper.ExpectString(ctx, fmt.Sprintf("? Are you sure you want to delete namespace %q?", ns))
helper.SendLine(ctx, "Yes")
})
@@ -48,6 +51,7 @@ var _ = Describe("doc command reference odo delete namespace", func() {
got := helper.StripAnsi(out)
got = helper.StripInteractiveQuestion(got)
got = fmt.Sprintf(outputStringFormat, args[1], helper.StripSpinner(got))
got = strings.ReplaceAll(got, ns, "odo-dev")
file := "delete_namespace.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)
@@ -55,9 +59,9 @@ var _ = Describe("doc command reference odo delete namespace", func() {
})
It("Deletes a project resource for a openshift cluster", func() {
args := []string{"odo", "delete", "project", "odo-dev"}
args := []string{"odo", "delete", "project", ns}
out, err := helper.RunInteractive(args, []string{"ODO_LOG_LEVEL=0"}, func(ctx helper.InteractiveContext) {
helper.ExpectString(ctx, "? Are you sure you want to delete project \"odo-dev\"?")
helper.ExpectString(ctx, fmt.Sprintf("? Are you sure you want to delete project %q?", ns))
helper.SendLine(ctx, "Yes")
})
@@ -65,6 +69,7 @@ var _ = Describe("doc command reference odo delete namespace", func() {
got := helper.StripAnsi(out)
got = helper.StripInteractiveQuestion(got)
got = fmt.Sprintf(outputStringFormat, args[1], helper.StripSpinner(got))
got = strings.ReplaceAll(got, ns, "odo-dev")
file := "delete_project.mdx"
want := helper.GetMDXContent(filepath.Join(commonPath, file))
diff := cmp.Diff(want, got)

View File

@@ -41,6 +41,11 @@ var _ = Describe("doc command reference odo init", Label(helper.LabelNoCluster),
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "java-maven") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")

View File

@@ -16,30 +16,31 @@ var _ = Describe("User guides: Quickstart test", func() {
var commonVar helper.CommonVar
var commonPath = filepath.Join("user-guides", "quickstart", "docs-mdx")
var outputStringFormat = "```console\n$ odo %s\n%s```\n"
const namespace = "odo-dev"
BeforeEach(func() {
commonVar = helper.CommonBeforeEach()
helper.Chdir(commonVar.Context)
})
AfterEach(func() {
helper.CommonAfterEach(commonVar)
})
Context("Create namespace/project", func() {
var namespace string
BeforeEach(func() {
// ensure "odo-dev" namespace does not exist before beginning
if commonVar.CliRunner.HasNamespaceProject(namespace) {
commonVar.CliRunner.DeleteNamespaceProject(namespace, true)
}
namespace = helper.GenerateProjectName()
})
AfterEach(func() {
if commonVar.CliRunner.HasNamespaceProject(namespace) {
helper.DeleteProject(namespace)
}
})
It("should show correct output for namespace/project creation", func() {
args := []string{"create", "namespace", namespace}
out := helper.Cmd("odo", args...).ShouldPass().Out()
got := fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(out))
got = strings.ReplaceAll(got, namespace, "odo-dev")
By("checking the output for namespace", func() {
file := filepath.Join(commonPath, "create_namespace_output.mdx")
want := helper.GetMDXContent(file)
@@ -69,7 +70,7 @@ var _ = Describe("User guides: Quickstart test", func() {
helper.ExpectString(ctx, "Is this correct?")
helper.SendLine(ctx, "")
helper.ExpectString(ctx, "✓ Downloading devfile \"nodejs:2.1.1\" from registry \"DefaultDevfileRegistry\"")
helper.ExpectString(ctx, "✓ Downloading devfile \"nodejs")
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -97,7 +98,7 @@ var _ = Describe("User guides: Quickstart test", func() {
args := []string{"dev"}
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"3000": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = strings.ReplaceAll(got, commonVar.Project, "odo-dev")
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
got = helper.StripGitCommitFromVersion(got)
file := filepath.Join(commonNodeJSPath, "nodejs_odo_dev_output.mdx")
@@ -119,7 +120,7 @@ var _ = Describe("User guides: Quickstart test", func() {
helper.ExpectString(ctx, "Is this correct?")
helper.SendLine(ctx, "")
helper.ExpectString(ctx, "✓ Downloading devfile \"go:1.0.2\" from registry \"DefaultDevfileRegistry\"")
helper.ExpectString(ctx, "✓ Downloading devfile \"go")
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -147,7 +148,7 @@ var _ = Describe("User guides: Quickstart test", func() {
args := []string{"dev"}
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = strings.ReplaceAll(got, commonVar.Project, "odo-dev")
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
got = helper.StripGitCommitFromVersion(got)
file := filepath.Join(commonGoPath, "go_odo_dev_output.mdx")
@@ -179,7 +180,12 @@ var _ = Describe("User guides: Quickstart test", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "6")
helper.ExpectString(ctx, "✓ Downloading devfile \"dotnet60\" from registry \"DefaultDevfileRegistry\"")
if helper.HasAtLeastTwoVersions("", "dotnet60") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "✓ Downloading devfile \"dotnet60")
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -192,7 +198,6 @@ var _ = Describe("User guides: Quickstart test", func() {
Expect(err).To(BeNil())
got := helper.StripAnsi(out)
got = helper.StripInteractiveQuestion(got)
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = fmt.Sprintf(outputStringFormat, "init", helper.StripSpinner(got))
got = helper.StripGitCommitFromVersion(got)
file := filepath.Join(commondotnetPath, "dotnet_odo_init_output.mdx")
@@ -208,7 +213,7 @@ var _ = Describe("User guides: Quickstart test", func() {
args := []string{"dev"}
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = strings.ReplaceAll(got, commonVar.Project, "odo-dev")
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
got = helper.StripGitCommitFromVersion(got)
file := filepath.Join(commondotnetPath, "dotnet_odo_dev_output.mdx")
@@ -230,7 +235,7 @@ var _ = Describe("User guides: Quickstart test", func() {
helper.ExpectString(ctx, "Is this correct?")
helper.SendLine(ctx, "Yes")
helper.ExpectString(ctx, "✓ Downloading devfile \"java-springboot:1.2.0\" from registry \"DefaultDevfileRegistry\"")
helper.ExpectString(ctx, "✓ Downloading devfile \"java-springboot")
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -261,7 +266,7 @@ var _ = Describe("User guides: Quickstart test", func() {
args := []string{"dev"}
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = strings.ReplaceAll(got, commonVar.Project, "odo-dev")
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
got = helper.StripGitCommitFromVersion(got)
file := filepath.Join(commonGoPath, "java_odo_dev_output.mdx")

View File

@@ -8,7 +8,6 @@ import (
"net/http"
"path"
"path/filepath"
"regexp"
"time"
. "github.com/onsi/ginkgo/v2"
@@ -48,18 +47,6 @@ var _ = Describe("E2E Test", func() {
}
Context("starting with empty Directory", func() {
var hasMultipleVersions bool
var _ = BeforeEach(func() {
helper.Chdir(commonVar.Context)
Expect(helper.ListFilesInDir(commonVar.Context)).To(BeEmpty())
out := helper.Cmd("odo", "registry", "--devfile", "nodejs", "--devfile-registry", "DefaultDevfileRegistry").ShouldPass().Out()
// Version pattern has always been in the form of X.X.X
vMatch := regexp.MustCompile(`(?:\d.\d.\d)`)
if matches := vMatch.FindAll([]byte(out), -1); len(matches) > 1 {
hasMultipleVersions = true
}
})
It("should verify developer workflow from empty Directory", func() {
deploymentName := "my-component"
serviceName := "my-cs"
@@ -78,7 +65,7 @@ var _ = Describe("E2E Test", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "Node.js")
if hasMultipleVersions {
if helper.HasAtLeastTwoVersions("", "nodejs") {
helper.ExpectString(ctx, "Select version: ")
helper.SendLine(ctx, "")
}

View File

@@ -233,6 +233,7 @@ func CommonBeforeEach() CommonVar {
}
}
commonVar.OriginalWorkingDirectory = Getwd()
Chdir(commonVar.Context)
configPath := filepath.Join(commonVar.ConfigDir, "preference.yaml")
os.Setenv("GLOBALODOCONFIG", configPath)
@@ -401,14 +402,11 @@ func SetDefaultDevfileRegistryAsStaging() {
func GetDevfileRegistryURL() string {
registryURL := "https://registry.stage.devfile.io"
proxy := os.Getenv("DEVFILE_PROXY")
if proxy != "" {
registryURL = "http://" + proxy
}
customReg := os.Getenv("DEVFILE_REGISTRY")
if customReg != "" {
registryURL = customReg
}
fmt.Printf("Using Devfile Registry URL at: %q\n", registryURL)
return registryURL
}

View File

@@ -5,12 +5,16 @@ import (
"fmt"
"net/http"
"net/url"
"regexp"
. "github.com/onsi/ginkgo/v2"
"github.com/redhat-developer/odo/pkg/api"
)
// Version pattern has always been in the form of X.X.X
var versionRe = regexp.MustCompile(`(\d.\d.\d)`)
type Registry struct {
url string
}
@@ -56,3 +60,25 @@ func (o Registry) GetStack(name string) (api.DevfileStack, error) {
}
return api.DevfileStack{}, fmt.Errorf("stack %q not found", name)
}
// GetVersions returns the list of all versions for the given stack name in the given Devfile registry.
// It uses the "odo registry" command to find out this information.
//
// The registry name is optional, and defaults to DefaultDevfileRegistry if not set.
func GetVersions(registryName string, stackName string) []string {
devfileReg := "DefaultDevfileRegistry"
if registryName != "" {
devfileReg = registryName
}
out := Cmd("odo", "registry", "--devfile", stackName, "--devfile-registry", devfileReg).ShouldPass().Out()
return versionRe.FindAllString(out, -1)
}
// HasAtLeastTwoVersions returns whether the given stack in the given Devfile registry has at least two versions.
// This is useful to determine if the "Select version" prompt will be displayed in the interactive "odo init" tests.
// Otherwise, "odo init" would just skip this "Select version" prompt if the stack selected has no version or only a single one.
//
// Note that the registry name is optional, and defaults to DefaultDevfileRegistry if not set.
func HasAtLeastTwoVersions(registryName string, stackName string) bool {
return len(GetVersions(registryName, stackName)) >= 2
}

View File

@@ -2,7 +2,6 @@ package integration
import (
"fmt"
"os"
"path/filepath"
. "github.com/onsi/ginkgo/v2"
@@ -37,15 +36,7 @@ var _ = Describe("odo devfile registry command tests", func() {
const registryName string = "RegistryName"
// Use staging OCI-based registry for tests to avoid overload
var addRegistryURL string = "https://registry.stage.devfile.io"
proxy := os.Getenv("DEVFILE_PROXY")
if proxy != "" {
addRegistryURL = "http://" + proxy
}
customDevfileRegistry := os.Getenv("DEVFILE_REGISTRY")
if customDevfileRegistry != "" {
addRegistryURL = customDevfileRegistry
}
addRegistryURL := helper.GetDevfileRegistryURL()
It("Should list all default registries", func() {
output := helper.Cmd("odo", "preference", "view").ShouldPass().Out()

View File

@@ -174,8 +174,10 @@ var _ = Describe("odo dev interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "Python")
if helper.HasAtLeastTwoVersions("", "python") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")

View File

@@ -5,7 +5,6 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"strings"
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
@@ -64,8 +63,10 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "go") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -84,18 +85,8 @@ var _ = Describe("odo init interactive command tests", func() {
Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml"))
})
Context("personalizing Devfile configuration", func() {
var hasMultipleVersions bool
BeforeEach(func() {
out := helper.Cmd("odo", "registry", "--devfile", "nodejs", "--devfile-registry", "DefaultDevfileRegistry").ShouldPass().Out()
// Version pattern has always been in the form of X.X.X
vMatch := regexp.MustCompile(`(\d.\d.\d)`)
if matches := vMatch.FindAll([]byte(out), -1); len(matches) > 1 {
hasMultipleVersions = true
}
})
Context("personalizing configuration", func() {
It("should allow to add and delete a port ", func() {
It("should allow to add and delete a port", func() {
command := []string{"odo", "init"}
output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) {
@@ -108,7 +99,7 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if hasMultipleVersions {
if helper.HasAtLeastTwoVersions("", "nodejs") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
@@ -147,7 +138,6 @@ var _ = Describe("odo init interactive command tests", func() {
helper.FileShouldContainSubstring(filepath.Join(commonVar.Context, "devfile.yaml"), "3000")
})
})
})
It("should ask to re-enter the component name when an invalid value is passed", func() {
command := []string{"odo", "init"}
@@ -162,8 +152,10 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "go") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -209,8 +201,10 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "go") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -250,8 +244,10 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "go") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -288,8 +284,10 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "go") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, devfileVersion)
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -327,6 +325,11 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "Vert.x Java")
if helper.HasAtLeastTwoVersions("", "java-vertx") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -428,6 +431,11 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "java-maven") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -588,6 +596,11 @@ var _ = Describe("odo init interactive command tests", func() {
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "dotnet50") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -737,6 +750,11 @@ spec:
helper.ExpectString(ctx, "Select project type")
helper.SendLine(ctx, "")
if helper.HasAtLeastTwoVersions("", "java-maven") {
helper.ExpectString(ctx, "Select version")
helper.SendLine(ctx, "")
}
helper.ExpectString(ctx, "Select container for which you want to change configuration?")
helper.SendLine(ctx, "")
@@ -751,8 +769,12 @@ spec:
Expect(err).ShouldNot(HaveOccurred())
By("displaying automation command with the in-cluster registry", func() {
Expect(output).Should(ContainSubstring(
"odo init --name my-java-maven-app --devfile java-maven --devfile-registry %s --starter springbootproject", devfileRegistryName))
Expect(output).Should(
ContainSubstring(
"odo init --name my-java-maven-app --devfile java-maven --devfile-registry %s --devfile-version 1.2.0 --starter springbootproject",
devfileRegistryName,
),
output)
})
By("actually downloading the Devfile", func() {
Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml"))