def kibana_handle_schema_change(
        tenant: str,
        alias_name: str,
        schema_old: Mapping[Any, Any],
        schema_new: Mapping[Any, Any],
        subscription: Mapping[str, Any],  # Subscription.definition
        es_index: Mapping[Any, Any],
        es_conn,
        kibana_conn):
    node_new = Node(schema_new)
    kibana_index = make_kibana_index(alias_name, node_new)
    schema_name = schema_new.get('name')
    if schema_old is not None:
        if schema_old.get('name'):
            schema_name = schema_old.get('name')
        node_old = Node(schema_old)
        if Node.compare(node_old, node_new) == {}:
            return False  # schema not substantially different
    if not check_for_kibana_update(schema_name, tenant, alias_name,
                                   subscription, kibana_index, es_index,
                                   es_conn, kibana_conn):
        return False

    return update_kibana_index(tenant, alias_name, schema_new, subscription,
                               kibana_index, es_index, es_conn, kibana_conn)
示例#2
0
def test__comparison_nested_attr(ComplexSchema):
    a = deepcopy(ComplexSchema)
    b = deepcopy(ComplexSchema)
    path = 'operator_type'
    # change a node's attribute
    a.children[path].__lookup = [{"something": "else"}]
    # I don't always trust deepcopy...
    assert (a.children[path].__lookup != b.children[path].__lookup)
    res = Node.compare(b, a)
    assert (any([path in k for k in res.keys()]))
示例#3
0
def test__comparison_all(SimpleSchema):
    a = deepcopy(SimpleSchema)
    b = deepcopy(SimpleSchema)
    a.name = 'SomethingElse'  # change root node (changes all paths)
    assert (len(Node.compare(a, b)) == 15)  # all nodes
示例#4
0
def test__comparison_none(SimpleSchema):
    assert (Node.compare(SimpleSchema, SimpleSchema) == {})