test: run the integration suite on an unlicensed instance
What does this MR do?
make test-integration against the instance that make testacc-up starts by default panics at the first test that calls SkipIfNotLicensed, and the panic ends the whole gitlab_test binary. The Makefile's default service is gitlab-ee-no-license, and an instance with no license answers GET /license with 200 and null (ee/lib/api/license.rb#L22-L26), so GetLicense returns a nil *License and no error, and HasPremiumOrUltimateLicense reads license.Plan from it (gitlab_test/utils_test.go#L71-L80). CI starts the licensed gitlab-ee service, where the license is never nil, so it does not show there.
This MR treats a nil license as no license, the way the helper already treats an error. With that, the suite runs to the end on an unlicensed instance, and four tests then fail because they set a Premium setting and assert that it was saved, which GitLab ignores without a license:
Test_GroupsUpdateGroup_MergeSettings_Integration, and theonly_allow_merge_if_pipeline_succeeds,allow_merge_on_skipped_pipelineandonly_allow_merge_if_all_discussions_are_resolvedsubtests ofTest_GroupsUpdateGroup_AllFields_Integration: the group-level merge checks, which the update drops withoutgroup_level_merge_checks_setting(ee/lib/ee/api/groups.rb#L114-L118).- The
prevent_forking_outside_groupsubtest: forking protection, which needsgroup_forking_protection(ee/app/policies/ee/group_policy.rb#L483). TestCreateProjectWithMergeRequestTitleRegex_IntegrationandTestEditMergeRequestTitleRegex_Integration: the merge request title regex, which needsmerge_request_title_regex_check(ee/lib/ee/api/helpers/projects_helpers.rb#L166-L168).
All three features are Premium features (features.rb). The three tests now call SkipIfNotLicensed, and the four group settings join skipPremium in Test_GroupsUpdateGroup_AllFields_Integration, next to ip_restriction_ranges and file_template_project_id. On a licensed instance nothing changes.
It comes from maintaining gitlab-mcp-server, an MCP server built on this library, while running this suite locally.
How this relates to other open MRs
!3066 (mine) adds SkipIfNotUltimate next to this helper, and it already treats a nil license as none. !3063 (closed) (mine) adds SkipIfVersionBelow below it. git merge-tree merges gitlab_test/utils_test.go of each with this branch without a conflict.
Is this a breaking change?
No. Only test code under gitlab_test/ changes, behind the integration build tag.
How was this tested?
Against gitlab/gitlab-ee:19.5.0-ee.0 started from this repository's docker-compose.yml as the gitlab-ee-no-license service, with the import_sources setting scripts/await_healthy.sh applies, running go test ./gitlab_test/... -race -tags=integration -v as make test-integration does, on Go 1.27.2:
- On
main(ea8d5daf),Test_GroupsListSAMLUsers_Integrationalone panics inHasPremiumOrUltimateLicense, and the whole suite stops with the same panic at thefile_template_project_idsubtest ofTest_GroupsUpdateGroup_AllFields_Integration. - On this branch, on a fresh instance, the whole suite passes: 116 tests and subtests passed, 16 were skipped, none failed.
go vet ./...andgo vet -tags=integration ./gitlab_test/...are clean,golangci-lint run2.14.0 as the CI job runs it reports 0 issues, with--build-tags integrationit reports nothing in the changed files that it does not report onmain,gofumpt -l(0.8.0) lists nothing, andgo test work -racepasses.
Running the suite a second time against the same instance still fails Test_GroupsCreateGroup_CodeOwnerApprovalRequired_Integration, which creates a group with a fixed path and does not delete it, so the second run is refused with path has already been taken. That has nothing to do with the license, so I left it out of this MR.
Test output
On main (ea8d5daf):
=== RUN Test_GroupsListSAMLUsers_Integration
--- FAIL: Test_GroupsListSAMLUsers_Integration (0.14s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
gitlab.com/gitlab-org/api/client-go/v3/gitlab_test_test.HasPremiumOrUltimateLicense(0xc0001e8908, 0xc000178c08)
/src/gitlab_test/utils_test.go:79 +0xf7
gitlab.com/gitlab-org/api/client-go/v3/gitlab_test_test.SkipIfNotLicensed(0xc0001e8908, 0xc000178c08)
/src/gitlab_test/utils_test.go:50 +0x45
FAIL gitlab.com/gitlab-org/api/client-go/v3/gitlab_test 0.180sOn this branch, the same test, the tests this MR gates, and the summary:
--- SKIP: Test_GroupsUpdateGroup_MergeSettings_Integration (0.05s)
--- SKIP: Test_GroupsUpdateGroup_AllFields_Integration/prevent_forking_outside_group (0.00s)
--- SKIP: Test_GroupsUpdateGroup_AllFields_Integration/only_allow_merge_if_pipeline_succeeds (0.00s)
--- SKIP: Test_GroupsUpdateGroup_AllFields_Integration/allow_merge_on_skipped_pipeline (0.00s)
--- SKIP: Test_GroupsUpdateGroup_AllFields_Integration/only_allow_merge_if_all_discussions_are_resolved (0.00s)
--- SKIP: Test_GroupsListSAMLUsers_Integration (0.00s)
--- SKIP: TestEditMergeRequestTitleRegex_Integration (0.00s)
--- SKIP: TestCreateProjectWithMergeRequestTitleRegex_Integration (0.00s)
ok gitlab.com/gitlab-org/api/client-go/v3/gitlab_test 70.030s