InfoGrab DocsInfoGrab Docs

실행 컨텍스트 선택

요약

일부 테스트는 특정 환경이나 특정 파이프라인 또는 job에서 실행되도록 설계됩니다. :production과 { <switch>: 'value' }를 동시에 지정할 수 없습니다. 지정한 컨텍스트에서만 테스트를 실행합니다.

일부 테스트는 특정 환경이나 특정 파이프라인 또는 job에서 실행되도록 설계됩니다. only와 except 메타데이터로 테스트 실행 컨텍스트를 지정할 수 있습니다.

사용 가능한 스위치#

스위치 기능 타입
tld 최상위 도메인 매처 설정 String
subdomain 서브도메인 매처 설정 Array 또는 String
domain 도메인 매처 설정 String
production 프로덕션 환경 매칭 Static
pipeline 파이프라인 매칭 Array 또는 Static
job job 매칭 Array 또는 Static
Warning

:production과 { <switch>: 'value' }를 동시에 지정할 수 없습니다. 두 옵션은 상호 배타적입니다. 프로덕션을 지정하려면 tld와 domain을 각각 제어할 수 있습니다.

예시#

Only#

지정한 컨텍스트에서만 테스트를 실행합니다.

매칭 방식은 다음과 같습니다.

  • 환경에는 정규식을 사용합니다.
  • 파이프라인에는 문자열 매칭을 사용합니다.
  • job에는 정규식 또는 문자열 매칭을 사용합니다
  • 일반 조건에는 람다 또는 참·거짓 값을 사용합니다
테스트 실행 컨텍스트 키 매칭
gitlab.com only: :production gitlab.com
staging.gitlab.com only: { subdomain: :staging } (staging).+.com
gitlab.com 및 staging.gitlab.com only: { subdomain: /(staging.)?/, domain: 'gitlab' } (staging.)?gitlab.com
dev.gitlab.org only: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } (dev).gitlab.org
staging.gitlab.com 및 domain.gitlab.com only: { subdomain: %i[staging domain] } (staging|domain).+.com
nightly 파이프라인 only: { pipeline: :nightly } "nightly scheduled pipeline"
nightly 및 canary 파이프라인 only: { pipeline: [:nightly, :canary] } "nightly scheduled pipeline" 및 "canary"
ee:instance job only: { job: 'ee:instance' } 모든 파이프라인의 ee:instance job
모든 quarantine job only: { job: '.*quarantine' } 모든 파이프라인에서 quarantine으로 끝나는 job
로컬 개발 환경 only: :local Runtime::Env.running_in_ci?가 false 인 모든 환경
조건이 참으로 평가되는 모든 실행 only: { condition: -> { ENV['TEST_ENV'] == 'true' } } TEST_ENV가 true로 설정된 모든 실행
RSpec.describe 'Area' do
  it 'runs in any environment or pipeline' do; end
  it 'runs only in production environment', only: :production do; end

  it 'runs only in staging environment', only: { subdomain: :staging } do; end

  it 'runs in dev environment', only: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } do; end

  it 'runs in prod and staging environments', only: { subdomain: /(staging.)?/, domain: 'gitlab' } {}

  it 'runs only in nightly pipeline', only: { pipeline: :nightly } do; end

  it 'runs in nightly and canary pipelines', only: { pipeline: [:nightly, :canary] } do; end

  it 'runs in specific environment matching condition', only: { condition: -> { ENV['TEST_ENV'] == 'true' } } do; end
end

Except#

지정한 컨텍스트를 제외한 일반적인 컨텍스트에서 테스트를 실행합니다.

매칭 방식은 다음과 같습니다.

  • 환경에는 정규식을 사용합니다.
  • 파이프라인에는 문자열 매칭을 사용합니다.
  • job에는 정규식 또는 문자열 매칭을 사용합니다
  • 일반 조건에는 람다 또는 참·거짓 값을 사용합니다
테스트 실행 컨텍스트 키 매칭
gitlab.com except: :production gitlab.com
staging.gitlab.com except: { subdomain: :staging } (staging).+.com
gitlab.com 및 staging.gitlab.com except: { subdomain: /(staging.)?/, domain: 'gitlab' } (staging.)?gitlab.com
dev.gitlab.org except: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } (dev).gitlab.org
staging.gitlab.com 및 domain.gitlab.com except: { subdomain: %i[staging domain] } (staging|domain).+.com
nightly 파이프라인 only: { pipeline: :nightly } "nightly scheduled pipeline"
nightly 및 canary 파이프라인 only: { pipeline: [:nightly, :canary] } "nightly scheduled pipeline" 및 "canary"
ee:instance job except: { job: 'ee:instance' } 모든 파이프라인의 ee:instance job
모든 quarantine job except: { job: '.*quarantine' } 모든 파이프라인에서 quarantine으로 끝나는 job
조건이 참으로 평가되는 경우를 제외한 모든 실행 except: { condition: -> { ENV['TEST_ENV'] == 'true' } } TEST_ENV가 true로 설정되지 않은 모든 실행
RSpec.describe 'Area' do
  it 'runs in any execution context except the production environment', except: :production do; end

  it 'runs in any execution context except the staging environment', except: { subdomain: :staging } do; end

  it 'runs in any execution context except the nightly pipeline', except: { pipeline: :nightly } do; end

  it 'runs in any execution context except the ee:instance job', except: { job: 'ee:instance' } do; end

  it 'runs in specific environment not matching condition', except: { condition: -> { ENV['TEST_ENV'] == 'true' } } do; end
