Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Dockerfile
initrd
.tmp
server/api
server/e2e
server/**/*_test.go
server/**/testdata
20 changes: 19 additions & 1 deletion .github/workflows/server-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "server/go.mod"
cache: false
cache: true
cache-dependency-path: server/go.sum

- name: Compute short SHA for images
id: vars
Expand All @@ -90,6 +91,23 @@ jobs:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Pull e2e images
shell: bash
run: |
set -euo pipefail

docker pull "$E2E_CHROMIUM_HEADFUL_IMAGE" &
headful_pid=$!

docker pull "$E2E_CHROMIUM_HEADLESS_IMAGE" &
headless_pid=$!

wait "$headful_pid"
wait "$headless_pid"
env:
E2E_CHROMIUM_HEADFUL_IMAGE: onkernel/chromium-headful:${{ steps.vars.outputs.short_sha }}
E2E_CHROMIUM_HEADLESS_IMAGE: onkernel/chromium-headless:${{ steps.vars.outputs.short_sha }}

- name: Run server e2e tests
run: make test-e2e
working-directory: server
Expand Down
27 changes: 26 additions & 1 deletion server/e2e/e2e_enterprise_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ func TestExtensionDownloadLogSince(t *testing.T) {
require.Equal(t, "line 3\n", extensionDownloadLogSince("line 3\n", ""))
}

func TestNextExtensionInstallPollDelay(t *testing.T) {
t.Parallel()

require.Zero(t, nextExtensionInstallPollDelay(0))
require.Zero(t, nextExtensionInstallPollDelay(-time.Millisecond))
require.Equal(t, 250*time.Millisecond, nextExtensionInstallPollDelay(500*time.Millisecond))
require.Equal(t, time.Second, nextExtensionInstallPollDelay(time.Second))
require.Equal(t, time.Second, nextExtensionInstallPollDelay(5*time.Second))
}

// checkChromePolicies checks how Chrome sees the policies.
func checkChromePolicies(t *testing.T, ctx context.Context, c *TestContainer) {
t.Helper()
Expand Down Expand Up @@ -598,15 +608,30 @@ func waitForExtensionInstalled(t *testing.T, ctx context.Context, c *TestContain
return
}

delay := nextExtensionInstallPollDelay(time.Until(deadline))
if delay <= 0 {
continue
}

select {
case <-ctx.Done():
require.NoError(t, ctx.Err(), "context cancelled waiting for extension installation")
return
case <-time.After(1 * time.Second):
case <-time.After(delay):
}
}
}

func nextExtensionInstallPollDelay(remaining time.Duration) time.Duration {
if remaining <= 0 {
return 0
}
if remaining < time.Second {
return remaining / 2
}
return time.Second
}

func chromeExtensionsCheckOutput(ctx context.Context, c *TestContainer, expectedExtensionName string) ([]byte, error) {
cmd := exec.CommandContext(ctx, "pnpm", "exec", "tsx", "-e", fmt.Sprintf(`
const { chromium } = require('playwright-core');
Expand Down
Loading