본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

테스트 소유권

원문 보기 위키 갱신

테스트 소유권 (Test ownership)

테스트 소유권(test ownership)은 조직에서 건강한 테스트 문화를 도입하는 데 중요한 요소예요. 하나 이상의 팀을 테스트 소유자로 정의하면 그 팀들이 테스트 스위트 안에서 테스트를 유지·관리하고, 빠르고 안정적으로 만들며, 코드를 배포할 때 확신을 제공하는 책임을 지게 돼요. 이 문서에서 테스트 소유권을 설정하고 관리하는 방법을 알아볼게요.

출처: 문서

본문

테스트 소유권은 팀에 할당할 수 있으며, TESTOWNERS 파일의 팀 할당을 통해 관리돼요.

소유권이 어떻게 할당되나요? (How ownership is assigned)

TESTOWNERS 패턴은 각 테스트의 위치(location) 메타데이터와 일치해요. 이 메타데이터는 테스트 컬렉터, JSON 테스트 업로드, 또는 JUnit 가져오기가 제공해요. 소유권은 파이프라인 YAML에서 구성되지 않으며, location이라는 이름의 태그는 매칭에 사용되지 않아요.

소유권(및 My teams 보기)이 작동하려면:

  1. 모든 업로드 경로가 각 테스트에 대해 위치 메타데이터를 보고하도록 해요. JSON 업로드의 경우 최상위 location 필드를 포함해요. JUnit 리포트의 경우 각 <testcase> 요소에 file 속성과 선택적으로 line 속성을 포함해요. 테스트 컬렉터는 동등한 위치 메타데이터를 제공해요. 나중 업로드가 테스트 기록을 덮어쓰며, 위치 메타데이터가 없는 업로드는 그것을 비워요.
  2. 그 위치 경로와 일치하는 패턴을 가진 TESTOWNERS 파일을 업로드해요.
  3. 소유권 기록이 생성되기 전에 TESTOWNERS에 나열된 팀을 테스트 스위트에 할당해요.

경로만 있는 위치(줄 번호 없음)도 유효해요. 성공적으로 일치한 후 테스트의 상세 페이지를 열어요. 헤더에 위치 경로와 Owners가 보여야 해요. 스위트 Tests 페이지의 My teams는 여러분이 속한 팀이 소유하고 스위트에도 할당된 테스트를 보여줘요.

TESTOWNERS 파일 형식 (TESTOWNERS file format)

TESTOWNERS 파일은 사용자 이름 대신 Buildkite 팀 슬러그를 사용해요. 팀 슬러그는 케밥-케이스(kebab-case)로 된 팀 이름이 될 거예요. 조직 설정에서 팀을 보거나 우리 API에서 가져올 수 있어요.

# Example team name to slug
Pipelines => pipelines
Test Engine => test-engine
📦 Package Registries => package-registries

시작점으로 복사할 수 있는 다음 예시 TESTOWNERS 파일은 이 파일의 구문과 작동 방식을 설명해요.

# This is a comment.
# Only Buildkite teams can be specified as test owners.
# Teams must have explicit access to the suite the test belongs to.
# Each line is a file pattern followed by one or more team slugs.

# The following example teams will be the test owners for all test
# location metadata (that is, test files) from your pipeline builds
# in this repository. While both these example teams own these
# tests, the first team specified in this file pattern is the
# default owner for all test files from your pipeline builds and
# will be notified about issues with their corresponding tests.
# Other teams specified from the second position onwards will also
# be identified as owners and appear in reports about the
# reliability of these tests. However, unlike the default team
# owner, these additional teams will not be notified about test
# issues. Any file pattern matches defined later in this file take
# precedence and override any file patterns defined further up
# this file.
*                     team-slug-1 team-slug-2

# In this example, any test file ending with `_spec.rb` will be
# assigned to the `test-engine` team and not `team-slug-1`.
*_spec.rb             test-engine # This is an inline comment.

# In this example, the `pipelines` team owns all `.rb` test files.
*.rb                  pipelines

# In this example, the `packages` team owns any test files in the
# `spec/packages/` directory at the root of the test location and
# in any of its subdirectories.
/spec/packages/       packages

