コード例 #1
0
def test_auto_ts_global_enabled(mock_sonic_db, manifest):
    mock_init_cfg = Mock()
    AutoTSHelp.GLOBAL_STATE = {"state" : "enabled"}
    mock_init_cfg.get_entry = Mock(side_effect=AutoTSHelp.get_entry)
    mock_sonic_db.get_connectors = Mock(return_value=[mock_init_cfg])
    mock_sonic_db.get_initial_db_connector = Mock(return_value=mock_init_cfg)
    feature_registry = FeatureRegistry(mock_sonic_db)
    feature_registry.register(manifest)
    mock_init_cfg.set_entry.assert_any_call("AUTO_TECHSUPPORT_FEATURE", "test", {
            "state" : "enabled",
            "rate_limit_interval" : "600"
        }
    )
コード例 #2
0
def test_feature_registration_with_non_default_owner(mock_sonic_db, manifest):
    mock_connector = Mock()
    mock_connector.get_entry = Mock(return_value={})
    mock_sonic_db.get_connectors = Mock(return_value=[mock_connector])
    feature_registry = FeatureRegistry(mock_sonic_db)
    feature_registry.register(manifest, owner='kube')
    mock_connector.set_entry.assert_called_with('FEATURE', 'test', {
        'state': 'disabled',
        'auto_restart': 'enabled',
        'high_mem_alert': 'disabled',
        'set_owner': 'kube',
        'has_per_asic_scope': 'False',
        'has_global_scope': 'True',
        'has_timer': 'False',
    })
コード例 #3
0
def test_feature_registration_with_non_default_owner(mock_sonic_db, manifest):
    mock_feature_table = Mock()
    mock_feature_table.get = Mock(return_value=(False, ()))
    mock_sonic_db.initial_table = Mock(return_value=mock_feature_table)
    mock_sonic_db.persistent_table = Mock(return_value=mock_feature_table)
    mock_sonic_db.running_table = Mock(return_value=mock_feature_table)
    feature_registry = FeatureRegistry(mock_sonic_db)
    feature_registry.register(manifest, owner='kube')
    mock_feature_table.set.assert_called_with('test', [
        ('state', 'disabled'),
        ('auto_restart', 'enabled'),
        ('high_mem_alert', 'disabled'),
        ('set_owner', 'kube'),
        ('has_per_asic_scope', 'False'),
        ('has_global_scope', 'True'),
        ('has_timer', 'False'),
    ])
コード例 #4
0
def test_feature_registration_with_timer(mock_sonic_db, manifest):
    manifest['service']['delayed'] = True
    mock_connector = Mock()
    mock_connector.get_entry = Mock(return_value={})
    mock_sonic_db.get_connectors = Mock(return_value=[mock_connector])
    mock_sonic_db.get_initial_db_connector = Mock(return_value=mock_connector)
    feature_registry = FeatureRegistry(mock_sonic_db)
    feature_registry.register(manifest)
    mock_connector.set_entry.assert_called_with('FEATURE', 'test', {
        'state': 'disabled',
        'auto_restart': 'enabled',
        'high_mem_alert': 'disabled',
        'set_owner': 'local',
        'has_per_asic_scope': 'False',
        'has_global_scope': 'True',
        'has_timer': 'True',
    })