mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 11:01:44 +00:00
Currently, all backend integration tests transitively depend on the client bundle. This results in rebuilds of the closure, and a (likely) cache miss on the test, when modifying any client-side files.
Given that the client bundle isnt needed for these tests, we can create targets that don't include the client bundle in its transitive closure, which should in theory improve the cache hit for backend integration tests by not having client side changes invalidate it. This would also be beneficial in local env, to keep frontend rebuilds down
To do this, we still need to create a `web.manifest.json` file due to some unfortunate requirement on that file existing as part of initializing the sourcegraph instance. For this I just create an empty json file, `select` this instead of the client bundle target in client/web/dist/BUILD.bazel based on a `//:integration_testing_enabled` config setting, and creating a `go_binary`-wrapping bazel rule + macro that automatically applies a transition to set this to true `go_binary_nobundle`, and using that rule for the specific `//cmd/{server,frontend}:{server,frontend}_nobundle` binary rules (along with the relevant `oci_{image,tarball}` etc rules to consume it).
## Test plan
- Integration tests in CI still work
- `bazel cquery 'kind("js_library", deps(//cmd/frontend:image_nobundle))'`, `bazel cquery 'kind("js_library", deps(//cmd/server:image_nobundle))'`, ``bazel cquery 'kind("js_library", deps(//testing:backend_integration_test))'` etc all return empty set
- Release test with marker in web bundle to ensure released images contain the web bundle via `sg release run test --version 5.4.2` (commenting out other tests for brevity)
243 lines
8.2 KiB
Python
243 lines
8.2 KiB
Python
load(":defs.bzl", "server_integration_test")
|
|
|
|
server_integration_test(
|
|
name = "e2e_test",
|
|
timeout = "long",
|
|
args = [
|
|
"$(location //client/web/src/end-to-end:e2e)",
|
|
"$(rootpath //:mocha_config)",
|
|
"'$(rootpath //client/web/src/end-to-end:testing_e2e_bundle)/**/*.test.js'",
|
|
],
|
|
data = [
|
|
"//:mocha_config",
|
|
"//client/web/src/end-to-end:e2e",
|
|
"//client/web/src/end-to-end:testing_e2e_bundle",
|
|
"//cmd/server:image_tarball",
|
|
],
|
|
env = {
|
|
"TEST_USER_EMAIL": "test@sourcegraph.com",
|
|
"TEST_USER_PASSWORD": "supersecurepassword",
|
|
"SOURCEGRAPH_SUDO_TOKEN": "fake-sg-token",
|
|
"NO_CLEANUP": "false",
|
|
"KEEP_BROWSER": "false",
|
|
"DEVTOOLS": "false",
|
|
"BROWSER": "chrome",
|
|
"WINDOW_WIDTH": "1280",
|
|
"WINDOW_HEIGHT": "1024",
|
|
"LOG_BROWSER_CONSOLE": "false",
|
|
# Enable findDom on CodeMirror
|
|
"INTEGRATION_TESTS": "true",
|
|
},
|
|
env_inherit = [
|
|
"DISPLAY",
|
|
"HEADLESS",
|
|
"SOURCEGRAPH_BASE_URL",
|
|
"GHE_GITHUB_TOKEN",
|
|
"GH_TOKEN",
|
|
"SOURCEGRAPH_LICENSE_GENERATION_KEY",
|
|
"SOURCEGRAPH_LICENSE_KEY",
|
|
],
|
|
port = "7080",
|
|
runner_src = ":e2e_test.sh",
|
|
server_image = "//cmd/server:image_tarball",
|
|
)
|
|
|
|
# Warning, this targets explicitly exclude p4 subrepo perms tests as they're very heavy and time
|
|
# consuming, due to having to add a repo, index it, etc ...
|
|
#
|
|
# See :backend_integration_test_p4 for then one, as opposed to this target, runs those tests
|
|
# exclusively.
|
|
server_integration_test(
|
|
name = "backend_integration_test",
|
|
timeout = "long",
|
|
args = [
|
|
"$(location //dev/gqltest:gqltest_test)", # actual test
|
|
"$(location //dev/authtest:authtest_test)", # actual test
|
|
],
|
|
data = [
|
|
"//cmd/server:no_client_bundle.image_tarball",
|
|
"//dev/authtest:authtest_test",
|
|
"//dev/gqltest:gqltest_test",
|
|
],
|
|
env_inherit = [
|
|
"AWS_ACCESS_KEY_ID",
|
|
"AWS_CODE_COMMIT_PASSWORD",
|
|
"AWS_CODE_COMMIT_USERNAME",
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
"AZURE_DEVOPS_TOKEN",
|
|
"AZURE_DEVOPS_USERNAME",
|
|
"BITBUCKET_SERVER_TOKEN",
|
|
"BITBUCKET_SERVER_URL",
|
|
"BITBUCKET_SERVER_USERNAME",
|
|
"GHE_GITHUB_TOKEN",
|
|
"PERFORCE_PASSWORD",
|
|
"PERFORCE_PORT",
|
|
"PERFORCE_USER",
|
|
"SOURCEGRAPH_LICENSE_GENERATION_KEY",
|
|
"SOURCEGRAPH_LICENSE_KEY",
|
|
],
|
|
port = "7081",
|
|
runner_src = ":backend_integration_test.sh",
|
|
server_image = "//cmd/server:no_client_bundle.image_tarball",
|
|
)
|
|
|
|
# The perforce subrepo permission testing is really heayv, as it requires to add a new repo,
|
|
# clone it, index it, etc... Therefore a crude yet effective optimization here is to separate
|
|
# those tests from the rest of the backeng integration tests, and instead run them in isolation,
|
|
# with the same exact runner and setup.
|
|
#
|
|
# But because Bazel tests targets are executed concurrently, even if the duration is ultimately the# same, if not even more due to the additional overhead of spawning a Sourcegraph server, the wall
|
|
# clock time is ultimately much better, because they're executed concurrently.
|
|
server_integration_test(
|
|
name = "backend_integration_test_p4",
|
|
timeout = "long",
|
|
args = [
|
|
"$(location //dev/gqltest:gqltest_test)", # actual test
|
|
],
|
|
data = [
|
|
"//cmd/server:no_client_bundle.image_tarball",
|
|
"//dev/authtest:authtest_test",
|
|
"//dev/gqltest:gqltest_test",
|
|
],
|
|
env_inherit = [
|
|
"AWS_ACCESS_KEY_ID",
|
|
"AWS_CODE_COMMIT_PASSWORD",
|
|
"AWS_CODE_COMMIT_USERNAME",
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
"AZURE_DEVOPS_TOKEN",
|
|
"AZURE_DEVOPS_USERNAME",
|
|
"BITBUCKET_SERVER_TOKEN",
|
|
"BITBUCKET_SERVER_URL",
|
|
"BITBUCKET_SERVER_USERNAME",
|
|
"GHE_GITHUB_TOKEN",
|
|
"PERFORCE_PASSWORD",
|
|
"PERFORCE_PORT",
|
|
"PERFORCE_USER",
|
|
"SOURCEGRAPH_LICENSE_GENERATION_KEY",
|
|
"SOURCEGRAPH_LICENSE_KEY",
|
|
],
|
|
port = "7082",
|
|
runner_src = ":backend_integration_test_p4.sh",
|
|
server_image = "//cmd/server:no_client_bundle.image_tarball",
|
|
tags = [TAG_PLATFORM_SOURCE],
|
|
)
|
|
|
|
server_integration_test(
|
|
name = "codeintel_integration_test",
|
|
args = [
|
|
"$(location //internal/cmd/init-sg)",
|
|
"$(rlocationpath //dev/tools:src-cli)",
|
|
"$(location //dev/codeintel-qa/cmd/download)",
|
|
"$(location //dev/codeintel-qa/cmd/clear)",
|
|
"$(location //dev/codeintel-qa/cmd/upload)",
|
|
"$(location //dev/codeintel-qa/cmd/query)",
|
|
"$(location //testing/code-intel:repos.json)",
|
|
],
|
|
data = [
|
|
"//cmd/server:no_client_bundle.image_tarball",
|
|
"//dev/codeintel-qa/cmd/clear",
|
|
"//dev/codeintel-qa/cmd/download",
|
|
"//dev/codeintel-qa/cmd/query",
|
|
"//dev/codeintel-qa/cmd/upload",
|
|
"//dev/tools:src-cli",
|
|
"//internal/cmd/init-sg",
|
|
"//testing/code-intel:repos.json",
|
|
],
|
|
env = {
|
|
"TEST_USER_EMAIL": "test@sourcegraph.com",
|
|
"TEST_USER_PASSWORD": "supersecurepassword",
|
|
"SOURCEGRAPH_SUDO_USER": "admin",
|
|
"HOME": ".",
|
|
"__LOCAL__": "false",
|
|
},
|
|
env_inherit = [
|
|
"AWS_ACCESS_KEY_ID",
|
|
"AWS_CODE_COMMIT_PASSWORD",
|
|
"AWS_CODE_COMMIT_USERNAME",
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
"AZURE_DEVOPS_TOKEN",
|
|
"AZURE_DEVOPS_USERNAME",
|
|
"BITBUCKET_SERVER_TOKEN",
|
|
"BITBUCKET_SERVER_URL",
|
|
"BITBUCKET_SERVER_USERNAME",
|
|
"GITHUB_TOKEN",
|
|
"PERFORCE_PASSWORD",
|
|
"PERFORCE_PORT",
|
|
"PERFORCE_USER",
|
|
"SOURCEGRAPH_LICENSE_GENERATION_KEY",
|
|
"SOURCEGRAPH_LICENSE_KEY",
|
|
],
|
|
port = "7083",
|
|
runner_src = ":codeintel_integration_test.sh",
|
|
server_image = "//cmd/server:no_client_bundle.image_tarball",
|
|
tags = [
|
|
"exclusive",
|
|
"manual",
|
|
TAG_PLATFORM_GRAPH,
|
|
],
|
|
)
|
|
|
|
# This one is bit perculiar, when running the codeintel-qa locally, we need to disable the sandbox
|
|
# so the runner can access the gcloud creds which are living in the users HOME, under
|
|
# .config/gcloud/application_default_credentials.json.
|
|
#
|
|
# It's more complicated to make the server_integration_test macro handle this automatically than it is to
|
|
# duplicate it, so we just duplicate and tweak it instead. It uses the same port, because those two tasks will
|
|
# never be run at the same time anyway. There is a safe guard in the original one that informs the user
|
|
# to use this variant instead.
|
|
server_integration_test(
|
|
name = "codeintel_integration_test_local",
|
|
args = [
|
|
"$(location //internal/cmd/init-sg)",
|
|
"$(rlocationpath //dev/tools:src-cli)",
|
|
"$(location //dev/codeintel-qa/cmd/download)",
|
|
"$(location //dev/codeintel-qa/cmd/clear)",
|
|
"$(location //dev/codeintel-qa/cmd/upload)",
|
|
"$(location //dev/codeintel-qa/cmd/query)",
|
|
"$(location //testing/code-intel:repos.json)",
|
|
],
|
|
data = [
|
|
"//cmd/server:no_client_bundle.image_tarball",
|
|
"//dev/codeintel-qa/cmd/clear",
|
|
"//dev/codeintel-qa/cmd/download",
|
|
"//dev/codeintel-qa/cmd/query",
|
|
"//dev/codeintel-qa/cmd/upload",
|
|
"//dev/tools:src-cli",
|
|
"//internal/cmd/init-sg",
|
|
"//testing/code-intel:repos.json",
|
|
],
|
|
env = {
|
|
"TEST_USER_EMAIL": "test@sourcegraph.com",
|
|
"TEST_USER_PASSWORD": "supersecurepassword",
|
|
"SOURCEGRAPH_SUDO_USER": "admin",
|
|
"HOME": ".",
|
|
"__LOCAL__": "true",
|
|
},
|
|
env_inherit = [
|
|
"AWS_ACCESS_KEY_ID",
|
|
"AWS_CODE_COMMIT_PASSWORD",
|
|
"AWS_CODE_COMMIT_USERNAME",
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
"AZURE_DEVOPS_TOKEN",
|
|
"AZURE_DEVOPS_USERNAME",
|
|
"BITBUCKET_SERVER_TOKEN",
|
|
"BITBUCKET_SERVER_URL",
|
|
"BITBUCKET_SERVER_USERNAME",
|
|
"GITHUB_TOKEN",
|
|
"PERFORCE_PASSWORD",
|
|
"PERFORCE_PORT",
|
|
"PERFORCE_USER",
|
|
"SOURCEGRAPH_LICENSE_GENERATION_KEY",
|
|
"SOURCEGRAPH_LICENSE_KEY",
|
|
"GOOGLE_APPLICATION_CREDENTIALS",
|
|
],
|
|
port = "7083",
|
|
runner_src = ":codeintel_integration_test.sh",
|
|
server_image = "//cmd/server:no_client_bundle.image_tarball",
|
|
tags = [
|
|
"manual",
|
|
"no-sandbox",
|
|
TAG_PLATFORM_GRAPH,
|
|
],
|
|
)
|