InfoGrab Docs

테스트 격리

요약

이 페이지는 GitLab에서 테스트 격리를 구현하기 위한 기술 참조를 제공합니다. 테스트를 격리한다는 것은 코드베이스에서 보존하면서 향후 수정을 위해 CI에서 건너뛰도록 표시한다는 것을 의미합니다. 테스트 실패 이슈의 URL과 함께 quarantine 메타데이터를 사용하십시오:

이 페이지는 GitLab에서 테스트 격리를 구현하기 위한 기술 참조를 제공합니다. 격리 시기, 소유권 및 타임라인에 대한 프로세스 정보는 테스트 격리 프로세스 핸드북 페이지를 참조하십시오.

테스트 격리란 무엇인가?#

테스트를 격리한다는 것은 코드베이스에서 보존하면서 향후 수정을 위해 CI에서 건너뛰도록 표시한다는 것을 의미합니다. 격리된 테스트는 기본적으로 로컬에서 실행되지만 다른 개발자가 차단되는 것을 방지하기 위해 CI 파이프라인에서 제외됩니다.

RSpec 격리#

기본 구문#

테스트 실패 이슈의 URL과 함께 quarantine 메타데이터를 사용하십시오:

# 단일 사양 격리
it 'succeeds', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  expect(response).to have_gitlab_http_status(:ok)
end

# describe/context 블록 격리
describe '#flaky-method', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  [...]
end

격리 메타데이터 유형#

격리 유형을 지정하여 이유를 분류하십시오:

it 'is flaky', quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :flaky
}

it 'is due to a bug', quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :bug
}

context 'when these tests rely on another MR', quarantine: {
  type: :waiting_on,
  issue: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/12345'
}

사용 가능한 격리 유형:

유형 설명
:flaky 테스트가 간헐적으로 실패
:bug 애플리케이션 버그로 인해 테스트 실패
:stale 기능 변경으로 인해 테스트가 오래됨
:broken 테스트 코드 또는 프레임워크 변경으로 인해 테스트 실패
:waiting_on 테스트가 다른 이슈 또는 MR에 의존
:investigating 조사 중인 불안정한 테스트
:test_environment 환경 문제로 인해 테스트 실패
:dependency 외부 종속성으로 인해 테스트 실패

중첩된 컨텍스트#

관련 태그가 있는 가장 바깥쪽 describe 또는 context 블록에 격리를 적용하십시오:

# 좋은 예
RSpec.describe 'Plan', :smoke, quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :flaky
} do
  describe 'Feature' do
    before(:context) do
      # 이 before(:context) 블록은 smoke 격리 작업에서만 실행됩니다
    end
  end
end

# 나쁜 예
RSpec.describe 'Plan', :smoke do
  describe 'Feature', quarantine: {
    issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
    type: :flaky
  } do
    before(:context) do
      # 이 before(:context) 블록은 smoke 태그가 없는 격리 작업에서
      # 실수로 실행될 수 있습니다
    end
  end
end

로컬에서 격리된 테스트 실행#

기본적으로 격리된 테스트는 로컬 개발에서 실행됩니다. 건너뛰려면:

# Bash
bin/rspec --tag ~quarantine

# ZSH
bin/rspec --tag \~quarantine

격리된 테스트 찾기#

기능 범주에 대한 모든 격리된 테스트를 찾으려면 ripgrep을 사용하십시오:

rg -l --multiline -w "(?s)feature_category:\s+:global_search.+quarantine:"

기술적 제약#

공유 예시 또는 it_behaves_like/include_examples 호출을 격리할 수 없습니다:

# RuboCop이 경고합니다
shared_examples 'loads all the users when opened', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  [...]
end

# 작동하지 않습니다
it_behaves_like 'a shared example', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345'

# 작동하지 않습니다
include_examples 'a shared example', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345'

자세한 내용은 다음을 참조하십시오:

전제 조건#

