@@ -6854,240 +6854,23 @@ def test_placement_client_init(self, mock_report_client):
6854
6854
6855
6855
6856
6856
class Cellsv1DeprecatedTestMixIn (object ):
6857
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' )
6858
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' ,
6859
- side_effect = exception .CellMappingNotFound (uuid = 'fake' ))
6860
- def test_get_all_includes_build_requests (self , mock_cell_mapping_get ,
6861
- mock_buildreq_get ):
6862
-
6863
- build_req_instances = self ._list_of_instances (2 )
6864
- build_reqs = [objects .BuildRequest (self .context , instance = instance )
6865
- for instance in build_req_instances ]
6866
- mock_buildreq_get .return_value = objects .BuildRequestList (self .context ,
6867
- objects = build_reqs )
6868
-
6869
- cell_instances = self ._list_of_instances (2 )
6870
-
6871
- with mock .patch .object (self .compute_api ,
6872
- '_get_instances_by_filters' ) as mock_inst_get :
6873
- mock_inst_get .return_value = objects .InstanceList (
6874
- self .context , objects = cell_instances )
6875
-
6876
- instances = self .compute_api .get_all (
6877
- self .context , search_opts = {'foo' : 'bar' },
6878
- limit = None , marker = 'fake-marker' , sort_keys = ['baz' ],
6879
- sort_dirs = ['desc' ])
6880
-
6881
- mock_buildreq_get .assert_called_once_with (
6882
- self .context , {'foo' : 'bar' }, limit = None , marker = 'fake-marker' ,
6883
- sort_keys = ['baz' ], sort_dirs = ['desc' ])
6884
- fields = ['metadata' , 'info_cache' , 'security_groups' ]
6885
- mock_inst_get .assert_called_once_with (
6886
- self .context , {'foo' : 'bar' }, limit = None , marker = None ,
6887
- fields = fields , sort_keys = ['baz' ], sort_dirs = ['desc' ])
6888
- for i , instance in enumerate (build_req_instances + cell_instances ):
6889
- self .assertEqual (instance , instances [i ])
6890
-
6891
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' )
6892
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' ,
6893
- side_effect = exception .CellMappingNotFound (uuid = 'fake' ))
6894
- def test_get_all_includes_build_requests_filter_dupes (self ,
6895
- mock_cell_mapping_get , mock_buildreq_get ):
6896
-
6897
- build_req_instances = self ._list_of_instances (2 )
6898
- build_reqs = [objects .BuildRequest (self .context , instance = instance )
6899
- for instance in build_req_instances ]
6900
- mock_buildreq_get .return_value = objects .BuildRequestList (self .context ,
6901
- objects = build_reqs )
6857
+ def test_get_all_build_requests_decrement_limit (self ):
6858
+ self .skipTest ("Removing cells v1" )
6902
6859
6903
- cell_instances = self ._list_of_instances (2 )
6860
+ def test_get_all_cell0_marker_not_found (self ):
6861
+ self .skipTest ("Removing cells v1" )
6904
6862
6905
- with mock .patch .object (self .compute_api ,
6906
- '_get_instances_by_filters' ) as mock_inst_get :
6907
- # Insert one of the build_req_instances here so it shows up twice
6908
- mock_inst_get .return_value = objects .InstanceList (
6909
- self .context , objects = build_req_instances [:1 ] + cell_instances )
6863
+ def test_get_all_includes_build_request_cell0 (self ):
6864
+ self .skipTest ("Removing cells v1" )
6910
6865
6911
- instances = self .compute_api .get_all (
6912
- self .context , search_opts = {'foo' : 'bar' },
6913
- limit = None , marker = 'fake-marker' , sort_keys = ['baz' ],
6914
- sort_dirs = ['desc' ])
6866
+ def test_get_all_includes_build_requests (self ):
6867
+ self .skipTest ("Removing cells v1" )
6915
6868
6916
- mock_buildreq_get .assert_called_once_with (
6917
- self .context , {'foo' : 'bar' }, limit = None , marker = 'fake-marker' ,
6918
- sort_keys = ['baz' ], sort_dirs = ['desc' ])
6919
- fields = ['metadata' , 'info_cache' , 'security_groups' ]
6920
- mock_inst_get .assert_called_once_with (
6921
- self .context , {'foo' : 'bar' }, limit = None , marker = None ,
6922
- fields = fields , sort_keys = ['baz' ], sort_dirs = ['desc' ])
6923
- for i , instance in enumerate (build_req_instances + cell_instances ):
6924
- self .assertEqual (instance , instances [i ])
6869
+ def test_get_all_includes_build_requests_filter_dupes (self ):
6870
+ self .skipTest ("Removing cells v1" )
6925
6871
6926
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' )
6927
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' ,
6928
- side_effect = exception .CellMappingNotFound (uuid = 'fake' ))
6929
- def test_get_all_build_requests_decrement_limit (self ,
6930
- mock_cell_mapping_get ,
6931
- mock_buildreq_get ):
6932
-
6933
- build_req_instances = self ._list_of_instances (2 )
6934
- build_reqs = [objects .BuildRequest (self .context , instance = instance )
6935
- for instance in build_req_instances ]
6936
- mock_buildreq_get .return_value = objects .BuildRequestList (self .context ,
6937
- objects = build_reqs )
6938
-
6939
- cell_instances = self ._list_of_instances (2 )
6940
-
6941
- with mock .patch .object (self .compute_api ,
6942
- '_get_instances_by_filters' ) as mock_inst_get :
6943
- mock_inst_get .return_value = objects .InstanceList (
6944
- self .context , objects = cell_instances )
6945
-
6946
- instances = self .compute_api .get_all (
6947
- self .context , search_opts = {'foo' : 'bar' },
6948
- limit = 10 , marker = 'fake-marker' , sort_keys = ['baz' ],
6949
- sort_dirs = ['desc' ])
6950
-
6951
- mock_buildreq_get .assert_called_once_with (
6952
- self .context , {'foo' : 'bar' }, limit = 10 , marker = 'fake-marker' ,
6953
- sort_keys = ['baz' ], sort_dirs = ['desc' ])
6954
- fields = ['metadata' , 'info_cache' , 'security_groups' ]
6955
- mock_inst_get .assert_called_once_with (
6956
- self .context , {'foo' : 'bar' }, limit = 8 , marker = None ,
6957
- fields = fields , sort_keys = ['baz' ], sort_dirs = ['desc' ])
6958
- for i , instance in enumerate (build_req_instances + cell_instances ):
6959
- self .assertEqual (instance , instances [i ])
6960
-
6961
- @mock .patch .object (context , 'target_cell' )
6962
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' )
6963
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' )
6964
- @mock .patch .object (objects .CellMappingList , 'get_all' )
6965
- def test_get_all_includes_build_request_cell0 (self , mock_cm_get_all ,
6966
- mock_cell_mapping_get ,
6967
- mock_buildreq_get , mock_target_cell ):
6968
-
6969
- build_req_instances = self ._list_of_instances (2 )
6970
- build_reqs = [objects .BuildRequest (self .context , instance = instance )
6971
- for instance in build_req_instances ]
6972
- mock_buildreq_get .return_value = objects .BuildRequestList (self .context ,
6973
- objects = build_reqs )
6974
-
6975
- cell0_instances = self ._list_of_instances (2 )
6976
- cell_instances = self ._list_of_instances (2 )
6977
-
6978
- cell_mapping = objects .CellMapping (uuid = objects .CellMapping .CELL0_UUID ,
6979
- name = '0' )
6980
- mock_cell_mapping_get .return_value = cell_mapping
6981
- mock_cm_get_all .return_value = [
6982
- cell_mapping ,
6983
- objects .CellMapping (uuid = uuids .cell1 , name = '1' ),
6984
- ]
6985
- cctxt = mock_target_cell .return_value .__enter__ .return_value
6986
-
6987
- with mock .patch .object (self .compute_api ,
6988
- '_get_instances_by_filters' ) as mock_inst_get :
6989
- mock_inst_get .side_effect = [objects .InstanceList (
6990
- self .context ,
6991
- objects = cell0_instances ),
6992
- objects .InstanceList (
6993
- self .context ,
6994
- objects = cell_instances )]
6995
-
6996
- instances = self .compute_api .get_all (
6997
- self .context , search_opts = {'foo' : 'bar' },
6998
- limit = 10 , marker = 'fake-marker' , sort_keys = ['baz' ],
6999
- sort_dirs = ['desc' ])
7000
-
7001
- if self .cell_type is None :
7002
- for cm in mock_cm_get_all .return_value :
7003
- mock_target_cell .assert_any_call (self .context , cm )
7004
- fields = ['metadata' , 'info_cache' , 'security_groups' ]
7005
- inst_get_calls = [mock .call (cctxt , {'foo' : 'bar' },
7006
- limit = 8 , marker = None ,
7007
- fields = fields , sort_keys = ['baz' ],
7008
- sort_dirs = ['desc' ]),
7009
- mock .call (mock .ANY , {'foo' : 'bar' },
7010
- limit = 6 , marker = None ,
7011
- fields = fields , sort_keys = ['baz' ],
7012
- sort_dirs = ['desc' ])
7013
- ]
7014
- self .assertEqual (2 , mock_inst_get .call_count )
7015
- mock_inst_get .assert_has_calls (inst_get_calls )
7016
- for i , instance in enumerate (build_req_instances +
7017
- cell0_instances +
7018
- cell_instances ):
7019
- self .assertEqual (instance , instances [i ])
7020
-
7021
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' )
7022
- @mock .patch .object (compute_api .API , '_get_instances_by_filters' )
7023
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' )
7024
- def test_tenant_to_project_conversion (self , mock_cell_map_get , mock_get ,
7025
- mock_buildreq_get ):
7026
- mock_cell_map_get .side_effect = exception .CellMappingNotFound (
7027
- uuid = 'fake' )
7028
- mock_get .return_value = objects .InstanceList (objects = [])
7029
- api = compute_api .API ()
7030
- api .get_all (self .context , search_opts = {'tenant_id' : 'foo' })
7031
- filters = mock_get .call_args_list [0 ][0 ][1 ]
7032
- self .assertEqual ({'project_id' : 'foo' }, filters )
7033
-
7034
- @mock .patch .object (context , 'target_cell' )
7035
- @mock .patch .object (objects .BuildRequestList , 'get_by_filters' ,
7036
- side_effect = exception .MarkerNotFound (
7037
- marker = uuids .marker ))
7038
- @mock .patch .object (objects .CellMapping , 'get_by_uuid' )
7039
- @mock .patch .object (objects .CellMappingList , 'get_all' )
7040
- def test_get_all_cell0_marker_not_found (self , mock_cm_get_all ,
7041
- mock_cell_mapping_get ,
7042
- mock_buildreq_get ,
7043
- mock_target_cell ):
7044
- """Tests that we handle a MarkerNotFound raised from the cell0 database
7045
- and continue looking for instances from the normal cell database.
7046
- """
7047
-
7048
- cell_instances = self ._list_of_instances (2 )
7049
-
7050
- cell_mapping = objects .CellMapping (uuid = objects .CellMapping .CELL0_UUID ,
7051
- name = '0' )
7052
- mock_cell_mapping_get .return_value = cell_mapping
7053
- mock_cm_get_all .return_value = [
7054
- cell_mapping ,
7055
- objects .CellMapping (uuid = uuids .cell1 , name = '1' ),
7056
- ]
7057
- marker = uuids .marker
7058
- cctxt = mock_target_cell .return_value .__enter__ .return_value
7059
-
7060
- with mock .patch .object (self .compute_api ,
7061
- '_get_instances_by_filters' ) as mock_inst_get :
7062
- # simulate calling _get_instances_by_filters twice, once for cell0
7063
- # which raises a MarkerNotFound and once from the cell DB which
7064
- # returns two instances
7065
- mock_inst_get .side_effect = [
7066
- exception .MarkerNotFound (marker = marker ),
7067
- objects .InstanceList (self .context , objects = cell_instances )]
7068
-
7069
- instances = self .compute_api .get_all (
7070
- self .context , search_opts = {'foo' : 'bar' },
7071
- limit = 10 , marker = marker , sort_keys = ['baz' ],
7072
- sort_dirs = ['desc' ])
7073
-
7074
- if self .cell_type is None :
7075
- for cm in mock_cm_get_all .return_value :
7076
- mock_target_cell .assert_any_call (self .context , cm )
7077
- fields = ['metadata' , 'info_cache' , 'security_groups' ]
7078
- inst_get_calls = [mock .call (cctxt , {'foo' : 'bar' },
7079
- limit = 10 , marker = marker ,
7080
- fields = fields , sort_keys = ['baz' ],
7081
- sort_dirs = ['desc' ]),
7082
- mock .call (mock .ANY , {'foo' : 'bar' },
7083
- limit = 10 , marker = marker ,
7084
- fields = fields , sort_keys = ['baz' ],
7085
- sort_dirs = ['desc' ])
7086
- ]
7087
- self .assertEqual (2 , mock_inst_get .call_count )
7088
- mock_inst_get .assert_has_calls (inst_get_calls )
7089
- for i , instance in enumerate (cell_instances ):
7090
- self .assertEqual (instance , instances [i ])
6872
+ def test_tenant_to_project_conversion (self ):
6873
+ self .skipTest ("Removing cells v1" )
7091
6874
7092
6875
def test_get_all_with_cell_down_support (self ):
7093
6876
self .skipTest ("Cell down handling is not supported for cells_v1." )
0 commit comments