def test_deduplication(self): aconf = Config() p = DeduplicatingKubernetesProcessor(CountingKubernetesProcessor(aconf, valid_mapping.gvk, 'test')) assert p.try_process(valid_mapping) assert p.try_process(valid_mapping) assert p.try_process(valid_mapping) assert aconf.get_count('test') == 1
def test_count(self): aconf = Config() p = CountingKubernetesProcessor(aconf, valid_mapping.gvk, 'test') assert p.try_process(valid_mapping), 'Processor rejected matching resource' assert p.try_process(valid_mapping), 'Processor rejected matching resource (again)' assert not p.try_process(valid_knative_ingress), 'Processor accepted non-matching resource' assert aconf.get_count('test') == 2, 'Processor did not increment counter'
def test_aggregation(self): aconf = Config() fp = FinalizingKubernetesProcessor() p = AggregateKubernetesProcessor([ CountingKubernetesProcessor(aconf, valid_knative_ingress.gvk, 'test_1'), CountingKubernetesProcessor(aconf, valid_mapping.gvk, 'test_2'), fp, ]) assert len(p.kinds()) == 2 assert p.try_process(valid_knative_ingress) assert p.try_process(valid_mapping) assert aconf.get_count('test_1') == 1 assert aconf.get_count('test_2') == 1 p.finalize() assert fp.finalized, 'Aggregate processor did not call finalizers'