Coverage for /builds/BuildGrid/buildgrid/buildgrid/_enums.py: 100.00%

62 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-06-11 15:37 +0000

1# Copyright (C) 2018 Bloomberg LP 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# <http://www.apache.org/licenses/LICENSE-2.0> 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15 

16from enum import Enum 

17from typing import Tuple 

18 

19from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 

20from buildgrid._protos.buildgrid.v2 import monitoring_pb2 

21from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2 

22 

23# RWAPI enumerations 

24# From google/devtools/remoteworkers/v1test2/bots.proto: 

25 

26 

27class BotStatus(Enum): 

28 # Initially unknown state. 

29 UNSPECIFIED = bots_pb2.BotStatus.Value("BOT_STATUS_UNSPECIFIED") 

30 # The bot is healthy, and will accept leases as normal. 

31 OK = bots_pb2.BotStatus.Value("OK") 

32 # The bot is unhealthy and will not accept new leases. 

33 UNHEALTHY = bots_pb2.BotStatus.Value("UNHEALTHY") 

34 # The bot has been asked to reboot the host. 

35 HOST_REBOOTING = bots_pb2.BotStatus.Value("HOST_REBOOTING") 

36 # The bot has been asked to shut down. 

37 BOT_TERMINATING = bots_pb2.BotStatus.Value("BOT_TERMINATING") 

38 

39 

40class LeaseState(Enum): 

41 # Initially unknown state. 

42 UNSPECIFIED = bots_pb2.LeaseState.Value("LEASE_STATE_UNSPECIFIED") 

43 # The server expects the bot to accept this lease. 

44 PENDING = bots_pb2.LeaseState.Value("PENDING") 

45 # The bot has accepted this lease. 

46 ACTIVE = bots_pb2.LeaseState.Value("ACTIVE") 

47 # The bot is no longer leased. 

48 COMPLETED = bots_pb2.LeaseState.Value("COMPLETED") 

49 # The bot should immediately release all resources associated with the lease. 

50 CANCELLED = bots_pb2.LeaseState.Value("CANCELLED") 

51 

52 

53# REAPI enumerations 

54# From build/bazel/remote/execution/v2/remote_execution.proto: 

55 

56 

57class OperationStage(Enum): 

58 # Initially unknown stage. 

59 UNKNOWN = remote_execution_pb2.ExecutionStage.Value.Value("UNKNOWN") 

60 # Checking the result against the cache. 

61 CACHE_CHECK = remote_execution_pb2.ExecutionStage.Value.Value("CACHE_CHECK") 

62 # Currently idle, awaiting a free machine to execute. 

63 QUEUED = remote_execution_pb2.ExecutionStage.Value.Value("QUEUED") 

64 # Currently being executed by a worker. 

65 EXECUTING = remote_execution_pb2.ExecutionStage.Value.Value("EXECUTING") 

66 # Finished execution. 

67 COMPLETED = remote_execution_pb2.ExecutionStage.Value.Value("COMPLETED") 

68 

69 

70# Internal enumerations 

71# From buildgrid.v2/monitoring.proto: 

72 

73 

74class LogRecordLevel(Enum): 

75 # Initially unknown level. 

76 NOTSET = monitoring_pb2.LogRecord.Level.Value("NOTSET") 

77 # Debug message severity level. 

78 DEBUG = monitoring_pb2.LogRecord.Level.Value("DEBUG") 

79 # Information message severity level. 

80 INFO = monitoring_pb2.LogRecord.Level.Value("INFO") 

81 # Warning message severity level. 

82 WARNING = monitoring_pb2.LogRecord.Level.Value("WARNING") 

83 # Error message severity level. 

84 ERROR = monitoring_pb2.LogRecord.Level.Value("ERROR") 

85 # Critical message severity level. 

86 CRITICAL = monitoring_pb2.LogRecord.Level.Value("CRITICAL") 

87 

88 

89class MetricRecordType(Enum): 

90 # Initially unknown type. 

91 NONE = monitoring_pb2.MetricRecord.Type.Value("NONE") 

92 # A metric for counting. 

93 COUNTER = monitoring_pb2.MetricRecord.Type.Value("COUNTER") 

94 # A metric for mesuring a duration. 

95 TIMER = monitoring_pb2.MetricRecord.Type.Value("TIMER") 

96 # A metric in arbitrary value. 

97 GAUGE = monitoring_pb2.MetricRecord.Type.Value("GAUGE") 

98 # A metric with distribution semantics 

99 DISTRIBUTION = monitoring_pb2.MetricRecord.Type.Value("DISTRIBUTION") 

100 

101 

102class DataStoreType(Enum): 

103 MEM = "mem" 

104 SQL = "sql" 

105 

106 

107class JobEventType(Enum): 

108 STOP = "stop" 

109 CHANGE = "change" 

110 

111 

112class MetricCategories(Enum): 

113 LEASES = "leases" 

114 JOBS = "jobs" 

115 

116 

117class ServiceName(Enum): 

118 EXECUTION = "execution" 

119 OPERATIONS = "operations" 

120 BOTS = "bots" 

121 

122 @classmethod 

123 def default_services(cls) -> Tuple[str, str, str]: 

124 return (cls.EXECUTION.value, cls.OPERATIONS.value, cls.BOTS.value) 

125 

126 

127class ByteStreamResourceType(Enum): 

128 CAS = "cas" 

129 

130 

131class ActionCacheEntryType(Enum): 

132 """Type of the value stored in an Action Cache entry.""" 

133 

134 ACTION_RESULT_DIGEST = 0 

135 ACTION_RESULT = 1 

136 

137 

138class ExchangeNames(Enum): 

139 BOT_STATUS = "bot-status" 

140 OPERATION_UPDATES = "operation-updates-exchange" 

141 

142 

143class QueueNames(Enum): 

144 OPERATION_UPDATES = "operation-updates-queue"