

# A/B 테스트 관리
<a name="ab-testing-manage"></a>

A/B 테스트를 업데이트하여 시작, 일시 중지 또는 중지합니다. `UpdateABTest` 작업을 사용하여 실행 상태를 변경합니다.

**참고**  
AgentCore CLI 수명 주기 명령(`view`, `pause`, `resume`, `stop`, `promote`, `archive`)은 이름이 `-i, --id`아닌 로 전달된 **작업 ID**로 테스트를 식별합니다. `agentcore run ab-test --json` ( `id` 필드)에서 또는를 사용하여 테스트를 나열하여 ID를 가져옵니다`agentcore view ab-test`. 작업 ID는 형식을 사용합니다`name-suffix`. 예를 들어 `customerSupportTargetTest-Ab1Cd2Ef3G`입니다. 작업 레코드는 프로젝트의에 JSON으로 로컬`.cli/jobs/ab-tests/`로 저장됩니다.

## 코드 샘플
<a name="manage-ab-test-examples"></a>

### 보기, 일시 중지, 재개 및 중지
<a name="manage-ab-test-start-stop"></a>

**Example**  
모든 A/B 테스트 작업을 나열하거나 자세히 봅니다(호출 URL 및 결과도 표시).  

```
agentcore view ab-test
agentcore view ab-test <ab-test-id>
```
일시 중지된 테스트를 재개합니다.  

```
agentcore resume ab-test -i <ab-test-id>
```
실행 중인 테스트를 일시 중지합니다. 트래픽이 분할을 중지하고 모든 요청이 제어 변형으로 라우팅됩니다. 재개할 수 있습니다.  

```
agentcore pause ab-test -i <ab-test-id>
```
테스트를 영구적으로 중지합니다. 모든 트래픽은 제어 변형으로 되돌아갑니다. 실행 취소할 수 없습니다.  

```
agentcore stop ab-test -i <ab-test-id>
```
테스트 시작(실행 상태를 로 설정`RUNNING`):  

```
import boto3
import uuid

client = boto3.client("bedrock-agentcore", region_name="us-west-2")

response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="RUNNING",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```
실행 중인 테스트를 일시 중지합니다.  

```
response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="PAUSED",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```
실행 중인 테스트를 영구적으로 중지합니다.  

```
response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="STOPPED",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```

### 처리 변형 승격
<a name="manage-ab-test-promote"></a>

결과가 통계적으로 유의하면 처리 변형을 승격합니다.는 테스트를 `promote` 중지하고 처리 변형을에 기록한 `agentcore deploy` 다음 나중에 `agentcore.json`실행하여 롤아웃합니다.

**Example**  

```
agentcore promote ab-test -i <ab-test-id>
agentcore deploy
```
SDK에는 단일 "승격" 작업이 없습니다. 테스트를 중지한 다음, 당첨된 변형을 리소스에 직접 적용합니다(예: 제어 구성 번들 또는 게이트웨이 대상을 처리와 일치하도록 업데이트).

### A/B 테스트 삭제
<a name="manage-ab-test-remove"></a>

A/B 테스트 및 관련 메타데이터를 삭제합니다. 테스트를 삭제하려면 먼저 테스트가 `STOPPED` 실행 상태여야 합니다. 테스트를 삭제해도 테스트가 참조한 구성 번들, AgentCore Gateway 또는 온라인 평가 구성에는 영향을 주지 않습니다.

**Example**  

```
agentcore archive ab-test -i <ab-test-id>
```
중지한 다음 삭제합니다.  

```
import boto3
import uuid

client = boto3.client("bedrock-agentcore", region_name="us-west-2")

# First stop the test if it's running
client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="STOPPED",
    clientToken=str(uuid.uuid4()),
)

# Then delete
response = client.delete_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G"
)
print(f"Deleted: {response['abTestId']}")
```

## 실행 상태 전환
<a name="manage-ab-test-execution-states"></a>


| From | 목적 | 설명 | 
| --- | --- | --- | 
|  `NOT_STARTED`  |  `RUNNING`  | 테스트를 시작합니다. AgentCore Gateway가 트래픽 분할을 시작합니다. | 
|  `RUNNING`  |  `PAUSED`  | 테스트를 일시 중지합니다. 트래픽 분할이 중지되고 모든 트래픽 경로가 제어됩니다. | 
|  `PAUSED`  |  `RUNNING`  | 일시 중지된 테스트를 재개합니다. | 
|  `RUNNING`  |  `STOPPED`  | 테스트를 영구적으로 중지합니다. 트래픽 라우팅은 즉시 종료됩니다. | 
|  `PAUSED`  |  `STOPPED`  | 일시 중지된 테스트를 영구적으로 중지합니다. | 