fabric8io / openshift-elasticsearch-plugin

Apache License 2.0
27 stars 21 forks source link

bug 1476062. Only seed documents when they are missing #100

Closed jcantrill closed 7 years ago

jcantrill commented 7 years ago

This PR

jcantrill commented 7 years ago

cc @portante

richm commented 7 years ago

Can we have a test to verify that an existing index pattern is not replaced?

jcantrill commented 7 years ago

@richm I'm still working on how to best run these tests consistently with our CI but was able to prove that:

Note: The steps are subtly different but it is only the verbiage and an initialization step

Before fix:

Feature: An user's kibana index is seeded with index mappings for
  the indices that are visible to them.

  Scenario: A user's kibana index is only seeded once     # features/elasticsearch.feature:7
    Given a user with the role of operations              # features/step_definitions/policy_steps.rb:1
    And logs were collected for the operations project    # features/step_definitions/elasticsearch_steps.rb:1
    And they log into Kibana                              # features/step_definitions/kibana_steps.rb:1
    And refresh their index field list                    # features/step_definitions/kibana_steps.rb:25
      Failed to write when refreshing field mappings. UI says 155 but index says 251 (RuntimeError)
      ./features/step_definitions/kibana_steps.rb:69:in `/^refresh their index field list$/'
      ./features/support/hooks.rb:15:in `call'
      ./features/support/hooks.rb:15:in `block in <top (required)>'
      features/elasticsearch.feature:14:in `And refresh their index field list'
    When they log into Kibana again                       # features/step_definitions/kibana_steps.rb:15
    Then the index mapping fields should remain unchanged # features/step_definitions/kibana_steps.rb:72

Failing Scenarios:
cucumber features/elasticsearch.feature:7 # Scenario: A user's kibana index is only seeded once

1 scenario (1 failed)
6 steps (1 failed, 2 skipped, 3 passed)
0m17.303s

After fix:

@elasticsearch
Feature: An user's kibana index is seeded with index mappings for
  the indices that are visible to them.

  Scenario: A user's kibana index is only seeded once     # features/elasticsearch.feature:7
    Given a user with the role of operations              # features/step_definitions/policy_steps.rb:1
    And the user has never used Kibana                    # features/step_definitions/kibana_steps.rb:15
    And logs were collected for the operations project    # features/step_definitions/elasticsearch_steps.rb:1
    And they log into Kibana                              # features/step_definitions/kibana_steps.rb:1
    And refresh operations index pattern field list       # features/step_definitions/kibana_steps.rb:34
    When they log into Kibana again                       # features/step_definitions/kibana_steps.rb:24
    Then the index mapping fields should remain unchanged # features/step_definitions/kibana_steps.rb:74

1 scenario (1 passed)
7 steps (7 passed)
0m20.763s

Does this satisfy your test request?

jcantrill commented 7 years ago

cc @portante