'Ensure volume types get by extra spec returns correct type.'

def test_volume_type_search_by_extra_spec(self):

    volume_types.create(self.ctxt, 'type1', {'key1': 'val1', 'key2': 'val2'})
    volume_types.create(self.ctxt, 'type2', {'key2': 'val2', 'key3': 'val3'})
    volume_types.create(self.ctxt, 'type3', {'key3': 'another_value', 'key4': 'val4'})
    vol_types = volume_types.get_all_types(self.ctxt, filters={'extra_specs': {'key1': 'val1'}})
    self.assertEqual(1, len(vol_types))
    self.assertIn('type1', vol_types.keys())
    self.assertEqual({'key1': 'val1', 'key2': 'val2'}, vol_types['type1']['extra_specs'])
    vol_types = volume_types.get_all_types(self.ctxt, filters={'extra_specs': {'key2': 'val2'}})
    self.assertEqual(2, len(vol_types))
    self.assertIn('type1', vol_types.keys())
    self.assertIn('type2', vol_types.keys())
    vol_types = volume_types.get_all_types(self.ctxt, filters={'extra_specs': {'key3': 'val3'}})
    self.assertEqual(1, len(vol_types))
    self.assertIn('type2', vol_types.keys())