# In this example, the `spec/features/*` pattern matches test files
# like `spec/features/application_spec.rb`, but not any test files
# nested in any subdirectories of `spec/features`, such as
# `spec/features/pipelines/application_spec.rb`.
spec/features/*       test-engine

# In this example, the `pipelines` team owns any test file in any
# `pipelines` directory, anywhere within the test location.
pipelines/            pipelines

# In this example, the `test-engine` team owns any test files
# within an `/test-engine` directory such as `/models/test-engine`,
# `/features/test-engine`, and `/models/organizations/test-engine`.
# Any test files directly within the `/test-engine` directory itself
# will also belong to the `test-engine` team.
**/test-engine        test-engine

# In this example, the `pipelines` team owns any test files in the
# `/spec` directory at the root of the test location. However, the
# test files contained within the `/spec/models/packages`
# subdirectory, are owned by the `packages` team.
/spec/                pipelines
/spec/models/packages packages

{: codeblock-file="TESTOWNERS"}

권한 요구 사항 (Permission requirements)

TESTOWNERS 파일에 나열된 팀은 소유권 기록이 생성되기 전에 테스트 스위트에 접근할 권한이 있어야 해요.

테스트 소유권 설정하기 (Setting test ownership)

이 API 엔드포인트를 사용해서 TESTOWNERS 파일을 업로드할 수 있어요.

curl --location 'https://analytics-api.buildkite.com/v1/test-ownerships' \
     --header "Authorization: Bearer <your-...ken>" \
     -F 'file=@<your-TESTOWNERS-file-location>'

같은 TESTOWNERS 파일을 여러 테스트 스위트에 업로드할 수 있어요. 하지만 테스트 스위트는 활성 TESTOWNERS 파일을 하나만 가질 수 있어요.

변경된 TESTOWNERS 파일을 업로드하면 이미 location이 있는 스위트의 최근 테스트에 대해 소유권 매칭이 다시 실행돼요. 동일한 파일 내용은 건너뛰어져요. location이 없는 테스트는 여전히 소유자를 받지 못해요.

📘 변경 사항이 감지되면 TESTOWNERS 파일을 자동으로 업로드하는 새 파이프라인을 만들 수도 있어요.

테스트 소유권 보기 (Viewing test ownership)

Test Suite > Settings > Test ownership 페이지에서 테스트 스위트의 현재 테스트 소유권 규칙을 볼 수 있어요.

Suite settings page showing test ownership

소유권이 특정 테스트에 적용됐는지 확인하려면 그 테스트의 상세 페이지를 열고 테스트 이름 아래에 위치 경로와 Owners가 있는지 확인해요. 스위트 Tests 페이지의 My teams 프리셋은 여러분의 팀이 소유한 테스트(스위트에 할당된 팀과의 교집합)로 필터링해요.

문제 해결 (Troubleshooting)

위치 누락 또는 My teams 비어 있음 (Location missing or My teams empty)

위치 경로가 테스트 상세 페이지에 나타나지 않으면 TESTOWNERS는 소유자를 할당할 수 없어요(모든 것을 잡는 * 규칙이 있어도요). 그리고 해당 테스트에 대해 My teams은 비어 있게 돼요.

흔한 원인:

  • location이 최상위 테스트 필드가 아니라 실행 태그로만 보내졌어요.
  • 한 업로드 경로는 location을 포함하지만, 같은 테스트의 나중 CI 업로드가 그것을 생략하고 필드를 비워요.
  • TESTOWNERS의 팀이 아직 스위트에 할당되지 않았어요.

TESTOWNERS 구문 (TESTOWNERS syntax)

TESTOWNERS 파일은 .gitignore 또는 CODEOWNERS 파일과 같은 규칙을 따르며, 파일 경로에 대응하는 팀이 없어도 되는 .gitignore 규칙은 예외예요.

# In a regular `.gitignore` or `CODEOWNER` file, the following
# block would set the `test-engine` team as the owner of any
# file in the `/specs` directory at the root of your test location
# except for the `/specs/features` subdirectory, as its owners are
# left empty.

# This functionality is not supported in a Buildkite `TESTOWNERS`
# file, where `/spec/features` would be also be owned by the
# `test-engine` team.

/specs/         test-engine
/specs/features

더 알아보기 (Learn more)