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

61 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-06-22 21:04 +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 

17 

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

19from buildgrid._protos.buildgrid.v2 import monitoring_pb2 

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

21 

22 

23# RWAPI enumerations 

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

25 

26class BotStatus(Enum): 

27 # Initially unknown state. 

28 UNSPECIFIED = bots_pb2.BotStatus.Value('BOT_STATUS_UNSPECIFIED') 

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

30 OK = bots_pb2.BotStatus.Value('OK') 

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

32 UNHEALTHY = bots_pb2.BotStatus.Value('UNHEALTHY') 

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

34 HOST_REBOOTING = bots_pb2.BotStatus.Value('HOST_REBOOTING') 

35 # The bot has been asked to shut down. 

36 BOT_TERMINATING = bots_pb2.BotStatus.Value('BOT_TERMINATING') 

37 

38 

39class LeaseState(Enum): 

40 # Initially unknown state. 

41 UNSPECIFIED = bots_pb2.LeaseState.Value('LEASE_STATE_UNSPECIFIED') 

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

43 PENDING = bots_pb2.LeaseState.Value('PENDING') 

44 # The bot has accepted this lease. 

45 ACTIVE = bots_pb2.LeaseState.Value('ACTIVE') 

46 # The bot is no longer leased. 

47 COMPLETED = bots_pb2.LeaseState.Value('COMPLETED') 

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

49 CANCELLED = bots_pb2.LeaseState.Value('CANCELLED') 

50 

51 

52# REAPI enumerations 

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

54 

55class OperationStage(Enum): 

56 # Initially unknown stage. 

57 UNKNOWN = remote_execution_pb2.ExecutionStage.Value.Value('UNKNOWN') 

58 # Checking the result against the cache. 

59 CACHE_CHECK = remote_execution_pb2.ExecutionStage.Value.Value('CACHE_CHECK') 

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

61 QUEUED = remote_execution_pb2.ExecutionStage.Value.Value('QUEUED') 

62 # Currently being executed by a worker. 

63 EXECUTING = remote_execution_pb2.ExecutionStage.Value.Value('EXECUTING') 

64 # Finished execution. 

65 COMPLETED = remote_execution_pb2.ExecutionStage.Value.Value('COMPLETED') 

66 

67 

68# Internal enumerations 

69# From buildgrid.v2/monitoring.proto: 

70 

71class LogRecordLevel(Enum): 

72 # Initially unknown level. 

73 NOTSET = monitoring_pb2.LogRecord.Level.Value('NOTSET') 

74 # Debug message severity level. 

75 DEBUG = monitoring_pb2.LogRecord.Level.Value('DEBUG') 

76 # Information message severity level. 

77 INFO = monitoring_pb2.LogRecord.Level.Value('INFO') 

78 # Warning message severity level. 

79 WARNING = monitoring_pb2.LogRecord.Level.Value('WARNING') 

80 # Error message severity level. 

81 ERROR = monitoring_pb2.LogRecord.Level.Value('ERROR') 

82 # Critical message severity level. 

83 CRITICAL = monitoring_pb2.LogRecord.Level.Value('CRITICAL') 

84 

85 

86class MetricRecordType(Enum): 

87 # Initially unknown type. 

88 NONE = monitoring_pb2.MetricRecord.Type.Value('NONE') 

89 # A metric for counting. 

90 COUNTER = monitoring_pb2.MetricRecord.Type.Value('COUNTER') 

91 # A metric for mesuring a duration. 

92 TIMER = monitoring_pb2.MetricRecord.Type.Value('TIMER') 

93 # A metric in arbitrary value. 

94 GAUGE = monitoring_pb2.MetricRecord.Type.Value('GAUGE') 

95 # A metric with distribution semantics 

96 DISTRIBUTION = monitoring_pb2.MetricRecord.Type.Value('DISTRIBUTION') 

97 

98 

99class DataStoreType(Enum): 

100 MEM = "mem" 

101 SQL = "sql" 

102 

103 

104class JobEventType(Enum): 

105 STOP = "stop" 

106 CHANGE = "change" 

107 

108 

109class MetricCategories(Enum): 

110 LEASES = 'leases' 

111 JOBS = 'jobs' 

112 

113 

114class ServiceName(Enum): 

115 EXECUTION = "execution" 

116 OPERATIONS = "operations" 

117 BOTS = "bots" 

118 

119 @classmethod 

120 def default_services(cls): 

121 return ( 

122 cls.EXECUTION.value, 

123 cls.OPERATIONS.value, 

124 cls.BOTS.value 

125 ) 

126 

127 

128class ByteStreamResourceType(Enum): 

129 CAS = 'cas' 

130 LOGSTREAM = 'logstream' 

131 

132 

133class ActionCacheEntryType(Enum): 

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

135 ACTION_RESULT_DIGEST = 0 

136 ACTION_RESULT = 1 

137 

138 

139class ExchangeNames(Enum): 

140 BOT_STATUS = 'bot-status' 

141 OPERATION_UPDATES = 'operation-updates-exchange' 

142 

143 

144class QueueNames(Enum): 

145 OPERATION_UPDATES = 'operation-updates-queue'