end

사용 시 주의사항#

테스트에 before 또는 after 블록이 있다면 바깥쪽 RSpec.describe 블록에 only 또는 except 메타데이터를 추가해야 합니다.

로컬 GitLab 인스턴스에서 only 태그가 붙은 테스트를 실행하려면 다음 중 하나를 수행합니다.

  • CI_PROJECT_NAME 이나 CI_JOB_NAME 환경 변수가 설정되어 있지 않은지 확인합니다.
  • 메타데이터에 맞는 변수를 설정합니다. 예를 들어 메타데이터가 only: { pipeline: :nightly } 라면 CI_PROJECT_NAME=nightly를 설정합니다. 메타데이터가 only: { job: 'ee:instance' } 라면 CI_JOB_NAME=ee:instance를 설정합니다.
  • 메타데이터를 일시적으로 제거합니다.

로컬에서 except 태그가 붙은 테스트를 실행하려면 다음 중 하나를 수행합니다.

  • CI_PROJECT_NAME 이나 CI_JOB_NAME 환경 변수가 설정되어 있지 않은지 확인합니다.
  • 메타데이터를 일시적으로 제거합니다.

특정 환경에 대한 테스트 격리#

테스트를 특정 환경에서만 실행하도록 지정하는 것과 마찬가지로, 특정 환경에서 실행될 때만 테스트를 격리할 수도 있습니다. 구문은 완전히 동일하며, only: { ... } 해시가 quarantine: { ... } 해시 안에 중첩된다는 점만 다릅니다. 예를 들어 quarantine: { only: { subdomain: :staging } }는 staging을 대상으로 실행할 때만 테스트를 격리합니다.

격리 기능은 GLCI_DISABLE_QUARANTINE 환경 변수로 명시적으로 비활성화할 수 있습니다. 로컬에서 테스트를 실행할 때 유용합니다.

실행 컨텍스트 선택

GitLab v19.4
원문 보기

요약

일부 테스트는 특정 환경이나 특정 파이프라인 또는 job에서 실행되도록 설계됩니다. :production과 { &#x3C;switch>: 'value' }를 동시에 지정할 수 없습니다. 지정한 컨텍스트에서만 테스트를 실행합니다.

일부 테스트는 특정 환경이나 특정 파이프라인 또는 job에서 실행되도록 설계됩니다. only와 except 메타데이터로 테스트 실행 컨텍스트를 지정할 수 있습니다.

사용 가능한 스위치#

스위치 기능 타입
tld 최상위 도메인 매처 설정 String
subdomain 서브도메인 매처 설정 Array 또는 String
domain 도메인 매처 설정 String
production 프로덕션 환경 매칭 Static
pipeline 파이프라인 매칭 Array 또는 Static
job job 매칭 Array 또는 Static
Warning

:production과 { <switch>: 'value' }를 동시에 지정할 수 없습니다. 두 옵션은 상호 배타적입니다. 프로덕션을 지정하려면 tld와 domain을 각각 제어할 수 있습니다.

예시#

Only#

지정한 컨텍스트에서만 테스트를 실행합니다.

매칭 방식은 다음과 같습니다.

  • 환경에는 정규식을 사용합니다.
  • 파이프라인에는 문자열 매칭을 사용합니다.
  • job에는 정규식 또는 문자열 매칭을 사용합니다
  • 일반 조건에는 람다 또는 참·거짓 값을 사용합니다
테스트 실행 컨텍스트 키 매칭
gitlab.com only: :production gitlab.com
staging.gitlab.com only: { subdomain: :staging } (staging).+.com
gitlab.com 및 staging.gitlab.com only: { subdomain: /(staging.)?/, domain: 'gitlab' } (staging.)?gitlab.com
dev.gitlab.org only: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } (dev).gitlab.org
staging.gitlab.com 및 domain.gitlab.com only: { subdomain: %i[staging domain] } (staging|domain).+.com
nightly 파이프라인 only: { pipeline: :nightly } "nightly scheduled pipeline"
nightly 및 canary 파이프라인 only: { pipeline: [:nightly, :canary] } "nightly scheduled pipeline" 및 "canary"
ee:instance job only: { job: 'ee:instance' } 모든 파이프라인의 ee:instance job
모든 quarantine job only: { job: '.*quarantine' } 모든 파이프라인에서 quarantine으로 끝나는 job
로컬 개발 환경 only: :local Runtime::Env.running_in_ci?가 false 인 모든 환경
조건이 참으로 평가되는 모든 실행 only: { condition: -> { ENV['TEST_ENV'] == 'true' } } TEST_ENV가 true로 설정된 모든 실행
RSpec.describe 'Area' do
  it 'runs in any environment or pipeline' do; end
  it 'runs only in production environment', only: :production do; end

  it 'runs only in staging environment', only: { subdomain: :staging } do; end

  it 'runs in dev environment', only: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } do; end

  it 'runs in prod and staging environments', only: { subdomain: /(staging.)?/, domain: 'gitlab' } {}

  it 'runs only in nightly pipeline', only: { pipeline: :nightly } do; end

  it 'runs in nightly and canary pipelines', only: { pipeline: [:nightly, :canary] } do; end

  it 'runs in specific environment matching condition', only: { condition: -> { ENV['TEST_ENV'] == 'true' } } do; end
