Skip to content

Commit

Permalink
[test] fix integration tests (#19692)
Browse files Browse the repository at this point in the history
* [test] fix TestProcessPriority

Need to give ws-daemon time before it applies process priority

* [server] always limit network connections

We are not limiting network connections for preview environments

* Cleanup

* Fix

* Always do network limiting
* Regardless of billing mode
* If there's an error

* Wait a bit longer, just in-case, to make the test more durable

* Cleanup

* No parallel

* [preview] update to use gen111 image

* [test] fix TestOpenWorkspaceFromPrebuild test

It was failing with an exit code of 2 on grep, because it was trying to grep a folder, rather than recurse into it.

When the grep command was run manually from a workspace that started from a prebuild, we saw `grep: logs: Is a directory`. So, it's important for integration tests to output the exit code, but also error text.

* [test] fix TestOpenWorkspaceFromPrebuild

We need to wait for the started workspace to stop, before we try to restart it

* be parallel again

* Nope

* Set StripeSecret on Preview install

Otherwise this returns false:
https://github.com/gitpod-io/gitpod/blob/643701c6352609b3bab3090d271d38cb42b33b3c/components/server/src/billing/billing-mode.ts#L25

Because EnablePayment is set to false at install time:
https://github.com/gitpod-io/gitpod/blob/643701c6352609b3bab3090d271d38cb42b33b3c/install/installer/pkg/components/server/configmap.go#L282
  • Loading branch information
kylos101 committed May 7, 2024
1 parent dc7df22 commit 606963a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dev/preview/infrastructure/modules/gce/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ variable "dev_kube_context" {
variable "vm_image" {
type = string
description = "The VM image"
default = "gitpod-k3s-202402021944"
default = "gitpod-k3s-202404302137"
}

variable "cert_issuer" {
Expand Down
2 changes: 1 addition & 1 deletion dev/preview/infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ variable "vm_type" {
variable "vm_image" {
type = string
description = "The VM image"
default = "gitpod-k3s-202402021944"
default = "gitpod-k3s-202404302137"
}

variable "cert_issuer" {
Expand Down
1 change: 1 addition & 0 deletions dev/preview/workflow/preview/deploy-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ then
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
apply -n ${PREVIEW_NAMESPACE} -f -
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.server.StripeSecret "stripe-api-keys"
fi

#
Expand Down
16 changes: 8 additions & 8 deletions test/tests/components/ws-manager/prebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {
// launch the workspace from prebuild
// TODO: change to use server API to launch the workspace, so we could run the integration test as the user code flow
// which is client -> server -> ws-manager rather than client -> ws-manager directly
ws, stopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
ws, stopWsFunc, err := integration.LaunchWorkspaceDirectly(t, ctx, api, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
req.Spec.FeatureFlags = test.FF
req.Spec.Initializer = &csapi.WorkspaceInitializer{
Spec: &csapi.WorkspaceInitializer_Prebuild{
Expand Down Expand Up @@ -301,7 +301,7 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {

t.Cleanup(func() {
// stop workspace in defer function to prevent we forget to stop the workspace
if err := stopWorkspace(t, cfg, stopWs); err != nil {
if err := stopWorkspace(t, cfg, stopWsFunc); err != nil {
t.Errorf("cannot stop workspace: %q", err)
}
})
Expand Down Expand Up @@ -343,14 +343,14 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
defer sapi.Done(t)

// stop workspace without wait
_, err = stopWs(false, sapi)
// stop workspace and wait, we're about to restart it
_, err = stopWsFunc(true, sapi)
if err != nil {
t.Fatal(err)
}

// reopen the workspace and make sure the file foobar.txt exists
ws1, stopWs1, err := integration.LaunchWorkspaceDirectly(t, ctx, sapi, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
ws1, stopWs1Func, err := integration.LaunchWorkspaceDirectly(t, ctx, sapi, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
req.ServicePrefix = ws.Req.ServicePrefix
req.Metadata.MetaId = ws.Req.Metadata.MetaId
req.Metadata.Owner = ws.Req.Metadata.Owner
Expand All @@ -372,7 +372,7 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {

t.Cleanup(func() {
// stop workspace in defer function to prevent we forget to stop the workspace
if err := stopWorkspace(t, cfg, stopWs1); err != nil {
if err := stopWorkspace(t, cfg, stopWs1Func); err != nil {
t.Errorf("cannot stop workspace: %q", err)
}
})
Expand Down Expand Up @@ -593,7 +593,7 @@ func checkPrebuildLogExist(t *testing.T, cfg *envconf.Config, rsa *integration.R
Command: "bash",
Args: []string{
"-c",
fmt.Sprintf("grep %s *", prebuildLog),
fmt.Sprintf("grep -r %s *", prebuildLog),
},
}, &grepResp)
if err == nil && grepResp.ExitCode == 0 && strings.Trim(grepResp.Stdout, " \t\n") != "" {
Expand All @@ -603,7 +603,7 @@ func checkPrebuildLogExist(t *testing.T, cfg *envconf.Config, rsa *integration.R
return
}

t.Logf("cannot found the prebuild message %s in %s, err:%v, exitCode:%d, stdout:%s", prebuildLog, prebuildLogPath, err, grepResp.ExitCode, grepResp.Stdout)
t.Logf("cannot found the prebuild message %s in %s, err:%v, exitCode:%d, stdout:%s, stderr:%s", prebuildLog, prebuildLogPath, err, grepResp.ExitCode, grepResp.Stdout, grepResp.Stderr)

// somehow, the prebuild log message '🍊 This task ran as a workspace prebuild' does not exists
// we fall back to check the init task message within the /workspace/.gitpod/prebuild-log-* or not
Expand Down
4 changes: 3 additions & 1 deletion test/tests/workspace/process_priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func TestProcessPriority(t *testing.T) {
}
defer rsa.Close()

t.Logf("running ps")
t.Logf("waiting for the next ws-daemon tick, before running ps")
time.Sleep(15 * time.Second)

var res agent.ExecResponse
err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
Dir: "/workspace",
Expand Down

0 comments on commit 606963a

Please sign in to comment.