테스트를 격리하기 전에:

  1. 적절한 귀속을 위해 테스트 파일에 feature_category 메타데이터가 있는지 확인
  2. 테스트 실패 이슈 프로젝트에서 테스트 실패 이슈를 생성하거나 식별
  3. 머지 요청에 ~"quarantine" 레이블 추가
  4. 표준 링크 용어를 사용하여 MR을 테스트 실패 이슈에 연결
  5. 이슈에 ~"quarantined test" 레이블 추가

격리 시기와 소유권 책임에 대한 프로세스 정보는 테스트 격리 프로세스 핸드북을 참조하십시오.

빠른 격리#

즉각적인 격리가 필요한 경우 빠른 격리 프로세스를 사용하십시오.

빠른 격리로 실패한 작업 재실행:

  • RSpec 테스트(단위/통합/시스템): retrieve-tests-metadata 작업을 다시 트리거한 다음 실패한 RSpec 작업을 재시도하십시오. 단순히 작업을 재시작하면 새 빠른 격리 업데이트가 적용되지 않습니다.
  • E2E 테스트: 실패한 E2E 작업을 단순히 재시도하십시오 - E2E 테스트는 최신 빠른 격리 파일을 자동으로 다운로드합니다.
  • 대안: 새 파이프라인을 실행하면 모든 테스트 유형에 대한 최신 빠른 격리가 적용됩니다.

빠른 격리 타임라인 및 후속 요구사항에 대한 전체 프로세스 정보는 핸드북의 빠른 격리 섹션을 참조하십시오.

Jest 격리#

기본 구문#

ESLint 비활성화 주석과 함께 .skip 메서드를 사용하십시오:

// quarantine: https://gitlab.com/gitlab-org/gitlab/-/issues/56789
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should throw an error', () => {
  expect(response).toThrowError(expected_error)
});

격리된 테스트 실행#

격리된 Jest 테스트는 --runInBand 옵션으로 실행하지 않는 한 건너뜁니다:

jest --runInBand

격리된 테스트 찾기#

격리된 Jest 사양이 있는 모든 파일을 나열하려면:

yarn jest:quarantine

관련 주제#

테스트 격리

원문 보기
요약

이 페이지는 GitLab에서 테스트 격리를 구현하기 위한 기술 참조를 제공합니다. 테스트를 격리한다는 것은 코드베이스에서 보존하면서 향후 수정을 위해 CI에서 건너뛰도록 표시한다는 것을 의미합니다. 테스트 실패 이슈의 URL과 함께 quarantine 메타데이터를 사용하십시오:

이 페이지는 GitLab에서 테스트 격리를 구현하기 위한 기술 참조를 제공합니다. 격리 시기, 소유권 및 타임라인에 대한 프로세스 정보는 테스트 격리 프로세스 핸드북 페이지를 참조하십시오.

테스트 격리란 무엇인가?#

테스트를 격리한다는 것은 코드베이스에서 보존하면서 향후 수정을 위해 CI에서 건너뛰도록 표시한다는 것을 의미합니다. 격리된 테스트는 기본적으로 로컬에서 실행되지만 다른 개발자가 차단되는 것을 방지하기 위해 CI 파이프라인에서 제외됩니다.

RSpec 격리#

기본 구문#

테스트 실패 이슈의 URL과 함께 quarantine 메타데이터를 사용하십시오:

# 단일 사양 격리
it 'succeeds', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  expect(response).to have_gitlab_http_status(:ok)
end

# describe/context 블록 격리
describe '#flaky-method', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  [...]
end

격리 메타데이터 유형#

격리 유형을 지정하여 이유를 분류하십시오:

it 'is flaky', quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :flaky
}

it 'is due to a bug', quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :bug
}

context 'when these tests rely on another MR', quarantine: {
  type: :waiting_on,
  issue: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/12345'
}

사용 가능한 격리 유형:

유형 설명
:flaky 테스트가 간헐적으로 실패
:bug 애플리케이션 버그로 인해 테스트 실패
:stale 기능 변경으로 인해 테스트가 오래됨
:broken 테스트 코드 또는 프레임워크 변경으로 인해 테스트 실패
:waiting_on 테스트가 다른 이슈 또는 MR에 의존
:investigating 조사 중인 불안정한 테스트
:test_environment 환경 문제로 인해 테스트 실패
:dependency 외부 종속성으로 인해 테스트 실패

