def setUpClass(cls): if DSE_VERSION: cls._create_cluster_with_cp_options("CONTDEFAULT", ContinuousPagingOptions()) cls._create_cluster_with_cp_options( "ONEPAGE", ContinuousPagingOptions(max_pages=1)) cls._create_cluster_with_cp_options( "MANYPAGES", ContinuousPagingOptions(max_pages=10)) cls._create_cluster_with_cp_options( "SLOW", ContinuousPagingOptions(max_pages_per_second=1))
def setUpClass(cls): if not DSE_VERSION or DSE_VERSION < cls.required_dse_version: return cls.execution_profiles = {"CONTDEFAULT": ExecutionProfile(continuous_paging_options=ContinuousPagingOptions()), "ONEPAGE": ExecutionProfile( continuous_paging_options=ContinuousPagingOptions(max_pages=1)), "MANYPAGES": ExecutionProfile( continuous_paging_options=ContinuousPagingOptions(max_pages=10)), "BYTES": ExecutionProfile(continuous_paging_options=ContinuousPagingOptions( page_unit=ContinuousPagingOptions.PagingUnit.BYTES)), "SLOW": ExecutionProfile( continuous_paging_options=ContinuousPagingOptions(max_pages_per_second=1)), } cls.sane_eps = ["CONTDEFAULT", "BYTES"]
def setUpClass(cls): BasicConcurrentTests.required_dse_version = Version('6.0') if not DSE_VERSION or DSE_VERSION < BasicConcurrentTests.required_dse_version: return BasicConcurrentTests.protocol_version = ProtocolVersion.DSE_V2 BasicConcurrentTests.setUpClass() cls.connections = cls.connections.union({"SMALL_QUEUE", "BIG_QUEUE"}) cls.sane_connections = cls.sane_connections.union( {"SMALL_QUEUE", "BIG_QUEUE"}) cls._create_cluster_with_cp_options( "SMALL_QUEUE", ContinuousPagingOptions(max_queue_size=2)) cls._create_cluster_with_cp_options( "BIG_QUEUE", ContinuousPagingOptions(max_queue_size=400))
def test_protocol_divergence_v5_fail_by_continuous_paging(self): """ Test to validate that V5 and DSE_V1 diverge. ContinuousPagingOptions is not supported by V5 @since DSE 2.0b3 GRAPH 1.0b1 @jira_ticket PYTHON-694 @expected_result NoHostAvailable will be risen when the continuous_paging_options parameter is set @test_category connection """ cluster = TestCluster(protocol_version=ProtocolVersion.V5, allow_beta_protocol_version=True) session = cluster.connect() max_pages = 4 max_pages_per_second = 3 continuous_paging_options = ContinuousPagingOptions( max_pages=max_pages, max_pages_per_second=max_pages_per_second) future = self._send_query_message( session, timeout=session.default_timeout, consistency_level=ConsistencyLevel.ONE, continuous_paging_options=continuous_paging_options) # This should raise NoHostAvailable because continuous paging is not supported under ProtocolVersion.DSE_V1 with self.assertRaises(NoHostAvailable) as context: future.result() self.assertIn( "Continuous paging may only be used with protocol version ProtocolVersion.DSE_V1 or higher", str(context.exception)) cluster.shutdown()
def setUpClass(cls): cls.required_dse_version = BaseContPagingTests.required_dse_version = Version('6.0') if not DSE_VERSION or DSE_VERSION < cls.required_dse_version: return BasicSharedKeyspaceUnitTestCaseRF3WM.setUpClass() BaseContPagingTests.setUpClass() more_profiles = { "SMALL_QUEUE": ExecutionProfile(continuous_paging_options=ContinuousPagingOptions(max_queue_size=2)), "BIG_QUEUE": ExecutionProfile(continuous_paging_options=ContinuousPagingOptions(max_queue_size=400)) } cls.sane_eps += ["SMALL_QUEUE", "BIG_QUEUE"] cls.execution_profiles.update(more_profiles) cls.protocol_version = ProtocolVersion.DSE_V2 cls.create_cluster()
def test_continuous_paging(self): """ Test to check continuous paging throws an Exception if it's not supported and the correct valuesa are written to the buffer if the option is enabled. @since DSE 2.0b3 GRAPH 1.0b1 @jira_ticket PYTHON-694 @expected_result the values are correctly written @test_category connection """ max_pages = 4 max_pages_per_second = 3 continuous_paging_options = ContinuousPagingOptions( max_pages=max_pages, max_pages_per_second=max_pages_per_second) message = QueryMessage( "a", 3, continuous_paging_options=continuous_paging_options) io = Mock() for version in [ version for version in ProtocolVersion.SUPPORTED_VERSIONS if not ProtocolVersion.has_continuous_paging_support(version) ]: self.assertRaises(UnsupportedOperation, message.send_body, io, version) io.reset_mock() message.send_body(io, ProtocolVersion.DSE_V1) # continuous paging adds two write calls to the buffer self.assertEqual(len(io.write.mock_calls), 6) # Check that the appropriate flag is set to True self.assertEqual( uint32_unpack(io.write.mock_calls[3][1][0]) & _WITH_SERIAL_CONSISTENCY_FLAG, 0) self.assertEqual( uint32_unpack(io.write.mock_calls[3][1][0]) & _PAGE_SIZE_FLAG, 0) self.assertEqual( uint32_unpack(io.write.mock_calls[3][1][0]) & _WITH_PAGING_STATE_FLAG, 0) self.assertEqual( uint32_unpack(io.write.mock_calls[3][1][0]) & _PAGING_OPTIONS_FLAG, _PAGING_OPTIONS_FLAG) # Test max_pages and max_pages_per_second are correctly written self.assertEqual(uint32_unpack(io.write.mock_calls[4][1][0]), max_pages) self.assertEqual(uint32_unpack(io.write.mock_calls[5][1][0]), max_pages_per_second)
def _test_cont_paging_with_custom_options(self, schema, graphson): """ Test that we can specify custom paging options. @jira_ticket PYTHON-1045 @expected_result we get only the desired number of results @test_category dse graph """ ep = self.get_execution_profile(graphson) new_ep = self.session.execution_profile_clone_update( ep, continuous_paging_options=ContinuousPagingOptions(max_pages=1)) self._setup_data(schema, graphson) self.session.default_fetch_size = 10 results = list(self.session.execute_graph("g.V()", execution_profile=new_ep)) self.assertEqual(len(results), 10)
def _test_cont_paging_with_custom_options(self, schema, graphson): """ Test that we can specify custom paging options. @jira_ticket PYTHON-1045 @expected_result we get only the desired number of results @test_category dse graph """ ep = self.get_execution_profile(graphson, traversal=True) ep = self.session.execution_profile_clone_update(ep, continuous_paging_options=ContinuousPagingOptions(max_pages=1)) self._setup_data(schema, graphson) self.session.default_fetch_size = 10 g = DseGraph.traversal_source(self.session, execution_profile=ep) results = g.V().toList() self.assertEqual(len(results), 10) # only 10 results since paging is disabled