예제 #1
0
    def test_ingest_method_type(self):
        """Test that the correct ingest method is returned for provider type."""
        test_matrix = [
            {
                "provider_type": Provider.PROVIDER_AWS,
                "expected_ingest": POLL_INGEST
            },
            {
                "provider_type": Provider.PROVIDER_AWS_LOCAL,
                "expected_ingest": POLL_INGEST
            },
            {
                "provider_type": Provider.PROVIDER_OCP,
                "expected_ingest": LISTEN_INGEST
            },
            {
                "provider_type": Provider.PROVIDER_AZURE_LOCAL,
                "expected_ingest": POLL_INGEST
            },
            {
                "provider_type": "NEW_TYPE",
                "expected_ingest": None
            },
        ]

        for test in test_matrix:
            ingest_method = common_utils.ingest_method_for_provider(
                test.get("provider_type"))
            self.assertEqual(ingest_method, test.get("expected_ingest"))
예제 #2
0
    def test_ingest_method_type(self):
        """Test that the correct ingest method is returned for provider type."""
        test_matrix = [
            {
                'provider_type': AMAZON_WEB_SERVICES,
                'expected_ingest': POLL_INGEST
            },
            {
                'provider_type': AWS_LOCAL_SERVICE_PROVIDER,
                'expected_ingest': POLL_INGEST,
            },
            {
                'provider_type': OPENSHIFT_CONTAINER_PLATFORM,
                'expected_ingest': LISTEN_INGEST,
            },
            {
                'provider_type': AZURE_LOCAL_SERVICE_PROVIDER,
                'expected_ingest': POLL_INGEST,
            },
            {
                'provider_type': 'NEW_TYPE',
                'expected_ingest': None
            },
        ]

        for test in test_matrix:
            ingest_method = common_utils.ingest_method_for_provider(
                test.get('provider_type'))
            self.assertEqual(ingest_method, test.get('expected_ingest'))
예제 #3
0
    def is_polling_account(account):
        """
        Determine if account should be polled to initiate the processing pipeline.

        Account report information can be ingested by either POLLING (hourly beat schedule)
        or by LISTENING (kafka event-driven).

        There is a development-only use case to be able to force an account to follow the
        polling ingest path.  For Example: OpenShift is a LISTENING provider type but we
        can still side-load data by placing it in the temporary file storage directory on
        the worker.  On the next poll the Orchestrator will look for report updates in this
        directory and proceed with the download/processing steps.

        Args:
            account (dict) - Account dictionary that is retruned by
                             AccountsAccessor().get_accounts()

        Returns:
            (Boolean) : True if provider should be polled for updates.

        """
        if utils.ingest_method_for_provider(
                account.get("provider_type")
        ) == POLL_INGEST or ocp_utils.poll_ingest_override_for_provider(
                account.get("provider_uuid")):
            log_statement = (
                f"Polling for\n"
                f' schema_name: {account.get("schema_name")}\n'
                f' provider: {account.get("provider_type")}\n'
                f' account (provider uuid): {account.get("provider_uuid")}')
            LOG.info(log_statement)
            return True
        return False
예제 #4
0
    def test_ingest_method_type(self):
        """Test that the correct ingest method is returned for provider type."""
        test_matrix = [{
            'provider_type': Provider.PROVIDER_AWS,
            'expected_ingest': POLL_INGEST
        }, {
            'provider_type': Provider.PROVIDER_AWS_LOCAL,
            'expected_ingest': POLL_INGEST
        }, {
            'provider_type': Provider.PROVIDER_OCP,
            'expected_ingest': LISTEN_INGEST
        }, {
            'provider_type': Provider.PROVIDER_AZURE_LOCAL,
            'expected_ingest': POLL_INGEST
        }, {
            'provider_type': 'NEW_TYPE',
            'expected_ingest': None
        }]

        for test in test_matrix:
            ingest_method = common_utils.ingest_method_for_provider(
                test.get('provider_type'))
            self.assertEqual(ingest_method, test.get('expected_ingest'))