end

Except#

지정한 컨텍스트를 제외한 일반적인 컨텍스트에서 테스트를 실행합니다.

매칭 방식은 다음과 같습니다.

  • 환경에는 정규식을 사용합니다.
  • 파이프라인에는 문자열 매칭을 사용합니다.
  • job에는 정규식 또는 문자열 매칭을 사용합니다
  • 일반 조건에는 람다 또는 참·거짓 값을 사용합니다
테스트 실행 컨텍스트 키 매칭
gitlab.com except: :production gitlab.com
staging.gitlab.com except: { subdomain: :staging } (staging).+.com
gitlab.com 및 staging.gitlab.com except: { subdomain: /(staging.)?/, domain: 'gitlab' } (staging.)?gitlab.com
dev.gitlab.org except: { tld: '.org', domain: 'gitlab', subdomain: 'dev' } (dev).gitlab.org
staging.gitlab.com 및 domain.gitlab.com except: { subdomain: %i[staging domain] } (staging|domain).+.com
nightly 파이프라인 only: { pipeline: :nightly } "nightly scheduled pipeline"
nightly 및 canary 파이프라인 only: { pipeline: [:nightly, :canary] } "nightly scheduled pipeline" 및 "canary"
ee:instance job except: { job: 'ee:instance' } 모든 파이프라인의 ee:instance job
모든 quarantine job except: { job: '.*quarantine' } 모든 파이프라인에서 quarantine으로 끝나는 job
조건이 참으로 평가되는 경우를 제외한 모든 실행 except: { condition: -> { ENV['TEST_ENV'] == 'true' } } TEST_ENV가 true로 설정되지 않은 모든 실행
RSpec.describe 'Area' do
  it 'runs in any execution context except the production environment', except: :production do; end

  it 'runs in any execution context except the staging environment', except: { subdomain: :staging } do; end

  it 'runs in any execution context except the nightly pipeline', except: { pipeline: :nightly } do; end

  it 'runs in any execution context except the ee:instance job', except: { job: 'ee:instance' } do; end

  it 'runs in specific environment not matching condition', except: { condition: -> { ENV['TEST_ENV'] == 'true' } } do; end
end

사용 시 주의사항#

테스트에 before 또는 after 블록이 있다면 바깥쪽 RSpec.describe 블록에 only 또는 except 메타데이터를 추가해야 합니다.

로컬 GitLab 인스턴스에서 only 태그가 붙은 테스트를 실행하려면 다음 중 하나를 수행합니다.

  • CI_PROJECT_NAME 이나 CI_JOB_NAME 환경 변수가 설정되어 있지 않은지 확인합니다.
  • 메타데이터에 맞는 변수를 설정합니다. 예를 들어 메타데이터가 only: { pipeline: :nightly } 라면 CI_PROJECT_NAME=nightly를 설정합니다. 메타데이터가 only: { job: 'ee:instance' } 라면 CI_JOB_NAME=ee:instance를 설정합니다.
  • 메타데이터를 일시적으로 제거합니다.

로컬에서 except 태그가 붙은 테스트를 실행하려면 다음 중 하나를 수행합니다.

  • CI_PROJECT_NAME 이나 CI_JOB_NAME 환경 변수가 설정되어 있지 않은지 확인합니다.
  • 메타데이터를 일시적으로 제거합니다.

특정 환경에 대한 테스트 격리#

테스트를 특정 환경에서만 실행하도록 지정하는 것과 마찬가지로, 특정 환경에서 실행될 때만 테스트를 격리할 수도 있습니다. 구문은 완전히 동일하며, only: { ... } 해시가 quarantine: { ... } 해시 안에 중첩된다는 점만 다릅니다. 예를 들어 quarantine: { only: { subdomain: :staging } }는 staging을 대상으로 실행할 때만 테스트를 격리합니다.

격리 기능은 GLCI_DISABLE_QUARANTINE 환경 변수로 명시적으로 비활성화할 수 있습니다. 로컬에서 테스트를 실행할 때 유용합니다.