Skip to content

Add Seat Assignment to Code Suggestions Setup

What does this MR do and why?

This MR updates code_suggestions_setup.rb to include assigning a Duo Pro seat to the admin user to prepare for the seat requirement changes that will occur on the service start date on 2024-02-15

This change is meant to be compatible both before and after the service start date, with the goal of having this available before the service start date to help minimize disruptions in E2E test coverage.

This is the first in a series of MRs related to https://gitlab.com/groups/gitlab-org/quality/quality-engineering/-/epics/53+. To see a list of other upcoming changes, please refer to the implementation plan.

Required Feature Flags

CustomersDot

GitLab

How to set up and validate locally

Service Start Date in the Past

This is meant to simulate how the test will run after 2024-02-15

Test steps

Service Start Date in the Past

  1. Ensure you have the following feature flags enabled for your GDK (these are already default enabled on master):
    • code_suggestions_tokens_api
    • self_managed_code_suggestions
  2. Remove any previous licenses from your GDK, and delete any previously assigned add-on seats from the admin user
  3. Include the following in your gdk.yml file:
license:
  customer_portal_url: https://customers.staging.gitlab.com
  license_mode: test
  1. Generate a Docker container for the AI gateway with the following, replacing your GDK url and port where necessary:
docker run --hostname ai-gateway --publish 5000:5000 --name ai-gateway --env AIGW_GITLAB_URL=<your GDK url and port> --env AIGW_GITLAB_API_URL='<your GDK url and port>/api/v4' --env AIGW_CUSTOMER_PORTAL_URL='https://customers.staging.gitlab.com' --env AIGW_USE_FAKE_MODELS='true' --network test registry.gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/model-gateway:latest
  1. In GDK, in gitlab/ee/lib/code_suggestions/self_managed.rb, update the SERVICE_START_DATE to be a date in the past
  2. In gitlab-qa, copy over the contents from code_suggestions_setup.rb, and add it as a new file to your GDK gitlab directory
  3. In GDK, export the following env vars
QA_EE_ACTIVATION_TOKEN=<value for Staging generated activation code in 1Password>
QA_GITLAB_URL=<your gdk url and port>
GITLAB_INITIAL_ROOT_PASSWORD=<your gdk root password>
GITLAB_QA_ADMIN_ACCESS_TOKEN=<api access token for the gdk admin>
AI_GATEWAY_URL=http://localhost:5000
  1. In gdk gitlab/qa directory, in qa/specs/features/ee/api/3_create/code_suggestions_spec.rb, remove the :orchestrated and :ai_gateway tags from the on Self-managed context
  2. Run gdk start or gdk restart, if already running
  3. In your GDK gitlab directory, run the code_suggestions_setup script:
bundle exec rails runner ./code_suggestions_setup.rb
  1. Once the script is complete, in your GDK gitlab/qa directory, run the following test:
bundle exec rspec qa/specs/features/ee/api/3_create/code_suggestions_spec.rb:80
  1. Verify the test passes
  2. You can also comment out the assign_code_suggestions_seat_to_admin method in code_suggestions_setup.rb's configure! method, remove the previous license and seat assignments from your GDK, and try running the script and test again. This time, the test should fail, since the seat has not been assigned in the script.

Service Start Date in the Future

These are just steps for how the current orchestrated tests would run today locally, with the new code suggestions setup script update

Test Steps
  1. Check out this branch locally
  2. Export the following env vars in gitlab-qa:
export GITLAB_LICENSE_MODE=test
export QA_EE_ACTIVATION_CODE=<value from 1Password>
export GITLAB_QA_ADMIN_ACCESS_TOKEN=<value from https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/support/data/admin_access_token_seed.rb#L7>
export QA_SKIP_PULL=true
  1. Pull the gitlab-ee Docker image from omnibus-gitlab-mirror from one of the latest master ai-gateway jobs, such as this one
docker pull registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:25a5c6e885229d6c96f5091dcfe198cb75729f4b
  1. In your gdk/gitlab, run the following (similar to step 7 in these docs)
docker build -t registry.gitlab.com/gitlab-org/gitlab/gitlab-ee-qa:your-custom-tag --file ./qa/Dockerfile ./
  1. Then, tag the build from the gitlab-ee image taken from step 3 with your custom tag
docker tag registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:25a5c6e885229d6c96f5091dcfe198cb75729f4b registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:your-custom-tag
  1. In gitlab-qa, run the following:
exe/gitlab-qa Test::Integration::AiGateway registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:your-custom-tag

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Valerie Burton

Merge request reports