def test_parse_fqan(self): self.assertEqual((None, None, 'role=2'), parse_fqan('role=2')) self.assertEqual(('role=some', '/Test', 'Test'), parse_fqan('/Test/role=some/test')) wrong_fqan1 = "hello." wrong_fqan2 = "the/the/the" right_fqan1 = "/atlas/role=doer" right_fqan2 = "/atlas/somethingelse/role=doer" right_fqan3 = "/atlas/Role=production/Capability=NULL;/atlas/Role=NULL/Capability=NULL;/atlas/alarm/Role=NULL/Capability=NULL;/atlas/au/Role=NULL/Capability=NULL;/atlas/dataprep/Role=NULL/Capability=NULL;/atlas/lcg1/Role=NULL/Capability=NULL;/atlas/team/Role=NULL/Capability=NULL;/atlas/uk/Role=NULL/Capability=NULL" right_fqan4 = "/ilc/Role=NULL/Capability=NULL" short_fqan1 = "/no/role/or/equals" short_fqan2 = "/someorg/somegroup" self.assertEqual(parse_fqan(wrong_fqan1), (None, None, wrong_fqan1)) self.assertEqual(parse_fqan(wrong_fqan2), (None, None, wrong_fqan2)) self.assertEqual(parse_fqan(right_fqan1), ("role=doer", "/atlas", "atlas")) self.assertEqual(parse_fqan(right_fqan2), ("role=doer", "/atlas/somethingelse", "atlas")) self.assertEqual(parse_fqan(right_fqan3), ("Role=production", "/atlas", "atlas")) self.assertEqual(parse_fqan(right_fqan4), ("Role=NULL", "/ilc", "ilc")) self.assertEqual(parse_fqan(short_fqan1), ('None', '/no/role/or/equals', 'no')) self.assertEqual(parse_fqan(short_fqan2), ('None', '/someorg/somegroup', 'someorg'))
def test_parse_fqan(self): self.assertEqual((None, None, 'role=2'), parse_fqan('role=2')) self.assertEqual(('role=some', '/Test', 'Test'), parse_fqan('/Test/role=some/test')) wrong_fqan1 = "hello." wrong_fqan2 = "the/the/the" right_fqan1 = "/atlas/role=doer" right_fqan2 = "/atlas/somethingelse/role=doer" right_fqan3 = "/atlas/Role=production/Capability=NULL;/atlas/Role=NULL/Capability=NULL;/atlas/alarm/Role=NULL/Capability=NULL;/atlas/au/Role=NULL/Capability=NULL;/atlas/dataprep/Role=NULL/Capability=NULL;/atlas/lcg1/Role=NULL/Capability=NULL;/atlas/team/Role=NULL/Capability=NULL;/atlas/uk/Role=NULL/Capability=NULL" right_fqan4 = "/ilc/Role=NULL/Capability=NULL" short_fqan1 = "/no/role/or/equals" short_fqan2 = "/someorg/somegroup" self.assertEqual(parse_fqan(wrong_fqan1), (None, None, wrong_fqan1)) self.assertEqual(parse_fqan(wrong_fqan2), (None, None, wrong_fqan2)) self.assertEqual(parse_fqan(right_fqan1), ("role=doer", "/atlas", "atlas")) self.assertEqual(parse_fqan(right_fqan2), ("role=doer", "/atlas/somethingelse", "atlas")) self.assertEqual(parse_fqan(right_fqan3), ("Role=production", "/atlas", "atlas")) self.assertEqual(parse_fqan(right_fqan4), ("Role=NULL", "/ilc", "ilc")) self.assertEqual(parse_fqan(short_fqan1), ('None', '/no/role/or/equals', 'no')) self.assertEqual(parse_fqan(short_fqan2), ('None', '/someorg/somegroup', 'someorg'))
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. if self._record_content['FQAN'] not in ('None', None): role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role == None: role = 'None' if group == None: group = 'None' if vo == None: vo = 'None' self._record_content['VORole'] = role self._record_content['VOGroup'] = group # Confusing terminology from the CAR self._record_content['VO'] = vo # Check the ScalingFactor. slt = self._record_content['ServiceLevelType'] sl = self._record_content['ServiceLevel'] (slt, sl) = self._check_factor(slt, sl) self._record_content['ServiceLevelType'] = slt self._record_content['ServiceLevel'] = sl # Check the values of StartTime and EndTime self._check_start_end_times()
def _check_fields(self): """ Add extra checks to those made in every record. """ # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. if self._record_content["FQAN"] not in ("None", None): role, group, vo = parse_fqan(self._record_content["FQAN"]) # We can't / don't put NULL in the database, so we use 'None' if role is None: role = "None" if group is None: group = "None" if vo is None: vo = "None" self._record_content["VORole"] = role self._record_content["VOGroup"] = group # Confusing terminology from the CAR self._record_content["VO"] = vo # Check the ScalingFactor. slt = self._record_content["ServiceLevelType"] sl = self._record_content["ServiceLevel"] (slt, sl) = self._check_factor(slt, sl) self._record_content["ServiceLevelType"] = slt self._record_content["ServiceLevel"] = sl # Check the values of StartTime and EndTime self._check_start_end_times()
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role == None: role = 'None' if group == None: group = 'None' if vo == None: vo = 'None' self._record_content['VORole'] = role self._record_content['VOGroup'] = group self._record_content['VO'] = vo
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role == None: role = 'None' if group == None: group = 'None' if vo == None: vo = 'None' self._record_content['VORole'] = role self._record_content['VOGroup'] = group self._record_content['VO'] = vo
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role is None: role = 'None' if group is None: group = 'None' if vo is None: vo = 'None' if self._record_content['Benchmark'] is None: # If Benchmark is not present in the original record the # parent Record class level type checking will set it to # None. We can't pass None as a Benchmark as the field is # NOT NULL in the database, so we set it to something # meaningful. In this case the float 0.0. self._record_content['Benchmark'] = 0.0 self._record_content['VORole'] = role self._record_content['VOGroup'] = group self._record_content['VO'] = vo # If the message was missing a CpuCount, assume it used # zero Cpus, to prevent a NULL being written into the column # in the CloudRecords tables. # Doing so would be a problem despite the CloudRecords # table allowing it because the CloudSummaries table # doesn't allow it, creating a problem at summariser time. if self._record_content['CpuCount'] is None: self._record_content['CpuCount'] = 0
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role is None: role = 'None' if group is None: group = 'None' if vo is None: vo = 'None' if self._record_content['Benchmark'] is None: # If Benchmark is not present in the original record the # parent Record class level type checking will set it to # None. We can't pass None as a Benchmark as the field is # NOT NULL in the database, so we set it to something # meaningful. In this case the float 0.0. self._record_content['Benchmark'] = 0.0 self._record_content['VORole'] = role self._record_content['VOGroup'] = group self._record_content['VO'] = vo # If the message was missing a CpuCount, assume it used # zero Cpus, to prevent a NULL being written into the column # in the CloudRecords tables. # Doing so would be a problem despite the CloudRecords # table allowing it because the CloudSummaries table # doesn't allow it, creating a problem at summariser time. if self._record_content['CpuCount'] is None: self._record_content['CpuCount'] = 0
def _check_fields(self): ''' Add extra checks to those made in every record. ''' # First, call the parent's version. Record._check_fields(self) # Extract the relevant information from the user fqan. # Keep the fqan itself as other methods in the class use it. if self._record_content['FQAN'] not in ('None', None): role, group, vo = parse_fqan(self._record_content['FQAN']) # We can't / don't put NULL in the database, so we use 'None' if role == None: role = 'None' if group == None: group = 'None' if vo == None: vo = 'None' self._record_content['VORole'] = role self._record_content['VOGroup'] = group # Confusing terminology from the CAR self._record_content['VO'] = vo # Check the ScalingFactor. slt = self._record_content['ServiceLevelType'] sl = self._record_content['ServiceLevel'] (slt, sl) = self._check_factor(slt, sl) self._record_content['ServiceLevelType'] = slt self._record_content['ServiceLevel'] = sl # Check the values of StartTime and EndTime self._check_start_end_times()