1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tradefed.result.error;
17 
18 import com.android.tradefed.result.proto.TestRecordProto.FailureStatus;
19 
20 /** Error Identifiers from Trade Federation infra, and dependent infra (like Build infra). */
21 public enum InfraErrorIdentifier implements ErrorIdentifier {
22 
23     // ********************************************************************************************
24     // Infra: 10_001 ~ 20_000
25     // ********************************************************************************************
26     // 10_001 - 10_500: General errors
27     ARTIFACT_NOT_FOUND(10_001, FailureStatus.INFRA_FAILURE),
28     FAIL_TO_CREATE_FILE(10_002, FailureStatus.INFRA_FAILURE),
29     INVOCATION_CANCELLED(10_003, FailureStatus.CANCELLED),
30     CODE_COVERAGE_ERROR(10_004, FailureStatus.INFRA_FAILURE),
31     MODULE_SETUP_RUNTIME_EXCEPTION(10_005, FailureStatus.UNSET), // TODO: switch to customer_issue
32 
33     // 10_501 - 11_000: Build, Artifacts download related errors
34     ARTIFACT_REMOTE_PATH_NULL(10_501, FailureStatus.INFRA_FAILURE),
35     ARTIFACT_UNSUPPORTED_PATH(10_502, FailureStatus.INFRA_FAILURE),
36     ARTIFACT_DOWNLOAD_ERROR(10_503, FailureStatus.INFRA_FAILURE),
37     GCS_ERROR(10_504, FailureStatus.UNSET), // TODO: switch to dependency_issue
38 
39     // 11_001 - 11_500: environment issues: For example: lab wifi
40     WIFI_FAILED_CONNECT(11_001, FailureStatus.UNSET), // TODO: switch to dependency_issue
41 
42     // 12_000 - 12_100: Test issues detected by infra
43     EXPECTED_TESTS_MISMATCH(12_000, FailureStatus.TEST_FAILURE),
44 
45     UNDETERMINED(20_000, FailureStatus.UNSET);
46 
47     private final long code;
48     private final FailureStatus status;
49 
InfraErrorIdentifier(int code, FailureStatus status)50     InfraErrorIdentifier(int code, FailureStatus status) {
51         this.code = code;
52         this.status = status;
53     }
54 
55     @Override
code()56     public long code() {
57         return code;
58     }
59 
60     @Override
status()61     public FailureStatus status() {
62         return status;
63     }
64 }
65