[go: up one dir, main page]

Skip to content

Create an integration test job to test the cli against a running Gitlab instance

Currently the glab cli is tested using unit tests and mocking the GitLab API. This is good for fast feedback and reliable tests but it would be nice to be able to run the cli commands against an instance of GitLab to give a true indication of whether commands are working correctly.

Go build tags could be used to seperate these tests: https://mickey.dev/posts/go-build-tags-testing/

Ideally these tests are non-exhaustive to reduce maintenance overhead. The tests should be able to be configured to point to different instances of GitLab, this will allow us to check compatibility with previous versions.

Context: #1158 (comment 1210769380)

Pre-requisites to running tests against GDK

Command to run tests: GITLAB_TOKEN=XXX API_PROTOCOL=http GITLAB_HOST=http://192.168.4.31:3000 make test

Alternatively GDK needs to be set-up with https, see https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/nginx.md

  1. Had to disable OP plugin

  2. Config entry:

    192.168.4.31:
        token: glpat-XXX
        api_host: "192.168.4.31:3000"
        git_protocol: ssh
        api_protocol: http
        user: root
        host: "192.168.4.31:3000"
  1. ENV variables API_HOST=192.168.4.31:3000;API_PROTOCOL=http;GITLAB_API_HOST=192.168.4.31:3000;GITLAB_HOST=http://192.168.4.31:3000;GITLAB_TOKEN=XXXX;GITLAB_URI=http://192.168.4.31:3000;NO_COLOR=true

  2. Create public group: cli-automated-testing (manually as there is no glab command - potentially could use api or glab-api)

  3. git clone git@gitlab.com:cli-automated-testing/test.git

  4. cd test

  5. GITLAB_HOST=192.168.4.31 NO_PROMPT=true glab repo create test --group cli-automated-testing --defaultBranch master --public

git remote add origin ssh://git@192.168.4.31:2222/cli-automated-testing/test.git
git push -u origin --all
git push -u origin --tags
  1. glab issue create -t test -d test
  2. Create user called testuser
  3. Run a pipeline (to get data to test against)
  4. Change hardcoded job number to a job number that exists in the application under test

For additional tests:

  1. Create an MR
Edited by Jay McCure
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information