중첩된 컨텍스트#

관련 태그가 있는 가장 바깥쪽 describe 또는 context 블록에 격리를 적용하십시오:

# 좋은 예
RSpec.describe 'Plan', :smoke, quarantine: {
  issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
  type: :flaky
} do
  describe 'Feature' do
    before(:context) do
      # 이 before(:context) 블록은 smoke 격리 작업에서만 실행됩니다
    end
  end
end

# 나쁜 예
RSpec.describe 'Plan', :smoke do
  describe 'Feature', quarantine: {
    issue: 'https://gitlab.com/gitlab-org/quality/test-failure-issues/-/issues/12345',
    type: :flaky
  } do
    before(:context) do
      # 이 before(:context) 블록은 smoke 태그가 없는 격리 작업에서
      # 실수로 실행될 수 있습니다
    end
  end
end

로컬에서 격리된 테스트 실행#

기본적으로 격리된 테스트는 로컬 개발에서 실행됩니다. 건너뛰려면:

# Bash
bin/rspec --tag ~quarantine

# ZSH
bin/rspec --tag \~quarantine

격리된 테스트 찾기#

기능 범주에 대한 모든 격리된 테스트를 찾으려면 ripgrep을 사용하십시오:

rg -l --multiline -w "(?s)feature_category:\s+:global_search.+quarantine:"

기술적 제약#

공유 예시 또는 it_behaves_like/include_examples 호출을 격리할 수 없습니다:

# RuboCop이 경고합니다
shared_examples 'loads all the users when opened', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345' do
  [...]
end

# 작동하지 않습니다
it_behaves_like 'a shared example', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345'

# 작동하지 않습니다
include_examples 'a shared example', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/12345'

자세한 내용은 다음을 참조하십시오:

전제 조건#

테스트를 격리하기 전에:

  1. 적절한 귀속을 위해 테스트 파일에 feature_category 메타데이터가 있는지 확인
  2. 테스트 실패 이슈 프로젝트에서 테스트 실패 이슈를 생성하거나 식별
  3. 머지 요청에 ~"quarantine" 레이블 추가
  4. 표준 링크 용어를 사용하여 MR을 테스트 실패 이슈에 연결
  5. 이슈에 ~"quarantined test" 레이블 추가

격리 시기와 소유권 책임에 대한 프로세스 정보는 테스트 격리 프로세스 핸드북을 참조하십시오.

빠른 격리#

즉각적인 격리가 필요한 경우 빠른 격리 프로세스를 사용하십시오.

빠른 격리로 실패한 작업 재실행:

  • RSpec 테스트(단위/통합/시스템): retrieve-tests-metadata 작업을 다시 트리거한 다음 실패한 RSpec 작업을 재시도하십시오. 단순히 작업을 재시작하면 새 빠른 격리 업데이트가 적용되지 않습니다.
  • E2E 테스트: 실패한 E2E 작업을 단순히 재시도하십시오 - E2E 테스트는 최신 빠른 격리 파일을 자동으로 다운로드합니다.
  • 대안: 새 파이프라인을 실행하면 모든 테스트 유형에 대한 최신 빠른 격리가 적용됩니다.

빠른 격리 타임라인 및 후속 요구사항에 대한 전체 프로세스 정보는 핸드북의 빠른 격리 섹션을 참조하십시오.

Jest 격리#

기본 구문#

ESLint 비활성화 주석과 함께 .skip 메서드를 사용하십시오:

// quarantine: https://gitlab.com/gitlab-org/gitlab/-/issues/56789
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should throw an error', () => {
  expect(response).toThrowError(expected_error)
});

격리된 테스트 실행#

격리된 Jest 테스트는 --runInBand 옵션으로 실행하지 않는 한 건너뜁니다:

jest --runInBand

격리된 테스트 찾기#

격리된 Jest 사양이 있는 모든 파일을 나열하려면:

yarn jest:quarantine

관련 주제#