-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix integration tests #7827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix integration tests #7827
Changes from all commits
b6e4704
6af99c5
f36b942
d0c1544
ec61d39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,22 +29,45 @@ There is a [werft job](../.werft/run-integration-tests.yaml) that runs the integ | |
|
||
Example command: | ||
``` | ||
werft job run github -j .werft/run-integration-tests.yaml -a namespace=staging-gpl-2658-int-tests -a version=gpl-2658-int-tests.57 -f | ||
werft run github -j .werft/run-integration-tests.yaml -a namespace=staging-gpl-2658-int-tests -a version=gpl-2658-int-tests.57 -f | ||
``` | ||
|
||
### Manually against a Kubernetes cluster | ||
### Manually | ||
|
||
You may want to run tests to assert whether your Gitpod installation is successfully integrated. | ||
You may want to run tests to assert whether a Gitpod installation is successfully integrated. | ||
|
||
To test your Gitpod installation: | ||
#### Using a pod | ||
|
||
1. Set your kubectl context to the cluster you want to test | ||
2. Integrate the Gitpod installation with OAuth for Github and/or Gitlab, otherwise related tests may fail | ||
3. Clone this repo, and `cd` to `./gitpod/test` | ||
4. Run the tests like so | ||
Best for when you want to validate an environment. | ||
|
||
1. Update image name in `integration.yaml` for job `integration-job` to latest built by werft. | ||
2. Optionally add your username in that job argument or any other additional params. | ||
2. Apply yaml file that will add all necessary permissions and create a job that will run tests. | ||
* [`kubectl apply -f ./integration.yaml`](./integration.yaml) | ||
3. Check logs to inspect test results like so `kubectl logs -f jobs/integration-job`. | ||
4. Tear down the integration user and job when testing is done. | ||
* [`kubectl delete -f ./integration.yaml`](./integration.yaml) | ||
|
||
#### Go test | ||
|
||
Best for when you're actively developing Gitpod. | ||
Test will work if images that they use are already cached by Gitpod instance. If not, they might fail if it takes too long to pull an image. | ||
There are 4 different types of tests: | ||
1. Enterprise specific, that require valid license to be installed. Run those with `-enterprise=true` | ||
2. Tests that require correct user (user should have github OAuth integration setup with gitpod). Run those with `-username=<gitpod_username>`. Make sure to load https://github.com/gitpod-io/gitpod-test-repo and https://github.com/gitpod-io/gitpod workspaces inside your gitpod that you are testing to preload those images onto your node. Wait for it to finish pulling those image, this will ensure that test will not fail due to timeout while waiting to pull an image for the first time. | ||
3. To test gitlab integration, add `-gitlab=true` | ||
4. All other tests. | ||
|
||
To run the tests: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you able to run the tests against a preview environment namespace? Like for this branch, as an example? I know the goal was to get it running against workspace-preview, but it would be interesting to see how it fairs here, too. Ideally we'd also be able to use these tests against core-dev (a set of namespaces in a single GKE cluster). Pretty soon core-dev will be replaced with Hertzner, where each preview environment (branch) gets a single node K3s cluster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. There is something with permissions when trying to run go tests in core-dev. when test calls kubectl it cannot access kubeconfig. And also you cannot run it via docker container due to permissions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry I missed your response from a couple days ago! 🙏 I rebased with main and did ec61d39 to get the tests runnable in werft against core-dev. May I ask for you to review? I just tried There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good, thank you! |
||
1. Clone this repo (`git clone git@github.com:gitpod-io/gitpod.git`), and `cd` to `./gitpod/test` | ||
2. Run the tests like so | ||
sagor999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```bash | ||
go test -v ./... \ | ||
-kubeconfig=<path_to_kube_config_file> \ | ||
-namespace=<namespace_where_gitpod_is_installed> \ | ||
-username=<a_user_in_the_gitpod_database> | ||
-username=<gitpod_user_with_oauth_setup> \ | ||
-enterprise=<true|false> \ | ||
-gitlab=<true|false> | ||
``` | ||
3. Tests `TestUploadDownloadBlob` and `TestUploadDownloadBlobViaServer` will fail when testing locally, as they are trying to connect to cluster local resources directly. To test them use docker image instead that runs within the cluster. | ||
4. If you want to run specific test, add `-run <test>` before `-kubeconfig` parameter. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: integration-svc | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: integration-role | ||
rules: | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- 'pods' | ||
- 'secrets' | ||
- 'services' | ||
- 'configmaps' | ||
- 'endpoints' | ||
verbs: | ||
- 'list' | ||
- 'get' | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- 'pods/portforward' | ||
- 'pods/exec' | ||
verbs: | ||
- 'create' | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: integration-rolebind | ||
subjects: | ||
- kind: ServiceAccount | ||
name: integration-svc | ||
roleRef: | ||
kind: Role | ||
name: integration-role | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: integration-job | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: integration-svc | ||
containers: | ||
- name: tests | ||
image: eu.gcr.io/gitpod-core-dev/build/integration-tests:kyleb-installer-integration.24 | ||
imagePullPolicy: Always | ||
#args: ["-username=sagor999"] | ||
#args: ["-enterprise=true"] | ||
#args: ["-gitlab=true"] | ||
resources: | ||
requests: | ||
cpu: 2 | ||
memory: 4Gi | ||
restartPolicy: Never | ||
backoffLimit: 0 |
Uh oh!
There was an error while loading. Please reload this page.