Commit Graph

46 Commits

Author SHA1 Message Date
Varun Gandhi
e4bb0b5ce6
chore: Remove client construction from SignUp/In funcs (#62789)
These functions are used in test code, which makes it tricker to
pass in loggers for checking requests and responses. Instead, make
the API method-based. This introduces slightly more boilerplate
since Client construction is fallible, but it allows calling code
to pass in loggers more easily for debugging test failures.
2024-05-21 15:18:58 +02:00
Varun Gandhi
7347853bba
chore: Factor out logic for modifying site config (#62768)
Multiple integration tests have essentially the same code for
modifying the site config, and then resetting it to it original
state. Refactor that out into a common method.
2024-05-21 15:16:48 +02:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Varun Gandhi
a447b6121a
chore: Refactor codeintel middleware code (#62573)
Fixes GRAPH-570

Adds new unit tests and updates integration test.
2024-05-09 12:48:12 +00:00
Noah S-C
98e0f75d1e
bazel: use transitions to apply cross-compile platform automatically to oci_image (#60569)
Removes the need to pass `--config=docker-darwin` through the following mechanisms:

1. `--enable_platform_specific_config` to enable certain flags on macos only e.g. `--extra_toolchains @zig_sdk//toolchain:linux_amd64_gnu.2.34` and `--sandbox_add_mount_pair=/tmp` (see [.bazelrc change](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=dotfile&show-viewed-files=true))
2. Apply a transition (using https://github.com/fmeum/with_cfg.bzl, please view [the following great video on it](https://www.youtube.com/watch?v=U5bdQRQY-io)) on `oci_image` targets when on the `@platforms//os:macos` platform to transition to the `@zig_sdk//platform:linux_amd64` platform. 
	- This will start at `oci_image` targets and propagate down to e.g. `go_{binary,library}` etc targets with the "transitioned" platform configuration, resulting in them being built with the transitioned-to platform
3. Remove `darwin_docker_e2e_go` config_setting and `darwin-docker` bool_flag.
	- These aren't necessary anymore, as the places where these were used were not in the transitive closure rooted at an `oci_image` target, meaning they wouldn't be transitioned.

To review, view [the following (filtered) files](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=.bzl&file-filters%5B%5D=.sh&file-filters%5B%5D=.yaml&file-filters%5B%5D=No+extension&file-filters%5B%5D=dotfile&show-viewed-files=true)  along with [the root BUILD.bazel](https://github.com/sourcegraph/sourcegraph/pull/60569/files#diff-7fc57714ef13c3325ce2a1130202edced92fcccc0c6db34a72f7b57f60d552a3). All the other files are just changing the `load` statements from `@rules_oci` to `//dev:oci_defs.bzl`

## Test plan

CI, checked image locally and `sg test bazel-backend-integration` & `sg test bazel-e2e`
2024-02-20 13:57:56 +00:00
Chris Warwick
b9099792b9
Implement expiry for access tokens (#59565)
Implement expiry for access tokens, by default all newly created access tokens will expire.  There is site configuration available at auth.accessToken to enable tokens without expiration and to configure the values in days are presented to users and selected by default. 

Co-authored-by: Erik Seliger <erikseliger@me.com>
2024-01-18 18:54:07 -05:00
Erik Seliger
a2fbaf830f
Remove dead code from org invites (#57279)
Whether we remove email org invitations or not, this code is currently not used and increases our ownership surface area, thus I'm removing it here. We can always revert, should we need it again.
2023-10-04 15:50:44 +02:00
Jean-Hadrien Chabran
54005e461f
Allow to run e2e tests locally (#55998)
Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-08-29 11:08:47 -05:00
Jean-Hadrien Chabran
3d36d34b3d
ci: re-enable race detection (#52776)
The previous approach to enable race detection was too radical and
accidently led to build our binaries with the race flage enabled, which
caused issues when building images down the line.

This happened because putting a `test --something` in bazelrc also sets
it on `build` which is absolutely not what we wanted. Usually folks get
this one working by having a `--stamp` config setting that fixes this
when releasing binaries, which we don't at this stage, as we're still
learning Bazel.

Luckily, this was caught swiftly. The current approach insteads takes a
more granular approach, which makes the `go_test` rule uses our own
variant, which injects the `race = "on"` attribute, but only on
`go_test`.


## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI, being a main-dry-run, this will cover the container building jobs,
which were the ones failing.

---------

Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
2023-06-05 20:41:47 +02:00
Jean-Hadrien Chabran
58da6780d7
Switch to OCI/Wolfi based image (#52693)
This PR ships our freshly rewritten container images built with
rules_oci and Wolfi, which for now will only be used on S2.

*What is this about*

This work is the conjunction of [hardening container
images](https://github.com/orgs/sourcegraph/projects/302?pane=issue&itemId=25019223)
and fully building our container images with Bazel.

* All base images are now distroless, based on Wolfi, meaning we fully
control every little package version and we won't be subject anymore to
Alpine maintainers dropping a postgres version for example.

* Container images are now built with `rules_oci`, meaning we don't have
Dockerfile anymore, but instead created through [Bazel
rules](https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph@bzl/oci_wolfi/-/blob/enterprise/cmd/gitserver/BUILD.bazel).
Don't be scared, while this will look a bit strange to you at first,
it's much saner and simpler to do than our Dockerfiles and their muddy
shell scripts calling themselves in cascade.


:spiral_note_pad:  *Plan*:

*1/ (NOW) We merge our branch on `main` today, here is what it does
change for you 👇:skin-tone-3::*

* On `main`: 
* It will introduce a new job on `main` _Bazel Push_, which will push
those new images on our registries with all tags prefixed by `bazel-`.
    * These new images will be picked up by S2 and S2 only. 
* The existing jobs building docker images and pushing them will stay in
place until we have QA'ed them enough and are confident to roll them out
on Dotcom.
* Because we'll be building both images, there will be more jobs running
on `main`, but this should not affect the wall clock time.
* On all branches (so your PRs and `main`)
* The _Bazel Test_ job will now run: Backend Integration Tests, E2E
Tests and CodeIntel QA
* This will increase the duration of your test jobs in PRs, but as we
haven't removed yet the `sg lint` step, it should not affect too much
the wall clock time of your PRs.
* But it will also increase your confidence toward your changes, as the
coverage will vastly increased compared to before.
* If you have ongoing branches which are affecting the docker images
(like adding a new binary, like the recent `scip-tags`, reach us out on
#job-fair-bazel so we can help you to port your changes. It's much much
simpler than before, but it's going to be unfamiliar to you).

* If something goes awfully wrong, we'll rollback and update this
thread.

*2/ (EOW / Early next week) Once we're confident enough with what we saw
on S2, we'll roll the new images on Dotcom.*

* After the first successful deploy and a few sanity checks, we will
drop the old images building jobs.
* At this point, we'll reach out to all TLs asking for their help to
exercise all features of our product to ensure we catch any potential
breakage.



## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->


* We tested our new images on `scale-testing` and it worked.
* The new container building rules comes with _container tests_ which
ensures that produced images are containing and configured with what
should be in there:
[example](https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph@bzl/oci_wolfi/-/blob/enterprise/cmd/gitserver/image_test.yaml)
.

---------

Co-authored-by: Dave Try <davetry@gmail.com>
Co-authored-by: Will Dollman <will.dollman@sourcegraph.com>
2023-06-02 12:12:52 +02:00
Joe Chen
7d693e686a
cloud: guard o11y for non-operator users (#51331)
This is a re-attempt of
https://github.com/sourcegraph/sourcegraph/pull/51230 which [fixes
backend integration tests
accordingly](https://github.com/sourcegraph/sourcegraph/pull/51331/files#diff-8e131337736d5def881b5a3a6ffee82dca23198d1e573f2ddb9605fc3a67506c).

## Test plan

Please see https://github.com/sourcegraph/sourcegraph/pull/51230
2023-05-05 16:35:23 +00:00
Alex Ostrikov
d0c99a945b
chore: remove user tags functionality. (#50051)
Test plan:
CI.

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2023-03-29 11:53:04 +04:00
Sander Ginn
841bd670a5
executors: refactor queue router to explicit test endpoint (#49721)
- Closes https://github.com/sourcegraph/sourcegraph/issues/49718

This PR refactors the base test router of the executor queue handler to
an explicit `/test` endpoint, and adds a path `/auth` for testing
authorization.

It updates `code_intel_test.go` to make use of this new endpoint.

## Test plan
- [x] Existing and child PRs tests pass
- [x] Tested on scaletesting
   ```shell
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# echo
$EXECUTOR_FRONTEND_PASSWORD
   <REDACTED>
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# echo
$EXECUTOR_FRONTEND_URL
   https://scaletesting.sgdev.org
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# executor validate
   All checks passed!
   
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# export
EXECUTOR_FRONTEND_PASSWORD=denied
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# executor validate
t=2023-03-24T17:42:57+0000 lvl=eror msg="apiclient got unexpected status
code" code=401 body=
failed to authorize with frontend, is executors.accessToken set
correctly in the site-config?
   
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# export
EXECUTOR_FRONTEND_URL=scaletesting.sgdev.org
root@sginn-sourcegraph-executor-x1z5:/usr/local/bin# executor validate
EXECUTOR_FRONTEND_URL must be in the format scheme://host (and
optionally :port)
   ```

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

---------

Co-authored-by: Daniel Dides <8784265+danieldides@users.noreply.github.com>
2023-03-24 18:11:13 +00:00
Eric Fritz
6ba53c8a3d
codeintel: Update auth test to target new (preferred) resolver (#49524) 2023-03-16 10:31:11 -05:00
Dave Try
2b8fa079f0
bazel: fix buf files (#49444)
fix protoc-gen-go version
2023-03-15 20:21:38 +00:00
Dave Try
293385d5dd
bazel: update timeouts to suppress warnings (#49399)
Updates all of the BUILD fields with timeouts to suppress warnings and
reduce log spam.


## Test plan

Green CI
2023-03-15 15:04:16 +02:00
Erik Seliger
e50a05d5e6
Fix integration test for list users (#48276)
Not a site-admin protected route anymore, so we have to remove this
test! See https://github.com/sourcegraph/sourcegraph/pull/48237 for
context on this change.
2023-02-27 15:11:13 +00:00
Eric Fritz
8e2430627c
codeintel: Add deprecation notice to LSIF handler (#47547) 2023-02-20 15:07:40 +00:00
Dave Try
1445abe99e
bazel: fix //enterprise/internal/... (#47846)
Merge fixes for `bazel test //enterprise/internal/...`


## Test plan

```bazel test //enterprise/internal/...```
2023-02-18 12:07:49 -05:00
Milan Freml
bc2c9437d8
[fix] Assert error based on the test setup (#47827)
Proper fix for #47806 
- #47806 

## Test plan

Tested with a main-dry-run here:
https://buildkite.com/sourcegraph/sourcegraph/builds/199730
2023-02-17 18:30:08 +01:00
Bolaji Olajide
757d369d02
authtest: properly assert error (#47806)
## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
Manually tested

---------

Co-authored-by: Milan Freml <kopancek@users.noreply.github.com>
Co-authored-by: Milan Freml <milan.freml@sourcegraph.com>
2023-02-17 17:19:53 +01:00
Jean-Hadrien Chabran
bc5490c4bb
bazel: introduce build files for Go (#46770) 2023-01-23 14:00:01 +01:00
Naman Kumar
c779796f64
[Org Members] Add pagination (#46067)
- Add pagination to org members page
- Improve UI by adding avatar and user role
- Remove version of org members page which was available under a feature flag but not used.
2023-01-17 12:25:22 +01:00
Eric Fritz
a51ee7bad7
ci: Fix main by referring to correct casing (#46305) 2023-01-10 17:17:23 -08:00
Stefan Hengl
e14b9c8204
graphqlbackend: add mutation to reindex repository (#45056)
This adds a new mutation that lets us trigger a reindex from frontend.
The goal is to add a reindex button, calling this mutation, to the index
status page.
2022-12-05 09:13:47 +01:00
Petri-Johan Last
3502c3a36a
Prevent race conditions when updating site config by checking Last ID (#42738) 2022-10-10 10:10:13 +02:00
Alex Ostrikov
86c9b9bc28
graphqlbackend: support async deletion of external service (#35293) 2022-05-12 12:54:12 +04:00
Jean-Hadrien Chabran
2ce250b30b
Revert "graphqlbackend: support async deletion of external service (#34701) (#35289) 2022-05-11 14:22:18 +02:00
Alex Ostrikov
3ff2175a34
graphqlbackend: support async deletion of external service (#34701) 2022-05-11 14:31:25 +04:00
Keegan Carruthers-Smith
18f487ccaa
all: use any instead of interface{} (#35102)
Now that we require go1.18, we can use a builtin type alias for
"interface{}": "any". I've updated all code except lib, which can be
imported by external modules. That is currently pinned at go1.16.
Additionally I had to rerun generate since rewriting generated go code
will fail CI.

  find -name '*.go' | xargs gofmt -s -r 'interface{} -> any' -w
  git checkout lib
  go generate ./...

Test Plan: CI will exercise that the code still compiles. Otherwise this
is a noop.
2022-05-09 10:59:39 +02:00
Milan Freml
e29d8182db
[cloud] Add email to inviteUserToOrganization mutation (#30632) 2022-02-04 09:22:37 +01:00
Eric Fritz
3dde1f43a9
gqltest: Lower timeout for settings to be available (#29939) 2022-01-19 14:23:28 -06:00
Eric Fritz
417fc319eb
auth: Update executor auth tests (#29926) 2022-01-19 11:50:26 -08:00
Robert Lin
369464f3d3
ci: only log NeedsSiteInit response in buildkite (#29707) 2022-01-13 09:24:39 -08:00
Robert Lin
2f245b11ae
dev/ci/integration: unify docker cleanup (#29532) 2022-01-10 19:39:19 +00:00
Camden Cheek
36945b6243
remove test for disabled notifications (#28358)
This is causing backend integration tests to fail.
2021-11-30 11:34:28 -07:00
Jean-Hadrien Chabran
584fc832af
Disable flaky test in the authtest suite (#28295) 2021-11-30 10:38:13 +01:00
Joe Chen
544f1d4d18
authtest: wait longer for site config to be updated (#28119) 2021-11-29 22:26:45 +08:00
Thorsten Ball
452f894f8f
Skip failing test TestCodeIntelEndpoints (#28074) 2021-11-23 13:46:29 +00:00
ᴜɴᴋɴᴡᴏɴ
f1765df3ca
authtest: ensure only site admins can list users (#21199) 2021-05-23 16:21:13 +08:00
ᴜɴᴋɴᴡᴏɴ
a700627225
authtest: to be run within backend integration test suite (#20493) 2021-05-06 07:28:36 +08:00
ᴜɴᴋɴᴡᴏɴ
d1eb7bc41a
authtest: add tests for LSIF upload (#20454) 2021-04-28 20:41:41 +08:00
ᴜɴᴋɴᴡᴏɴ
c4e5836770
authtest: add tests for organization endpoints (#20417) 2021-04-27 13:42:59 +00:00
ᴜɴᴋɴᴡᴏɴ
da7fe21fac
authtest: add tests for access repositories (#20416) 2021-04-27 21:36:08 +08:00
ᴜɴᴋɴᴡᴏɴ
16a7bb1cb4
authtest: add tests for site admin endpoints (#20266) 2021-04-26 13:14:57 +00:00
ᴜɴᴋɴᴡᴏɴ
5cbc33c6a2
authtest: Scaffold site admin endpoints (#20009) 2021-04-14 20:36:18 +08:00