Remove API Server from experimental mode, set UI Server as experimental (#6985)

* Remove API Server from experimental mode, set UI Server as experimental

* Adapt api-server integration tests

* Disable --api-server by default in the tests

They are enabled only if `options.StartAPIServer`
is explicitly enabled.
This is to avoid potential port conflicting issue,
especially on Windows - see [1]

[1] https://github.com/redhat-developer/odo/issues/6939

* Error out if `--api-server-port` is set but `--api-server` is false

---------

Co-authored-by: Armel Soro <asoro@redhat.com>
This commit is contained in:
Philippe Martin
2023-07-21 12:11:08 +02:00
committed by GitHub
parent 251648998c
commit 9605c92ede
9 changed files with 104 additions and 66 deletions

View File

@@ -163,12 +163,11 @@ func StartDevMode(options DevSessionOpts) (devSession DevSession, err error) {
if options.CustomAddress != "" {
args = append(args, "--address", options.CustomAddress)
}
if options.StartAPIServer {
env = append(env, "ODO_EXPERIMENTAL_MODE=true")
args = append(args, "--api-server")
if options.APIServerPort != 0 {
args = append(args, "--api-server-port", fmt.Sprintf("%d", options.APIServerPort))
}
if !options.StartAPIServer {
args = append(args, "--api-server=false")
}
if options.APIServerPort != 0 {
args = append(args, fmt.Sprintf("--api-server-port=%d", options.APIServerPort))
}
if options.SyncGitDir {
args = append(args, "--sync-git-dir")

View File

@@ -33,28 +33,43 @@ var _ = Describe("odo dev command with api server tests", func() {
var _ = AfterEach(func() {
helper.CommonAfterEach(commonVar)
})
for _, podman := range []bool{false, true} {
podman := podman
for _, customPort := range []bool{false, true} {
customPort := customPort
When("the component is bootstrapped", helper.LabelPodmanIf(podman, func() {
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"), cmpName)
})
When("the component is bootstrapped", helper.LabelPodmanIf(podman, func() {
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"), cmpName)
})
It("should fail if --api-server is false but --api-server-port is true", func() {
args := []string{
"dev",
"--api-server=false",
fmt.Sprintf("--api-server-port=%d", helper.GetCustomStartPort()),
}
if podman {
args = append(args, "--platform=podman")
}
errOut := helper.Cmd("odo", args...).ShouldFail().Err()
Expect(errOut).To(ContainSubstring("--api-server-port makes sense only if --api-server is enabled"))
})
for _, customPort := range []bool{false, true} {
customPort := customPort
if customPort {
It("should fail if --random-ports and --api-server-port are used together", func() {
args := []string{
"dev",
"--random-ports",
"--api-server",
fmt.Sprintf("--api-server-port=%d", helper.GetCustomStartPort()),
}
if podman {
args = append(args, "--platform=podman")
}
errOut := helper.Cmd("odo", args...).AddEnv("ODO_EXPERIMENTAL_MODE=true").ShouldFail().Err()
errOut := helper.Cmd("odo", args...).ShouldFail().Err()
Expect(errOut).Should(ContainSubstring("--random-ports and --api-server-port cannot be used together"))
})
}
@@ -90,26 +105,6 @@ var _ = Describe("odo dev command with api server tests", func() {
Expect(resp.StatusCode).To(BeEquivalentTo(http.StatusOK))
})
It("should not describe the API Server in non-experimental mode", func() {
args := []string{"describe", "component"}
if podman {
args = append(args, "--platform", "podman")
}
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
for _, s := range []string{"Dev Control Plane", "API Server"} {
Expect(stdout).ShouldNot(ContainSubstring(s))
}
})
It("should not describe the API Server in non-experimental mode (JSON)", func() {
args := []string{"describe", "component", "-o", "json"}
if podman {
args = append(args, "--platform", "podman")
}
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
helper.JsonPathDoesNotExist(stdout, "devControlPlane")
})
It("should describe the API Server port in the experimental mode", func() {
args := []string{"describe", "component"}
if podman {
@@ -147,9 +142,43 @@ var _ = Describe("odo dev command with api server tests", func() {
helper.JsonPathContentIs(stdout, "devControlPlane.0.apiServerPath", "/api/v1/")
helper.JsonPathContentIs(stdout, "devControlPlane.0.webInterfacePath", "/")
})
It("should describe the API Server port", func() {
args := []string{"describe", "component"}
if podman {
args = append(args, "--platform", "podman")
}
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
Expect(stdout).To(ContainSubstring("Dev Control Plane"))
Expect(stdout).To(ContainSubstring("API: http://%s", devSession.APIServerEndpoint))
Expect(stdout).ToNot(ContainSubstring("Web UI: http://localhost:%d/", localPort))
})
It("should describe the API Server port (JSON)", func() {
args := []string{"describe", "component", "-o", "json"}
if podman {
args = append(args, "--platform", "podman")
}
stdout := helper.Cmd("odo", args...).ShouldPass().Out()
helper.IsJSON(stdout)
helper.JsonPathExist(stdout, "devControlPlane")
plt := "cluster"
if podman {
plt = "podman"
}
helper.JsonPathContentHasLen(stdout, "devControlPlane", 1)
helper.JsonPathContentIs(stdout, "devControlPlane.0.platform", plt)
if customPort {
helper.JsonPathContentIs(stdout, "devControlPlane.0.localPort", strconv.Itoa(localPort))
} else {
helper.JsonPathContentIsValidUserPort(stdout, "devControlPlane.0.localPort")
}
helper.JsonPathContentIs(stdout, "devControlPlane.0.apiServerPath", "/api/v1/")
helper.JsonPathDoesNotExist(stdout, "devControlPlane.0.webInterfacePath")
})
})
}))
}
}
}))
When("the component is bootstrapped", helper.LabelPodmanIf(podman, func() {
BeforeEach(func() {