hawkular-client 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.rdoc +12 -0
  3. data/README.rdoc +5 -3
  4. data/Rakefile +8 -0
  5. data/hawkularclient.gemspec +1 -1
  6. data/lib/hawkular/base_client.rb +19 -1
  7. data/lib/hawkular/hawkular_client.rb +1 -1
  8. data/lib/hawkular/hawkular_client_utils.rb +1 -0
  9. data/lib/hawkular/inventory/entities.rb +234 -0
  10. data/lib/hawkular/inventory/inventory_api.rb +92 -311
  11. data/lib/hawkular/metrics/metric_api.rb +23 -10
  12. data/lib/hawkular/metrics/metrics_client.rb +14 -0
  13. data/lib/hawkular/operations/operations_api.rb +8 -2
  14. data/lib/hawkular/version.rb +1 -1
  15. data/spec/README.rdoc +62 -0
  16. data/spec/integration/alerts_spec.rb +18 -14
  17. data/spec/integration/hawkular_client_spec.rb +53 -14
  18. data/spec/integration/inventory_spec.rb +91 -44
  19. data/spec/integration/metric_spec.rb +574 -420
  20. data/spec/integration/operations_spec.rb +78 -5
  21. data/spec/integration/tokens_spec.rb +8 -4
  22. data/spec/spec_helper.rb +73 -13
  23. data/spec/unit/base_spec.rb +30 -1
  24. data/spec/unit/client_spec.rb +21 -9
  25. data/spec/vcr_cassettes/HawkularClient/Should_err_on_bad_credentials.yml +42 -0
  26. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_create_and_delete_feed.yml +64 -34
  27. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_list_WildFlys.yml +27 -43
  28. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_list_types_with_bad_feed.yml +12 -8
  29. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_same_types_when_param_is_given.yml +144 -64
  30. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_the_same_feeds.yml +26 -14
  31. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_the_same_resource_types.yml +20 -158
  32. data/spec/vcr_cassettes/HawkularClient/and_Operations_client/Should_both_work_the_same_way.yml +40 -30
  33. data/spec/vcr_cassettes/{Tenants/Should_Get_Tenant_For_Explicit_Credentials.yml → HawkularClient/and_Operations_client/Should_work_initializing_with_URI.yml} +18 -20
  34. data/spec/vcr_cassettes/HawkularClient/and_Operations_client_Should_both_work_the_same_way.json +8 -8
  35. data/spec/vcr_cassettes/HawkularClient/and_Operations_client_Should_work_initializing_with_URI.json +9 -0
  36. data/spec/vcr_cassettes/HawkularClient/and_URIs_as_input/Should_work_with_URI.yml +77 -20
  37. data/spec/vcr_cassettes/HawkularClient/and_URIs_as_input/Should_work_with_URI_on_metrics_client.yml +3 -3
  38. data/spec/vcr_cassettes/Inventory/Connection/Should_err_on_bad_credentials.yml +42 -0
  39. data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Explicit_Credentials.yml +59 -12
  40. data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Implicit_Credentials.yml +59 -12
  41. data/spec/vcr_cassettes/Inventory/{Helpers → inventory_0_17/Helpers}/create_url.yml +9 -7
  42. data/spec/vcr_cassettes/Inventory/{Templates/Should_list_feeds_when_using_SSL_without_certificate.yml → inventory_0_17/Helpers/get_feeds.yml} +23 -21
  43. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Client_should_listen_on_various_inventory_events.json +47 -0
  44. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Client_should_listen_on_various_inventory_events.yml +48 -40
  45. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Helpers/generate_some_events_for_websocket.yml +397 -0
  46. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_List_datasources_with_no_props.yml +129 -0
  47. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_a_feed.yml +13 -10
  48. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_a_feed_again.yml +40 -29
  49. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_a_nested_resource_and_metric_on_it.yml +193 -237
  50. data/spec/vcr_cassettes/Inventory/{Templates/Should_create_and_get_a_resource.yml → inventory_0_17/Templates/Should_create_a_resource.yml} +86 -172
  51. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_a_resource_with_metric.yml +296 -158
  52. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_a_resourcetype.yml +38 -29
  53. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_create_and_delete_feed.yml +42 -27
  54. data/spec/vcr_cassettes/Inventory/{Templates/Should_create_a_resource.yml → inventory_0_17/Templates/Should_create_and_get_a_resource.yml} +109 -89
  55. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_URLs.yml +20 -17
  56. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_WildFlys.yml +19 -12
  57. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_WildFlys_with_props.yml +131 -0
  58. data/spec/vcr_cassettes/Inventory/{Helpers/get_feeds.yml → inventory_0_17/Templates/Should_list_all_the_resource_types.yml} +14 -11
  59. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_children_of_WildFly.yml +315 -0
  60. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_children_of_nested_resource.yml +45 -30
  61. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_feeds.yml +16 -10
  62. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml +60 -0
  63. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_heap_metrics_for_WildFlys.yml +935 -0
  64. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_metrics_for_WildFlys.yml +357 -0
  65. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_metrics_of_given_metric_type.yml +122 -0
  66. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_metrics_of_given_resource_type.yml +292 -0
  67. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource.yml +235 -0
  68. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource_type.yml +121 -0
  69. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_recursive_children_of_WildFly.yml +1099 -0
  70. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_relationships_of_WildFly.yml +377 -0
  71. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_resources_for_feed.yml +19 -9
  72. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_list_types_with_bad_feed.yml +10 -8
  73. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_types_with_feed.yml +164 -0
  74. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_not_find_an_unknown_resource.yml +12 -10
  75. data/spec/vcr_cassettes/Inventory/{Templates → inventory_0_17/Templates}/Should_return_config_data_of_given_nested_resource.yml +17 -11
  76. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_return_config_data_of_given_resource.yml +66 -0
  77. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_return_the_version.yml +48 -0
  78. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Get_metric_definition_by_id.yml +49 -0
  79. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Retrieve_metric_rate_points.yml +88 -0
  80. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_create_Availability_definition.yml +97 -0
  81. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_create_Counter_definition.yml +97 -0
  82. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_create_gauge_definition.yml +97 -0
  83. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_push_metric_data_to_existing_gauge.yml +48 -0
  84. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_update_tags_for_Availability_definition.yml +140 -0
  85. data/spec/vcr_cassettes/Metric_ID_with_special_characters/Should_update_tags_for_gauge_definition.yml +140 -0
  86. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Availability_metrics/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +95 -0
  87. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Availability_metrics/Should_create_and_return_Availability_using_Hash_parameter.yml +95 -0
  88. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Availability_metrics/Should_group_contiguous_values.yml +93 -0
  89. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Availability_metrics/Should_push_metric_data_to_non-existing_Availability.yml +138 -0
  90. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Availability_metrics/Should_update_tags_for_Availability_definition.yml +230 -0
  91. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_create_and_return_counter_using_Hash_parameter.yml +95 -0
  92. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_create_counter_definition_using_MetricDefinition_parameter.yml +95 -0
  93. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +230 -0
  94. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +314 -0
  95. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_push_metric_data_to_existing_counter.yml +269 -0
  96. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Counter_metrics/Should_push_metric_data_to_non-existing_counter.yml +138 -0
  97. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_create_gauge_definition_using_Hash.yml +95 -0
  98. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_create_gauge_definition_using_MetricDefinition.yml +95 -0
  99. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_push_metric_data_to_existing_gauge.yml +269 -0
  100. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_push_metric_data_to_non-existing_gauge.yml +138 -0
  101. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_return_periods.yml +93 -0
  102. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Gauge_metrics/Should_update_tags_for_gauge_definition.yml +230 -0
  103. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Mixed_metrics/Should_requests_raw_data_for_multiple_metrics.yml +330 -0
  104. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Mixed_metrics/Should_send_mixed_metric_request.yml +300 -0
  105. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Mixed_metrics/Should_send_mixed_metric_request_of_a_single_type.yml +273 -0
  106. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/No_Tenant/Should_fail.yml +48 -0
  107. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Simple/Should_be_Cool.yml +48 -0
  108. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Status/Should_return_the_version.yml +42 -0
  109. data/spec/vcr_cassettes/Metrics/metrics_0_16_0/Templates/Tenants/Should_create_and_return_tenant.yml +95 -0
  110. data/spec/vcr_cassettes/{Availability_metrics → Metrics/metrics_0_8_0/Templates/Availability_metrics}/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +5 -9
  111. data/spec/vcr_cassettes/{Availability_metrics → Metrics/metrics_0_8_0/Templates/Availability_metrics}/Should_create_and_return_Availability_using_Hash_parameter.yml +5 -9
  112. data/spec/vcr_cassettes/{Availability_metrics → Metrics/metrics_0_8_0/Templates/Availability_metrics}/Should_push_metric_data_to_non-existing_Availability.yml +9 -15
  113. data/spec/vcr_cassettes/{Availability_metrics → Metrics/metrics_0_8_0/Templates/Availability_metrics}/Should_update_tags_for_Availability_definition.yml +11 -21
  114. data/spec/vcr_cassettes/{Counter_metrics → Metrics/metrics_0_8_0/Templates/Counter_metrics}/Should_create_and_return_counter_using_Hash_parameter.yml +5 -9
  115. data/spec/vcr_cassettes/{Counter_metrics → Metrics/metrics_0_8_0/Templates/Counter_metrics}/Should_create_counter_definition_using_MetricDefinition_parameter.yml +5 -9
  116. data/spec/vcr_cassettes/Metrics/metrics_0_8_0/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +200 -0
  117. data/spec/vcr_cassettes/{Counter_metrics → Metrics/metrics_0_8_0/Templates/Counter_metrics}/Should_push_metric_data_to_existing_counter.yml +16 -28
  118. data/spec/vcr_cassettes/{Counter_metrics → Metrics/metrics_0_8_0/Templates/Counter_metrics}/Should_push_metric_data_to_non-existing_counter.yml +9 -15
  119. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_create_gauge_definition_using_Hash.yml +5 -9
  120. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_create_gauge_definition_using_MetricDefinition.yml +6 -10
  121. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_push_metric_data_to_existing_gauge.yml +18 -30
  122. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_push_metric_data_to_non-existing_gauge.yml +9 -15
  123. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_return_periods.yml +6 -10
  124. data/spec/vcr_cassettes/{Gauge_metrics → Metrics/metrics_0_8_0/Templates/Gauge_metrics}/Should_update_tags_for_gauge_definition.yml +11 -21
  125. data/spec/vcr_cassettes/{Mixed_metrics → Metrics/metrics_0_8_0/Templates/Mixed_metrics}/Should_send_mixed_metric_request.yml +19 -33
  126. data/spec/vcr_cassettes/{Mixed_metrics → Metrics/metrics_0_8_0/Templates/Mixed_metrics}/Should_send_mixed_metric_request_of_a_single_type.yml +19 -31
  127. data/spec/vcr_cassettes/Metrics/metrics_0_8_0/Templates/Simple/Should_be_Cool.yml +82 -0
  128. data/spec/vcr_cassettes/Metrics/{Status.yml → metrics_0_8_0/Templates/Status/Should_return_the_version.yml} +6 -8
  129. data/spec/vcr_cassettes/{Tenants → Metrics/metrics_0_8_0/Templates/Tenants}/Should_create_and_return_tenant.yml +12 -8
  130. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Availability_metrics/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +95 -0
  131. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Availability_metrics/Should_create_and_return_Availability_using_Hash_parameter.yml +95 -0
  132. data/spec/vcr_cassettes/{Availability_metrics → Metrics/metrics_services/Templates/Availability_metrics}/Should_group_contiguous_values.yml +7 -7
  133. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Availability_metrics/Should_push_metric_data_to_non-existing_Availability.yml +138 -0
  134. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Availability_metrics/Should_update_tags_for_Availability_definition.yml +230 -0
  135. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Counter_metrics/Should_create_and_return_counter_using_Hash_parameter.yml +95 -0
  136. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Counter_metrics/Should_create_counter_definition_using_MetricDefinition_parameter.yml +95 -0
  137. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +230 -0
  138. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +314 -0
  139. data/spec/vcr_cassettes/{Counter_metrics/Should_get_metrics_with_limit_and_order.yml → Metrics/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_existing_counter.yml} +72 -61
  140. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_non-existing_counter.yml +138 -0
  141. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_Hash.yml +95 -0
  142. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_MetricDefinition.yml +95 -0
  143. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_existing_gauge.yml +269 -0
  144. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_non-existing_gauge.yml +138 -0
  145. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_return_periods.yml +93 -0
  146. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory.yml +48 -0
  147. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory_def.yml +49 -0
  148. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Gauge_metrics/Should_update_tags_for_gauge_definition.yml +230 -0
  149. data/spec/vcr_cassettes/{Mixed_metrics → Metrics/metrics_services/Templates/Mixed_metrics}/Should_requests_raw_data_for_multiple_metrics.yml +25 -25
  150. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request.yml +300 -0
  151. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request_of_a_single_type.yml +273 -0
  152. data/spec/vcr_cassettes/{No_Tenant → Metrics/metrics_services/Templates/No_Tenant}/Should_fail.yml +16 -10
  153. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Simple/Should_be_Cool.yml +48 -0
  154. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Status/Should_return_the_version.yml +42 -0
  155. data/spec/vcr_cassettes/Metrics/metrics_services/Templates/Tenants/Should_create_and_return_tenant.yml +95 -0
  156. data/spec/vcr_cassettes/{Counter_metrics → New_API_Counter_metrics}/Should_get_metrics_as_bucketed_results.yml +73 -33
  157. data/spec/vcr_cassettes/New_API_Mixed_metrics/Should_send_mixed_metric_request.yml +300 -0
  158. data/spec/vcr_cassettes/Operation/Helpers/get_feed.yml +17 -11
  159. data/spec/vcr_cassettes/Operation/Helpers/get_tenant.yml +13 -11
  160. data/spec/vcr_cassettes/Operation/Operation/Add_JDBC_driver_should_add_the_driver.json +2 -2
  161. data/spec/vcr_cassettes/Operation/Operation/Add_datasource_should_be_doable.json +2 -2
  162. data/spec/vcr_cassettes/Operation/Operation/Add_deployment_should_be_doable.json +2 -2
  163. data/spec/vcr_cassettes/Operation/Operation/Redeploy_can_be_run_multiple_times_in_parallel.json +4 -4
  164. data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_be_performed_and_eventually_respond_with_success.json +2 -2
  165. data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_not_be_performed_if_resource_path_is_wrong.json +2 -2
  166. data/spec/vcr_cassettes/Operation/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +2 -2
  167. data/spec/vcr_cassettes/Operation/Operation/Remove_datasource_should_be_performed_and_eventually_respond_with_success.json +2 -2
  168. data/spec/vcr_cassettes/Operation/Operation/Remove_deployment_should_be_performed_and_eventually_respond_with_success.json +2 -2
  169. data/spec/vcr_cassettes/Operation/Operation/Undeploy_should_be_performed_and_eventually_respond_with_success.json +2 -2
  170. data/spec/vcr_cassettes/Operation/Websocket_connection/should_bail_with_hash_property_error_because_no_callback_at_all.json +9 -0
  171. data/spec/vcr_cassettes/Operation/Websocket_connection/should_bail_with_hash_property_error_because_no_error-callback_.json +9 -0
  172. data/spec/vcr_cassettes/Operation/Websocket_connection/should_run_into_error_callback_because_bad_hash_parameters.json +13 -0
  173. metadata +259 -139
  174. data/spec/vcr_cassettes/Gauge_metrics/Platform_mem.yml +0 -44
  175. data/spec/vcr_cassettes/Gauge_metrics/Platform_mem_def.yml +0 -45
  176. data/spec/vcr_cassettes/Inventory/Helpers/generate_some_events_for_websocket.yml +0 -4446
  177. data/spec/vcr_cassettes/Inventory/Templates/Client_should_listen_on_various_inventory_events.json +0 -47
  178. data/spec/vcr_cassettes/Inventory/Templates/Helpers/generate_some_events_for_websocket.yml +0 -542
  179. data/spec/vcr_cassettes/Inventory/Templates/Should_List_datasources_with_no_props.yml +0 -174
  180. data/spec/vcr_cassettes/Inventory/Templates/Should_list_WildFlys_with_props.yml +0 -115
  181. data/spec/vcr_cassettes/Inventory/Templates/Should_list_all_the_resource_types.yml +0 -126
  182. data/spec/vcr_cassettes/Inventory/Templates/Should_list_children_of_WildFly.yml +0 -308
  183. data/spec/vcr_cassettes/Inventory/Templates/Should_list_heap_metrics_for_WildFlys.yml +0 -712
  184. data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_for_WildFlys.yml +0 -278
  185. data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_metric_type.yml +0 -530
  186. data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_resource_type.yml +0 -278
  187. data/spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource.yml +0 -185
  188. data/spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource_type.yml +0 -126
  189. data/spec/vcr_cassettes/Inventory/Templates/Should_list_recursive_children_of_WildFly.yml +0 -2369
  190. data/spec/vcr_cassettes/Inventory/Templates/Should_list_relationships_of_WildFly.yml +0 -415
  191. data/spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_feed.yml +0 -124
  192. data/spec/vcr_cassettes/Inventory/Templates/Should_return_config_data_of_given_resource.yml +0 -57
  193. data/spec/vcr_cassettes/Simple/Should_be_Cool.yml +0 -208
  194. data/spec/vcr_cassettes/Tenants/Should_Get_Tenant_For_Implicit_Credentials.yml +0 -50
@@ -4,28 +4,46 @@ require 'securerandom'
4
4
 
5
5
  module Hawkular::Inventory::RSpec
6
6
  ENTRYPOINT = 'http://localhost:8080/hawkular/inventory'
7
+ DEFAULT_VERSION = '0.17.2.Final'
8
+ VERSION = ENV['INVENTORY_VERSION'] || DEFAULT_VERSION
9
+
7
10
  include Hawkular::Inventory
8
- describe 'Inventory/Tenants', vcr: { decode_compressed_response: true } do
11
+ describe 'Inventory/Tenants', vcr: { decode_compressed_response: true, record: :new_episodes } do
9
12
  it 'Should Get Tenant For Explicit Credentials' do
10
13
  # get the client for given endpoint for given credentials
11
14
  creds = { username: 'jdoe', password: 'password' }
12
- mock_inventory_client
15
+ mock_inventory_client(VERSION) unless ENV['VCR_UPDATE'] == '1'
16
+ options = { tenant: 'hawkular' }
13
17
  client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT,
14
- credentials: creds)
15
-
18
+ credentials: creds,
19
+ options: options)
16
20
  tenant = client.get_tenant(creds)
17
-
18
- expect(tenant).to eq('28026b36-8fe4-4332-84c8-524e173a68bf')
21
+ expect(tenant).to eq('hawkular')
19
22
  end
20
23
 
21
24
  it 'Should Get Tenant For Implicit Credentials' do
22
25
  creds = { username: 'jdoe', password: 'password' }
23
- mock_inventory_client
24
- client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT, credentials: creds)
25
-
26
- tenant = client.get_tenant
26
+ mock_inventory_client(VERSION) unless ENV['VCR_UPDATE'] == '1'
27
+ options = { tenant: 'hawkular' }
28
+ client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT,
29
+ credentials: creds,
30
+ options: options)
31
+ tenant = client.get_tenant(creds)
32
+ expect(tenant).to eq('hawkular')
33
+ end
34
+ end
27
35
 
28
- expect(tenant).to eq('28026b36-8fe4-4332-84c8-524e173a68bf')
36
+ describe 'Inventory Connection' do
37
+ it 'Should err on bad credentials' do
38
+ VCR.use_cassette('Inventory/Connection/Should err on bad credentials') do
39
+ @creds = {
40
+ username: '-XX-X-jdoe-X',
41
+ password: 'password'
42
+ }
43
+ expect do
44
+ Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT, credentials: @creds)
45
+ end.to raise_error(Hawkular::BaseClient::HawkularException, 'Unauthorized')
46
+ end
29
47
  end
30
48
  end
31
49
 
@@ -37,13 +55,30 @@ module Hawkular::Inventory::RSpec
37
55
  username: 'jdoe',
38
56
  password: 'password'
39
57
  }
40
- ::RSpec::Mocks.with_temporary_scope do
41
- mock_inventory_client
42
- @client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT, credentials: @creds)
43
- end
58
+
44
59
  options = { decode_compressed_response: true }
45
60
  options[:record] = :all if ENV['VCR_UPDATE'] == '1'
46
- VCR.use_cassette('Inventory/Helpers/get_feeds', options) do
61
+ client_options = { tenant: 'hawkular' }
62
+
63
+ if ENV['VCR_UPDATE'] == '1'
64
+ VCR.turn_off!(ignore_cassettes: true)
65
+ WebMock.allow_net_connect!
66
+ @client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT,
67
+ credentials: @creds,
68
+ options: client_options)
69
+ WebMock.disable_net_connect!
70
+ VCR.turn_on!
71
+ else
72
+ ::RSpec::Mocks.with_temporary_scope do
73
+ mock_inventory_client(VERSION) unless ENV['VCR_UPDATE'] == '1'
74
+ @client = Hawkular::Inventory::InventoryClient.create(entrypoint: ENTRYPOINT,
75
+ credentials: @creds,
76
+ options: client_options)
77
+ end
78
+ end
79
+
80
+ x, y, = @client.version
81
+ VCR.use_cassette("Inventory/inventory_#{x}_#{y}/Helpers/get_feeds", options) do
47
82
  feeds = @client.list_feeds
48
83
  @state = {
49
84
  feed_uuid: feeds[0]
@@ -51,10 +86,13 @@ module Hawkular::Inventory::RSpec
51
86
  end
52
87
 
53
88
  # create 1 URL resource and its metrics
54
- VCR.use_cassette('Inventory/Helpers/create_url', options) do
89
+ VCR.use_cassette("Inventory/inventory_#{x}_#{y}/Helpers/create_url", options) do
90
+ headers = {}
91
+ headers[:'Hawkular-Tenant'] = 'hawkular'
55
92
  rest_client = RestClient::Resource.new('http://localhost:8080/hawkular/api/urls',
56
93
  user: @creds[:username],
57
- password: @creds[:password]
94
+ password: @creds[:password],
95
+ headers: headers
58
96
  )
59
97
  url_json = {
60
98
  url: URL_RESOURCE
@@ -73,7 +111,8 @@ module Hawkular::Inventory::RSpec
73
111
 
74
112
  after(:all) do
75
113
  require 'fileutils'
76
- FileUtils.rm_rf "#{VCR.configuration.cassette_library_dir}/Inventory/tmp"
114
+ x, y, = @client.version
115
+ FileUtils.rm_rf "#{VCR.configuration.cassette_library_dir}/Inventory/inventory#{x}_#{y}/tmp"
77
116
  end
78
117
 
79
118
  let(:cassette_name) do |example|
@@ -90,13 +129,14 @@ module Hawkular::Inventory::RSpec
90
129
  end
91
130
 
92
131
  around(:each) do |example|
93
- record('Inventory', @state, cassette_name, example: example)
132
+ major, minor, = @client.version
133
+ record("Inventory/inventory_#{major}_#{minor}", @state, cassette_name, example: example)
94
134
  end
95
135
 
96
136
  it 'Should list feeds' do
97
137
  feeds = @client.list_feeds
98
138
 
99
- expect(feeds.size).to be(1)
139
+ expect(feeds.size).to be > 0
100
140
  end
101
141
 
102
142
  it 'Should list resources for feed' do
@@ -112,10 +152,12 @@ module Hawkular::Inventory::RSpec
112
152
  creds = { username: @state[:super_secret_username],
113
153
  password: @state[:super_secret_password] }
114
154
  tori_url = 'https://hawkular.torii.gva.redhat.com/hawkular/inventory'
115
- mock_inventory_client
155
+ mock_inventory_client(VERSION)
116
156
  client = Hawkular::Inventory::InventoryClient.create(entrypoint: tori_url,
117
157
  credentials: creds,
118
- options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE })
158
+ options: { tenant: 'hawkular',
159
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE
160
+ })
119
161
  feeds = client.list_feeds
120
162
 
121
163
  expect(feeds.size).to be(1)
@@ -123,13 +165,14 @@ module Hawkular::Inventory::RSpec
123
165
 
124
166
  it 'Should list all the resource types' do
125
167
  types = @client.list_resource_types
126
- expect(types.size).to be(19)
168
+ # new API returns only the feedless types here, while the old one returned all the types
169
+ expect(types.size).to be > 0
127
170
  end
128
171
 
129
172
  it 'Should list types with feed' do
130
173
  types = @client.list_resource_types(feed_id)
131
174
 
132
- expect(types.size).to be(18)
175
+ expect(types.size).to be >= 18
133
176
  end
134
177
 
135
178
  it 'Should list types with bad feed' do
@@ -144,8 +187,6 @@ module Hawkular::Inventory::RSpec
144
187
  resources = @client.list_resources_for_type(wildfly_type.to_s)
145
188
 
146
189
  expect(resources.size).to be(1)
147
- wf = resources.first
148
- expect(wf.properties.size).to be(0)
149
190
  end
150
191
 
151
192
  it 'Should list WildFlys with props' do
@@ -160,9 +201,7 @@ module Hawkular::Inventory::RSpec
160
201
  type_path = CanonicalPath.new(feed_id: feed_id, resource_type_id: hawk_escape_id('Datasource'))
161
202
  resources = @client.list_resources_for_type(type_path.to_s, fetch_properties: true)
162
203
 
163
- expect(resources.size).to be(2)
164
- wf = resources.first
165
- expect(wf.properties.size).to be(0) # They have no props
204
+ expect(resources.size).to be > 0
166
205
  end
167
206
 
168
207
  it 'Should list URLs' do
@@ -192,7 +231,7 @@ module Hawkular::Inventory::RSpec
192
231
 
193
232
  children = @client.list_child_resources(wild_fly.path)
194
233
 
195
- expect(children.size).to be(22)
234
+ expect(children.size).to be > 10
196
235
  end
197
236
 
198
237
  it 'Should list children of nested resource' do
@@ -200,8 +239,8 @@ module Hawkular::Inventory::RSpec
200
239
  datasource_res_id = hawk_escape_id 'Local~/subsystem=datasources/data-source=ExampleDS'
201
240
  resource_path = CanonicalPath.new(feed_id: feed_id, resource_ids: [wildfly_res_id, datasource_res_id])
202
241
  datasource = @client.get_resource(resource_path.to_s)
203
- expect(datasource.name).to eq('ExampleDS')
204
242
 
243
+ expect(datasource.name).to eq('Datasource [ExampleDS]')
205
244
  children = @client.list_child_resources(datasource.path)
206
245
 
207
246
  expect(children.size).to be(0)
@@ -213,7 +252,7 @@ module Hawkular::Inventory::RSpec
213
252
 
214
253
  children = @client.list_child_resources(wild_fly.path, recursive: true)
215
254
 
216
- expect(children.size).to be(251)
255
+ expect(children.size).to be > 40
217
256
  end
218
257
 
219
258
  it 'Should list relationships of WildFly' do
@@ -222,7 +261,8 @@ module Hawkular::Inventory::RSpec
222
261
 
223
262
  rels = @client.list_relationships(wild_fly.path)
224
263
 
225
- expect(rels.size).to be(61)
264
+ expect(rels.size).to be > 40
265
+ expect(rels[0].to_h['source']).not_to be_empty
226
266
  end
227
267
 
228
268
  it 'Should list heap metrics for WildFlys' do
@@ -243,7 +283,7 @@ module Hawkular::Inventory::RSpec
243
283
  type_path = CanonicalPath.new(feed_id: feed_id, metric_type_id: hawk_escape_id('Total Space'))
244
284
  metrics = @client.list_metrics_for_metric_type(type_path)
245
285
 
246
- expect(metrics.size).to be(7)
286
+ expect(metrics.size).to be >= 4
247
287
  end
248
288
 
249
289
  it 'Should list metrics of given resource type' do
@@ -257,7 +297,7 @@ module Hawkular::Inventory::RSpec
257
297
  config = @client.get_config_data_for_resource(resource_path)
258
298
 
259
299
  expect(config['value']['Server State']).to eq('running')
260
- expect(config['value']['Product Name']).to eq('Hawkular')
300
+ # expect(config['value']['Product Name']).to eq('Hawkular')
261
301
  end
262
302
 
263
303
  it 'Should return config data of given nested resource' do
@@ -279,6 +319,11 @@ module Hawkular::Inventory::RSpec
279
319
  expect(operation_definitions).to include('Reload')
280
320
  expect(operation_definitions).to include('Shutdown')
281
321
  expect(operation_definitions).to include('Deploy')
322
+ shutdown_def = operation_definitions.fetch 'Shutdown'
323
+ expect(shutdown_def.params).to include('timeout')
324
+ expect(shutdown_def.params).to include('restart')
325
+ restart_param = shutdown_def.params.fetch 'restart'
326
+ expect(restart_param['type']).to eq('bool')
282
327
  end
283
328
 
284
329
  it 'Should list operation definitions of given resource' do
@@ -438,7 +483,8 @@ module Hawkular::Inventory::RSpec
438
483
  reverse_substitution: true
439
484
  }
440
485
  vcr_options[:record] = :all if ENV['VCR_UPDATE'] == '1'
441
- cassette_name = 'Inventory/Templates/Client_should_listen_on_various_inventory_events'
486
+ x, y, = @client.version
487
+ cassette_name = "Inventory/inventory_#{x}_#{y}/Templates/Client_should_listen_on_various_inventory_events"
442
488
  WebSocketVCR.use_cassette(cassette_name, vcr_options) do
443
489
  id_1 = uuid_prefix + '-r126'
444
490
  id_2 = uuid_prefix + '-r127'
@@ -455,7 +501,9 @@ module Hawkular::Inventory::RSpec
455
501
  end
456
502
 
457
503
  new_resource_types_events = {}
458
- resource_type_closable = @client.events('resourcetype') do |resource_type|
504
+ # another breaking change in the new inventory api
505
+ interest = 'resourceType'
506
+ resource_type_closable = @client.events(interest) do |resource_type|
459
507
  new_resource_types_events[resource_type.id] = resource_type
460
508
  end
461
509
 
@@ -468,7 +516,7 @@ module Hawkular::Inventory::RSpec
468
516
  resource_type_id = uuid_prefix + '-rt-123'
469
517
  resource_type_name = 'ResourceType'
470
518
 
471
- record('Inventory',
519
+ record("Inventory/inventory_#{x}_#{y}",
472
520
  { uuid_prefix: uuid_prefix },
473
521
  'Helpers/generate_some_events_for_websocket') do
474
522
  @client.create_feed new_feed_id
@@ -506,10 +554,9 @@ module Hawkular::Inventory::RSpec
506
554
  end
507
555
  end
508
556
 
509
- # TODO: enable when inventory supports it
510
- # it 'Should return the version' do
511
- # data = @client.get_version_and_status
512
- # expect(data).not_to be_nil
513
- # end
557
+ it 'Should return the version' do
558
+ data = @client.fetch_version_and_status
559
+ expect(data).not_to be_nil
560
+ end
514
561
  end
515
562
  end
@@ -6,492 +6,646 @@ require 'securerandom'
6
6
 
7
7
  # time constants
8
8
  t4h = 4 * 60 * 60 * 1000
9
+ v16_version_string = '0.16.0.Final'
9
10
 
10
- describe 'Simple', :vcr do
11
- it 'Should be Cool' do
12
- Net::HTTP.get_response(URI('http://localhost:8080/'))
13
- end
14
- end
11
+ # test contexts
12
+ v8_context = :metrics_0_8_0
13
+ services_context = :metrics_services
14
+ v16_context = :metrics_0_16_0
15
15
 
16
- describe 'Tenants', vcr: { match_requests_on: [:uri, :method], record: :none } do
17
- before(:all) do
18
- setup_client
16
+ [v8_context, services_context, v16_context].each do |metrics_context|
17
+ if ENV['SKIP_V8_METRICS'] == '1' && metrics_context == v8_context
18
+ puts 'skipping v8 metrics'
19
+ next
19
20
  end
20
-
21
- it 'Should create and return tenant' do
22
- tenant = SecureRandom.uuid
23
- @client.tenants.create(tenant)
24
- created = @client.tenants.query.select { |t| t.id == tenant }
25
- expect(created).not_to be nil
21
+ if ENV['SKIP_SERVICES_METRICS'] == '1' && metrics_context == services_context
22
+ puts 'skipping services metrics'
23
+ next
26
24
  end
27
- end
28
-
29
- describe 'No_Tenant' do
30
- it 'Should fail' do
31
- id = SecureRandom.uuid
32
25
 
33
- VCR.use_cassette('No_Tenant/Should fail', erb: { id: id }, record: :none) do
34
- setup_client
35
-
36
- begin
37
- @client.counters.push_data(id, value: 4)
38
- rescue # rubocop:disable Lint/HandleExceptions
39
- # This is good
26
+ describe "#{metrics_context}" do
27
+ let(:cassette_name) do |example|
28
+ if example.respond_to?(:example_group) && !example.example_group.description.start_with?(metrics_context.to_s)
29
+ example.example_group.description + '/'
40
30
  else
41
- fail 'The call should have failed due to missing tenant'
42
- end
31
+ ''
32
+ end + example.description
43
33
  end
44
- end
45
- end
46
34
 
47
- describe 'Mixed metrics' do
48
- before(:all) do
49
- setup_client_new_tenant
50
- end
35
+ around(:each) do |example|
36
+ run_for = example.metadata[:run_for]
37
+ if run_for.nil? || run_for.empty? || run_for.include?(metrics_context)
38
+ @random_id = SecureRandom.uuid
39
+ if example.metadata[:skip_auto_vcr]
40
+ example.run
41
+ else
42
+ record("Metrics/#{metrics_context}", { id: @random_id }, cassette_name, example: example)
43
+ end
44
+ end
45
+ end
51
46
 
52
- it 'Should send mixed metric request of a single type' do
53
- id = SecureRandom.uuid
47
+ after(:all) do
48
+ require 'fileutils'
49
+ FileUtils.rm_rf "#{VCR.configuration.cassette_library_dir}/Metrics/#{metrics_context}/tmp"
50
+ end
54
51
 
55
- VCR.use_cassette('Mixed_metrics/Should send mixed metric request of a single type',
56
- erb: { id: id }, record: :none
57
- ) do
58
- @client.push_data(counters: [{ id: id, data: [{ value: 1 }] }])
59
- data = @client.counters.get_data(id)
60
- expect(data.size).to be 1
52
+ describe 'Simple' do
53
+ it 'Should be Cool' do
54
+ url = metrics_context == v8_context ? config['url_v8'] : config['url']
55
+ Net::HTTP.get_response(URI(url))
56
+ end
57
+ end
61
58
 
62
- @client.push_data(availabilities: [{ id: id, data: [{ value: 'down' }] }])
63
- data = @client.avail.get_data(id)
64
- expect(data.size).to be 1
59
+ describe 'Tenants', run_for: [v8_context, services_context, v16_context] do
60
+ before(:all) do
61
+ if metrics_context == v8_context
62
+ setup_v8_client
63
+ else
64
+ metrics_context == v16_context ? setup_client(mocked_version: v16_version_string) : setup_client
65
+ end
66
+ end
65
67
 
66
- @client.push_data(gauges: [{ id: id, data: [{ value: 1.1 }] }])
67
- data = @client.gauges.get_data(id)
68
- expect(data.size).to be 1
69
- end
70
- end
71
- # end
72
-
73
- it 'Should requests raw data for multiple metrics' do
74
- @client = setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test')
75
- ids = [SecureRandom.uuid, SecureRandom.uuid, SecureRandom.uuid]
76
- VCR.use_cassette('Mixed_metrics/Should requests raw data for multiple metrics',
77
- erb: { ids: ids }, record: :none
78
- ) do
79
- expect(@client.counters.raw_data(ids).size).to be 0
80
- expect(@client.gauges.raw_data(ids).size).to be 0
81
- expect(@client.avail.raw_data(ids).size).to be 0
82
-
83
- @client.push_data(
84
- counters: [
85
- { id: ids[0], data: [{ value: 1 }] },
86
- { id: ids[1], data: [{ value: 2 }] },
87
- { id: ids[2], data: [{ value: 3 }] }
88
- ],
89
- availabilities: [
90
- { id: ids[0], data: [{ value: 'up' }] },
91
- { id: ids[1], data: [{ value: 'down' }] },
92
- { id: ids[2], data: [{ value: 'up' }] }
93
- ],
94
- gauges: [
95
- { id: ids[0], data: [{ value: 1.1 }] },
96
- { id: ids[1], data: [{ value: 2.2 }] },
97
- { id: ids[2], data: [{ value: 3.3 }] }
98
- ]
99
- )
100
-
101
- counter_metrics = @client.counters.raw_data(ids)
102
- gauges_metrics = @client.gauges.raw_data(ids)
103
- availability_metrics = @client.avail.raw_data(ids)
104
-
105
- expect(counter_metrics.size).to be 3
106
- expect(counter_metrics).to include(
107
- { 'id' => ids[0], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 1 }] },
108
- { 'id' => ids[1], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 2 }] },
109
- { 'id' => ids[2], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 3 }] }
110
- )
111
-
112
- expect(gauges_metrics.size).to be 3
113
- expect(gauges_metrics).to include(
114
- { 'id' => ids[0], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 1.1 }] },
115
- { 'id' => ids[1], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 2.2 }] },
116
- { 'id' => ids[2], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 3.3 }] }
117
- )
118
-
119
- expect(availability_metrics.size).to be 3
120
- expect(availability_metrics).to include(
121
- { 'id' => ids[0], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'up' }] },
122
- { 'id' => ids[1], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'down' }] },
123
- { 'id' => ids[2], 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'up' }] }
124
- )
68
+ it 'Should create and return tenant' do
69
+ tenant = @random_id
70
+ @client.tenants.create(tenant)
71
+ created = @client.tenants.query.select { |t| t.id == tenant }
72
+ expect(created).not_to be nil
73
+ end
125
74
  end
126
- end
127
75
 
128
- it 'Should send mixed metric request' do
129
- id = SecureRandom.uuid
130
- VCR.use_cassette('Mixed_metrics/Should send mixed metric request',
131
- erb: { id: id }, record: :none
132
- ) do
133
- expect(@client.counters.get_data(id).size).to be 0
134
- expect(@client.gauges.get_data(id).size).to be 0
135
- expect(@client.avail.get_data(id).size).to be 0
136
-
137
- @client.push_data(
138
- counters: [{ id: id, data: [{ value: 1 }] }],
139
- availabilities: [{ id: id, data: [{ value: 'down' }] }],
140
- gauges: [{ id: id, data: [{ value: 1.1 }] }]
141
- )
142
-
143
- expect(@client.counters.get_data(id).size).to be 1
144
- expect(@client.gauges.get_data(id).size).to be 1
145
- expect(@client.avail.get_data(id).size).to be 1
76
+ describe 'No Tenant', run_for: [services_context, v16_context] do
77
+ it 'Should fail' do
78
+ setup_client_without_tenant
79
+ begin
80
+ @client.counters.push_data(@random_id, value: 4)
81
+ rescue # rubocop:disable Lint/HandleExceptions
82
+ # This is good
83
+ else
84
+ fail 'The call should have failed due to missing tenant'
85
+ end
86
+ end
146
87
  end
147
- end
148
- end
149
88
 
150
- describe 'Counter metrics' do
151
- before(:all) do
152
- setup_client_new_tenant
153
- end
89
+ describe 'Mixed metrics', run_for: [v8_context, services_context, v16_context] do
90
+ before(:all) do
91
+ if metrics_context == v8_context
92
+ setup_v8_client tenant: 'vcr-test-tenant-123'
93
+ else
94
+ if metrics_context == v16_context
95
+ setup_client_new_tenant(mocked_version: v16_version_string)
96
+ else
97
+ setup_client_new_tenant
98
+ end
99
+ end
100
+ end
154
101
 
155
- it 'Should create and return counter using Hash parameter' do
156
- id = SecureRandom.uuid
157
- VCR.use_cassette('Counter_metrics/Should create and return counter using Hash parameter',
158
- erb: { id: id }, record: :none
159
- ) do
160
- create_metric_using_hash @client.counters, id, @tenant
161
- end
162
- end
102
+ it 'Should requests raw data for multiple metrics', :skip_auto_vcr, run_for: [services_context, v16_context] do
103
+ id1 = SecureRandom.uuid
104
+ id2 = SecureRandom.uuid
105
+ id3 = SecureRandom.uuid
106
+
107
+ ids = [id1, id2, id3]
108
+ bindings = { id1: id1, id2: id2, id3: id3 }
109
+ example = proc do
110
+ if (metrics_context == v16_context)
111
+ @client = setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test',
112
+ mocked_version: v16_version_string)
113
+ else
114
+ @client = setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test')
115
+ end
116
+
117
+ expect(@client.counters.raw_data(ids).size).to be 0
118
+ expect(@client.gauges.raw_data(ids).size).to be 0
119
+ expect(@client.avail.raw_data(ids).size).to be 0
120
+
121
+ @client.push_data(
122
+ counters: [
123
+ { id: id1, data: [{ value: 1 }] },
124
+ { id: id2, data: [{ value: 2 }] },
125
+ { id: id3, data: [{ value: 3 }] }
126
+ ],
127
+ availabilities: [
128
+ { id: id1, data: [{ value: 'up' }] },
129
+ { id: id2, data: [{ value: 'down' }] },
130
+ { id: id3, data: [{ value: 'up' }] }
131
+ ],
132
+ gauges: [
133
+ { id: id1, data: [{ value: 1.1 }] },
134
+ { id: id2, data: [{ value: 2.2 }] },
135
+ { id: id3, data: [{ value: 3.3 }] }
136
+ ]
137
+ )
138
+
139
+ c_metrics = @client.counters.raw_data(ids)
140
+ g_metrics = @client.gauges.raw_data(ids)
141
+ a_metrics = @client.avail.raw_data(ids)
142
+
143
+ expect(c_metrics.size).to be 3
144
+ expect(c_metrics).to include(
145
+ { 'id' => id1, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 1 }] },
146
+ { 'id' => id2, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 2 }] },
147
+ { 'id' => id3, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 3 }] }
148
+ )
149
+
150
+ expect(g_metrics.size).to be 3
151
+ expect(g_metrics).to include(
152
+ { 'id' => id1, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 1.1 }] },
153
+ { 'id' => id2, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 2.2 }] },
154
+ { 'id' => id3, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 3.3 }] }
155
+ )
156
+
157
+ expect(a_metrics.size).to be 3
158
+ expect(a_metrics).to include(
159
+ { 'id' => id1, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'up' }] },
160
+ { 'id' => id2, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'down' }] },
161
+ { 'id' => id3, 'data' => [{ 'timestamp' => a_kind_of(Integer), 'value' => 'up' }] }
162
+ )
163
+ end
164
+
165
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
166
+ end
163
167
 
164
- it 'Should create counter definition using MetricDefinition parameter' do
165
- id = SecureRandom.uuid
166
- VCR.use_cassette(
167
- 'Counter_metrics/Should create counter definition using MetricDefinition parameter',
168
- erb: { id: id }, record: :none
169
- ) do
170
- create_metric_using_md @client.counters, id
171
- end
172
- end
168
+ it 'Should send mixed metric request of a single type' do
169
+ @client.push_data(counters: [{ id: @random_id, data: [{ value: 1 }] }])
170
+ data = @client.counters.get_data(@random_id)
171
+ expect(data.size).to be 1
173
172
 
174
- it 'Should push metric data to existing counter' do
175
- id = SecureRandom.uuid
176
- now = @client.now
177
-
178
- VCR.use_cassette('Counter_metrics/Should push metric data to existing counter',
179
- erb: { id: id, ends: now - t4h, starts: now - (2 * t4h),
180
- minus20: now - 20, minus30: now - 30, minus10: now - 10,
181
- now: now }, record: :none
182
- ) do
183
- # create counter
184
- @client.counters.create(id: id)
185
-
186
- # push 3 values with timestamps
187
- @client.counters.push_data(id, [{ value: 1, timestamp: now - 30 },
188
- { value: 2, timestamp: now - 20 },
189
- { value: 3, timestamp: now - 10 }])
190
-
191
- data = @client.counters.get_data(id)
192
- expect(data.size).to be 3
193
-
194
- # push one value without timestamp (which means now)
195
- @client.counters.push_data(id, value: 4)
196
- data = @client.counters.get_data(id)
197
- expect(data.size).to be 4
198
-
199
- # retrieve values from past
200
- data = @client.counters.get_data(id, starts: now - (2 * t4h), ends: now - t4h)
201
- expect(data.empty?).to be true
202
- end
203
- end
173
+ @client.push_data(availabilities: [{ id: @random_id, data: [{ value: 'down' }] }])
174
+ data = @client.avail.get_data(@random_id)
175
+ expect(data.size).to be 1
204
176
 
205
- it 'Should get metrics with limit and order' do
206
- @client = setup_client(username: 'jdoe', password: 'password')
207
- id = SecureRandom.uuid
208
- now = 1_462_872_284_000
209
-
210
- VCR.use_cassette('Counter_metrics/Should get metrics with limit and order',
211
- decode_compressed_response: true,
212
- erb: { id: id, ends: now - t4h, starts: now - (2 * t4h),
213
- minus10: now - 10, minus20: now - 20, minus30: now - 30,
214
- now: now }, record: :none
215
- ) do
216
- # create counter
217
- @client.counters.create(id: id)
218
-
219
- # push 3 values with timestamps
220
- @client.counters.push_data(id, [{ value: 1, timestamp: now - 30 },
221
- { value: 2, timestamp: now - 20 },
222
- { value: 3, timestamp: now - 10 }])
223
-
224
- data = @client.counters.get_data(id)
225
- expect(data.size).to be 3
226
-
227
- # push one value without timestamp (which means now)
228
- @client.counters.push_data(id, value: 4)
229
- data = @client.counters.get_data(id)
230
- expect(data.size).to be 4
231
-
232
- # retrieve values with limit
233
- data = @client.counters.get_data(id, limit: 1, order: 'DESC')
234
- expect(data.size).to be 1
235
- expect(data.first['value']).to be 4
236
-
237
- # retrieve values from past
238
- data = @client.counters.get_data(id, starts: now - (2 * t4h), ends: now - t4h)
239
- expect(data.empty?).to be true
240
- end
241
- end
177
+ @client.push_data(gauges: [{ id: @random_id, data: [{ value: 1.1 }] }])
178
+ data = @client.gauges.get_data(@random_id)
179
+ expect(data.size).to be 1
180
+ end
242
181
 
243
- it 'Should get metrics as bucketed results' do
244
- @client = setup_client(username: 'jdoe', password: 'password')
245
- id = SecureRandom.uuid
246
- now = @client.now
247
-
248
- VCR.use_cassette('Counter_metrics/Should get metrics as bucketed results',
249
- decode_compressed_response: true,
250
- erb: { id: id, now: now }, record: :none
251
- ) do
252
- # create counter
253
- @client.counters.create(id: id)
254
-
255
- # push 10 values with timestamps
256
- @client.counters.push_data(id, [{ value: 110, timestamp: now - 110 },
257
- { value: 100, timestamp: now - 100 },
258
- { value: 90, timestamp: now - 90 },
259
- { value: 80, timestamp: now - 80 },
260
- { value: 70, timestamp: now - 70 },
261
- { value: 60, timestamp: now - 60 },
262
- { value: 50, timestamp: now - 50 },
263
- { value: 40, timestamp: now - 40 },
264
- { value: 30, timestamp: now - 30 },
265
- { value: 20, timestamp: now - 20 },
266
- { value: 10, timestamp: now - 10 }])
267
- ERR = 0.001
268
- data = @client.counters.get_data(id, starts: now - 105, ends: now - 5, buckets: 5)
269
- expect(data.size).to be 5
270
- expect(data.first['avg']).to be_within(ERR).of(95.0)
271
- expect(data.first['max']).to be_within(ERR).of(100.0)
272
- expect(data.first['samples']).to be 2
273
-
274
- data = @client.counters.get_data(id, starts: now - 105, ends: now - 5, buckets: 2)
275
- expect(data.size).to be 2
276
- expect(data.first['avg']).to be_within(ERR).of(80.0)
277
- expect(data.first['samples']).to be 5
278
-
279
- data = @client.counters.get_data(id, starts: now - 105, ends: now - 5, bucketDuration: '50ms')
280
- expect(data.size).to be 2
281
- expect(data.first['avg']).to be_within(ERR).of(80.0)
282
- end
283
- end
182
+ it 'Should send mixed metric request' do
183
+ expect(@client.counters.get_data(@random_id).size).to be 0
184
+ expect(@client.gauges.get_data(@random_id).size).to be 0
185
+ expect(@client.avail.get_data(@random_id).size).to be 0
284
186
 
285
- it 'Should push metric data to non-existing counter' do
286
- id = SecureRandom.uuid
187
+ @client.push_data(
188
+ counters: [{ id: @random_id, data: [{ value: 1 }] }],
189
+ availabilities: [{ id: @random_id, data: [{ value: 'down' }] }],
190
+ gauges: [{ id: @random_id, data: [{ value: 1.1 }] }]
191
+ )
287
192
 
288
- VCR.use_cassette('Counter_metrics/Should push metric data to non-existing counter',
289
- erb: { id: id }, record: :none
290
- ) do
291
- push_data_to_non_existing_metric @client.counters, { value: 4 }, id
193
+ expect(@client.counters.get_data(@random_id).size).to be 1
194
+ expect(@client.gauges.get_data(@random_id).size).to be 1
195
+ expect(@client.avail.get_data(@random_id).size).to be 1
196
+ end
292
197
  end
293
- end
294
- end
295
198
 
296
- describe 'Availability metrics' do
297
- before(:all) do
298
- setup_client_new_tenant
299
- end
199
+ describe 'Counter metrics' do
200
+ before(:all) do
201
+ @tenant = 'vcr-test-tenant-123'
202
+ if metrics_context == v8_context
203
+ setup_v8_client tenant: @tenant
204
+ else
205
+ if metrics_context == v16_context
206
+ setup_client_new_tenant(mocked_version: v16_version_string)
207
+ else
208
+ setup_client_new_tenant
209
+ end
210
+ end
211
+ end
300
212
 
301
- it 'Should create and return Availability using Hash parameter' do
302
- id = SecureRandom.uuid
303
- VCR.use_cassette(
304
- 'Availability_metrics/Should create and return Availability using Hash parameter',
305
- erb: { id: id }, record: :none
306
- ) do
307
- create_metric_using_hash @client.avail, id, @tenant
308
- end
309
- end
213
+ it 'Should create and return counter using Hash parameter' do
214
+ create_metric_using_hash @client.counters, @random_id, @tenant
215
+ end
310
216
 
311
- it 'Should create Availability definition using MetricDefinition parameter' do
312
- id = SecureRandom.uuid
313
- VCR.use_cassette(
314
- 'Availability_metrics/Should create Availability definition using MetricDefinition parameter',
315
- erb: { id: id }, record: :none
316
- ) do
317
- create_metric_using_md @client.avail, id
318
- end
319
- end
217
+ it 'Should create counter definition using MetricDefinition parameter' do
218
+ create_metric_using_md @client.counters, @random_id
219
+ end
220
+
221
+ it 'Should push metric data to existing counter', :skip_auto_vcr do
222
+ now = @client.now
223
+ minus10 = now - 10
224
+ minus20 = now - 20
225
+ minus30 = now - 30
226
+ minus8h = now - (2 * t4h)
227
+ minus4h = now - t4h
228
+
229
+ bindings = { id: @random_id, minus10: minus10, minus20: minus20, minus30: minus30,
230
+ minus8h: minus8h, minus4h: minus4h }
231
+ example = proc do
232
+ # create counter
233
+ @client.counters.create(id: @random_id)
234
+
235
+ # push 3 values with timestamps
236
+ @client.counters.push_data(@random_id, [{ value: 1, timestamp: minus30 },
237
+ { value: 2, timestamp: minus20 },
238
+ { value: 3, timestamp: minus10 }])
239
+
240
+ data = @client.counters.get_data(@random_id)
241
+ expect(data.size).to be 3
242
+
243
+ # push one value without timestamp (which means now)
244
+ @client.counters.push_data(@random_id, value: 4)
245
+ data = @client.counters.get_data(@random_id)
246
+ expect(data.size).to be 4
247
+
248
+ # retrieve values from past
249
+ data = @client.counters.get_data(@random_id, starts: minus8h, ends: minus4h)
250
+ expect(data.empty?).to be true
251
+ end
252
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
253
+ end
320
254
 
321
- it 'Should push metric data to non-existing Availability' do
322
- id = SecureRandom.uuid
255
+ # limit and order were introduced in 0.11.0 => skipping for 0.8.0
256
+ it 'Should get metrics with limit and order', run_for: [services_context, v16_context], skip_auto_vcr: true do
257
+ now = @client.now
258
+ minus10 = now - 10
259
+ minus20 = now - 20
260
+ minus30 = now - 30
261
+ minus8h = now - (2 * t4h)
262
+ minus4h = now - t4h
263
+ bindings = { id: @random_id, minus10: minus10, minus20: minus20, minus30: minus30,
264
+ minus8h: minus8h, minus4h: minus4h }
265
+
266
+ example = proc do
267
+ # create counter
268
+ @client.counters.create(id: @random_id)
269
+
270
+ # push 3 values with timestamps
271
+ @client.counters.push_data(@random_id, [{ value: 1, timestamp: minus30 },
272
+ { value: 2, timestamp: minus20 },
273
+ { value: 3, timestamp: minus10 }])
274
+
275
+ data = @client.counters.get_data(@random_id)
276
+ expect(data.size).to be 3
277
+
278
+ # push one value without timestamp (which means now)
279
+ @client.counters.push_data(@random_id, value: 4)
280
+ data = @client.counters.get_data(@random_id)
281
+ expect(data.size).to be 4
282
+
283
+ # retrieve values with limit
284
+ data = @client.counters.get_data(@random_id, limit: 1, order: 'DESC')
285
+ expect(data.size).to be 1
286
+ expect(data.first['value']).to be 4
287
+
288
+ # retrieve values from past
289
+ data = @client.counters.get_data(@random_id, starts: minus8h, ends: minus4h)
290
+ expect(data.empty?).to be true
291
+ end
292
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
293
+ end
294
+
295
+ it 'Should get metrics as bucketed results', :skip_auto_vcr do
296
+ now = @client.now
297
+ minus5 = now - 5
298
+ minus10 = now - 10
299
+ minus20 = now - 20
300
+ minus30 = now - 30
301
+ minus40 = now - 40
302
+ minus50 = now - 50
303
+ minus60 = now - 60
304
+ minus70 = now - 70
305
+ minus80 = now - 80
306
+ minus90 = now - 90
307
+ minus100 = now - 100
308
+ minus105 = now - 105
309
+ minus110 = now - 110
310
+ bindings = { id: @random_id, minus5: minus5, minus10: minus10, minus20: minus20, minus30: minus30,
311
+ minus40: minus40, minus50: minus50, minus60: minus60, minus70: minus70, minus80: minus80,
312
+ minus90: minus90, minus100: minus100, minus105: minus105, minus110: minus110 }
313
+ example = proc do
314
+ # create counter
315
+ @client.counters.create(id: @random_id)
316
+
317
+ # push 10 values with timestamps
318
+ @client.counters.push_data(@random_id, [{ value: 110, timestamp: minus110 },
319
+ { value: 100, timestamp: minus100 },
320
+ { value: 90, timestamp: minus90 },
321
+ { value: 80, timestamp: minus80 },
322
+ { value: 70, timestamp: minus70 },
323
+ { value: 60, timestamp: minus60 },
324
+ { value: 50, timestamp: minus50 },
325
+ { value: 40, timestamp: minus40 },
326
+ { value: 30, timestamp: minus30 },
327
+ { value: 20, timestamp: minus20 },
328
+ { value: 10, timestamp: minus10 }])
329
+ err = 0.001
330
+ data = @client.counters.get_data(@random_id, starts: minus105, ends: minus5, buckets: 5)
331
+ expect(data.size).to be 5
332
+ expect(data.first['avg']).to be_within(err).of(95.0)
333
+ expect(data.first['max']).to be_within(err).of(100.0)
334
+ expect(data.first['samples']).to be 2
335
+
336
+ data = @client.counters.get_data(@random_id, starts: minus105, ends: minus5, buckets: 2)
337
+ expect(data.size).to be 2
338
+ expect(data.first['avg']).to be_within(err).of(80.0)
339
+ expect(data.first['samples']).to be 5
340
+
341
+ data = @client.counters.get_data(@random_id, starts: minus105, ends: minus5, bucketDuration: '50ms')
342
+ expect(data.size).to be 2
343
+ expect(data.first['avg']).to be_within(err).of(80.0)
344
+ end
345
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
346
+ end
323
347
 
324
- VCR.use_cassette('Availability_metrics/Should push metric data to non-existing Availability',
325
- erb: { id: id }, record: :none
326
- ) do
327
- push_data_to_non_existing_metric @client.avail, { value: 'UP' }, id
348
+ it 'Should push metric data to non-existing counter' do
349
+ push_data_to_non_existing_metric @client.counters, { value: 4 }, @random_id
350
+ end
328
351
  end
329
- end
330
352
 
331
- it 'Should update tags for Availability definition' do
332
- id = SecureRandom.uuid
353
+ describe 'Availability metrics' do
354
+ before(:all) do
355
+ @tenant = 'vcr-test-tenant-123'
356
+ if metrics_context == v8_context
357
+ setup_v8_client tenant: @tenant
358
+ else
359
+ if metrics_context == v16_context
360
+ setup_client_new_tenant(mocked_version: v16_version_string)
361
+ else
362
+ setup_client_new_tenant
363
+ end
364
+ end
365
+ end
366
+
367
+ it 'Should create and return Availability using Hash parameter' do
368
+ create_metric_using_hash @client.avail, @random_id, @tenant
369
+ end
370
+
371
+ it 'Should create Availability definition using MetricDefinition parameter' do
372
+ create_metric_using_md @client.avail, @random_id
373
+ end
333
374
 
334
- VCR.use_cassette('Availability_metrics/Should update tags for Availability definition',
335
- erb: { id: id }, record: :none
336
- ) do
337
- update_metric_by_tags @client.avail, id
375
+ it 'Should push metric data to non-existing Availability' do
376
+ push_data_to_non_existing_metric @client.avail, { value: 'UP' }, @random_id
377
+ end
378
+
379
+ it 'Should update tags for Availability definition' do
380
+ update_metric_by_tags @client.avail, @random_id
381
+ end
382
+
383
+ it 'Should raise ArgumentError, availability does not accept percentiles param' do
384
+ expect { @client.avail.get_data(@random_id, percentiles: 50) }.to raise_error(ArgumentError)
385
+ end
386
+
387
+ it 'Should group contiguous values', :skip_auto_vcr, run_for: [services_context, v16_context] do
388
+ now = @client.now
389
+ minus10 = now - 10
390
+ minus20 = now - 20
391
+ minus30 = now - 30
392
+ minus40 = now - 40
393
+ minus50 = now - 50
394
+ bindings = { id: @random_id, minus10: minus10, minus20: minus20, minus30: minus30, minus40: minus40,
395
+ minus50: minus50, now: now }
396
+ example = proc do
397
+ if (metrics_context == v16_context)
398
+ @client = setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test',
399
+ mocked_version: v16_version_string)
400
+ else
401
+ @client = setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test')
402
+ end
403
+ @client.avail.push_data(@random_id, [
404
+ { timestamp: minus50, value: 'up' },
405
+ { timestamp: minus40, value: 'up' },
406
+ { timestamp: minus30, value: 'down' },
407
+ { timestamp: minus20, value: 'down' },
408
+ { timestamp: minus10, value: 'down' },
409
+ { timestamp: now, value: 'up' }
410
+ ])
411
+ result = @client.avail.get_data(@random_id, distinct: true, order: 'ASC')
412
+ expect(result).to eq([
413
+ { 'timestamp' => minus50, 'value' => 'up' },
414
+ { 'timestamp' => minus30, 'value' => 'down' },
415
+ { 'timestamp' => now, 'value' => 'up' }
416
+ ])
417
+ end
418
+
419
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
420
+ end
338
421
  end
339
- end
340
422
 
341
- it 'Should raise ArgumentError, availability does not accept percentiles param' do
342
- expect { @client.avail.get_data(SecureRandom.uuid, percentiles: 50) }.to raise_error(ArgumentError)
343
- end
423
+ describe 'Gauge metrics' do
424
+ before(:all) do
425
+ @tenant = 'vcr-test-tenant-123'
426
+ if metrics_context == v8_context
427
+ setup_v8_client tenant: @tenant
428
+ else
429
+ if metrics_context == v16_context
430
+ setup_client_new_tenant(mocked_version: v16_version_string)
431
+ else
432
+ setup_client_new_tenant
433
+ end
434
+ end
435
+ end
344
436
 
345
- it 'Should group contiguous values' do
346
- id = SecureRandom.uuid
347
- now = @client.now
348
- setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test')
349
- VCR.use_cassette('Availability_metrics/Should group contiguous values',
350
- erb: { id: id, now: now }, record: :none
351
- ) do
352
- @client.avail.push_data(id, [
353
- { timestamp: now - 50, value: 'up' },
354
- { timestamp: now - 40, value: 'up' },
355
- { timestamp: now - 30, value: 'down' },
356
- { timestamp: now - 20, value: 'down' },
357
- { timestamp: now - 10, value: 'down' },
358
- { timestamp: now, value: 'up' }
359
- ])
360
- expect(@client.avail.get_data(id, distinct: true, order: 'ASC')).to eq([
361
- { 'timestamp' => now - 50, 'value' => 'up' },
362
- { 'timestamp' => now - 30, 'value' => 'down' },
363
- { 'timestamp' => now, 'value' => 'up' }
364
- ])
437
+ it 'Should create gauge definition using MetricDefinition' do
438
+ create_metric_using_md @client.gauges, @random_id
439
+ end
440
+
441
+ it 'Should create gauge definition using Hash' do
442
+ create_metric_using_hash @client.gauges, @random_id, @tenant
443
+ end
444
+
445
+ it 'Should push metric data to non-existing gauge' do
446
+ push_data_to_non_existing_metric @client.gauges, { value: 3.1415926 }, @random_id
447
+ end
448
+
449
+ # let's do the recording manually
450
+ it 'Should push metric data to existing gauge', :skip_auto_vcr do
451
+ now = @client.now
452
+ ends = now - t4h
453
+ starts = now - (2 * t4h)
454
+ now10 = now - 10
455
+ now20 = now - 20
456
+ now30 = now - 30
457
+ bindings = { id: @random_id, ends: ends, starts: starts, now10: now10, now20: now20, now30: now30 }
458
+ example = proc do
459
+ # create gauge
460
+ @client.gauges.create(id: @random_id)
461
+
462
+ # push 3 values with timestamps
463
+ @client.gauges.push_data(@random_id,
464
+ [{ value: 1, timestamp: now30 },
465
+ { value: 2, timestamp: now20 },
466
+ { value: 3, timestamp: now10 }])
467
+
468
+ data = @client.gauges.get_data(@random_id)
469
+ expect(data.size).to be 3
470
+
471
+ # push one value without timestamp (which means now)
472
+ @client.gauges.push_data(@random_id, value: 4)
473
+ data = @client.gauges.get_data(@random_id)
474
+ expect(data.size).to be 4
475
+
476
+ # retrieve values from past
477
+ data = @client.counters.get_data(@random_id, starts: starts, ends: ends)
478
+ expect(data.empty?).to be true
479
+ end
480
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
481
+ end
482
+
483
+ it 'Should update tags for gauge definition' do
484
+ update_metric_by_tags @client.gauges, @random_id
485
+ end
486
+
487
+ it 'Should return periods', :skip_auto_vcr do
488
+ now = @client.now
489
+ before4h = now - t4h
490
+ minus20 = now - 20
491
+ minus30 = now - 30
492
+ bindings = { id: @random_id, start: now, before4h: before4h, minus20: minus20, minus30: minus30 }
493
+ example = proc do
494
+ # push 3 values with timestamps
495
+ @client.gauges.push_data(@random_id, [{ value: 1, timestamp: minus30 },
496
+ { value: 2, timestamp: minus20 },
497
+ { value: 3, timestamp: now }])
498
+
499
+ data = @client.gauges.get_periods(@random_id, operation: 'lte', threshold: 4, starts: before4h)
500
+ expect(data.size).to be 1
501
+ expect(data[0][0]).to eql(now - 30)
502
+ expect(data[0][1]).to eql(now)
503
+ end
504
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
505
+ end
506
+
507
+ it 'Should return platform memory def', :skip_auto_vcr, run_for: [services_context] do
508
+ # this id depends on OS and the feed id
509
+ feed = 'b37ba088-6bfa-4877-83af-b3747696bfb1'
510
+ mem_id = "MI~R~[#{feed}/platform~/OPERATING_SYSTEM=#{feed}_OperatingSystem/MEMORY=Memory]~MT~Total Memory"
511
+
512
+ bindings = { id: @random_id, mem_id: mem_id }
513
+ example = proc do
514
+ tenant_id = 'hawkular'
515
+ if metrics_context == v8_context
516
+ setup_v8_client tenant: tenant_id
517
+ else
518
+ setup_client tenant: tenant_id
519
+ end
520
+
521
+ data = @client.gauges.get(mem_id)
522
+
523
+ expect(data).not_to be_nil
524
+ expect(data.id).not_to be_nil
525
+ expect(data.tenant_id).to eq(tenant_id)
526
+ end
527
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
528
+ end
529
+
530
+ it 'Should return platform memory', :skip_auto_vcr, run_for: [services_context] do
531
+ # this id depends on OS and the feed id
532
+ feed = 'b37ba088-6bfa-4877-83af-b3747696bfb1'
533
+ mem_id = "MI~R~[#{feed}/platform~/OPERATING_SYSTEM=#{feed}_OperatingSystem/MEMORY=Memory]~MT~Total Memory"
534
+
535
+ bindings = { id: @random_id, mem_id: mem_id }
536
+ example = proc do
537
+ tenant_id = 'hawkular'
538
+ if metrics_context == v8_context
539
+ setup_v8_client tenant: tenant_id
540
+ else
541
+ setup_client tenant: tenant_id
542
+ end
543
+
544
+ data = @client.gauges.get_data(mem_id)
545
+ expect(data.size).to be > 2 # needs the services to be running for more than 2 minutes
546
+ end
547
+ record("Metrics/#{metrics_context}", bindings, cassette_name, example: example)
548
+ end
549
+ end
550
+
551
+ it 'Status/Should return the version' do
552
+ if metrics_context == v8_context
553
+ setup_v8_client
554
+ else
555
+ setup_client
556
+ end
557
+ data = @client.fetch_version_and_status
558
+ expect(data).not_to be_nil
365
559
  end
366
560
  end
367
561
  end
368
562
 
369
- describe 'Gauge metrics' do
563
+ describe 'Metric ID with special characters' do
370
564
  before(:all) do
371
- setup_client_new_tenant
565
+ setup_client(username: 'jdoe', password: 'password', tenant: 'vcr-test')
372
566
  end
373
567
 
374
- it 'Should create gauge definition using MetricDefinition' do
375
- id = SecureRandom.uuid
568
+ id_gauge = 'MI~R~[8b*}{\'\\14#?/5-7%92e[-c9_.r1//;/74eddf/L=c~~]~MT~ * / Met@ics~Aggre&? ated s Active" Ses;ns'
569
+ id_avail = 'AA~R~[8b*}{\'\\14#?/5-7%92[d-c9_.r1///7;:4eddf/L=c~~]~MT~ A * %-Met@ics~Aggre&?ated " Sess{ons'
570
+ id_counter = 'AA~R~[8b*}{\'\\14#?/5-7%92[d-c9_.r1///7;:4eddf/L=c~~]~MT~ %-Met@ics~Aggre&?ated " Sess{ons'
376
571
 
377
- VCR.use_cassette('Gauge_metrics/Should create gauge definition using MetricDefinition',
378
- erb: { id: id }, record: :none
379
- ) do
380
- create_metric_using_md @client.gauges, id
572
+ it 'Should create gauge definition' do
573
+ VCR.use_cassette('Metric ID with special characters/Should create gauge definition') do
574
+ create_metric_using_md @client.gauges, id_gauge
381
575
  end
382
576
  end
383
577
 
384
- it 'Should create gauge definition using Hash' do
385
- id = SecureRandom.uuid
386
-
387
- VCR.use_cassette('Gauge_metrics/Should create gauge definition using Hash',
388
- erb: { id: id }, record: :none
389
- ) do
390
- create_metric_using_hash @client.gauges, id, @tenant
578
+ it 'Should create Availability definition' do
579
+ VCR.use_cassette('Metric ID with special characters/Should create Availability definition') do
580
+ create_metric_using_md @client.avail, id_avail
391
581
  end
392
582
  end
393
583
 
394
- it 'Should push metric data to non-existing gauge' do
395
- id = SecureRandom.uuid
396
-
397
- VCR.use_cassette('Gauge_metrics/Should push metric data to non-existing gauge',
398
- erb: { id: id }, record: :none
399
- ) do
400
- push_data_to_non_existing_metric @client.gauges, { value: 3.1415926 }, id
584
+ it 'Should create Counter definition' do
585
+ VCR.use_cassette('Metric ID with special characters/Should create Counter definition') do
586
+ create_metric_using_md @client.counters, id_counter
401
587
  end
402
588
  end
403
589
 
404
590
  it 'Should push metric data to existing gauge' do
405
- id = SecureRandom.uuid
406
- now = @client.now
407
-
408
- VCR.use_cassette('Gauge_metrics/Should push metric data to existing gauge',
409
- erb: { id: id, ends: now - t4h, starts: now - (2 * t4h) }, record: :none
410
- ) do
411
- # create gauge
412
- @client.gauges.create(id: id)
413
-
414
- # push 3 values with timestamps
415
- @client.gauges.push_data(id,
416
- [{ value: 1, timestamp: now - 30 },
417
- { value: 2, timestamp: now - 20 },
418
- { value: 3, timestamp: now - 10 }])
419
-
420
- data = @client.gauges.get_data(id)
421
- expect(data.size).to be 3
422
-
423
- # push one value without timestamp (which means now)
424
- @client.gauges.push_data(id, value: 4)
425
- data = @client.gauges.get_data(id)
426
- expect(data.size).to be 4
427
-
428
- # retrieve values from past
429
- data = @client.counters.get_data(id, starts: now - (2 * t4h), ends: now - t4h)
430
- expect(data.empty?).to be true
591
+ VCR.use_cassette('Metric ID with special characters/Should push metric data to existing gauge') do
592
+ @client.gauges.push_data(id_gauge, [
593
+ { value: 0.1, tags: { tagName: 'myMin' } },
594
+ { value: 99.9, tags: { tagName: 'myMax' } }
595
+ ])
431
596
  end
432
597
  end
433
598
 
434
599
  it 'Should update tags for gauge definition' do
435
- id = SecureRandom.uuid
436
-
437
- VCR.use_cassette('Gauge_metrics/Should update tags for gauge definition',
438
- erb: { id: id }, record: :none
439
- ) do
440
- update_metric_by_tags @client.gauges, id
441
- end
442
- end
443
-
444
- it 'Should return periods' do
445
- id = SecureRandom.uuid
446
- now = @client.now
447
- before4h = now - t4h
448
-
449
- VCR.use_cassette('Gauge_metrics/Should return periods',
450
- erb: { id: id, start: now, before4h: before4h,
451
- minus20: now - 20, minus30: now - 30 },
452
- record: :none) do
453
- # push 3 values with timestamps
454
- @client.gauges.push_data(id, [{ value: 1, timestamp: now - 30 },
455
- { value: 2, timestamp: now - 20 },
456
- { value: 3, timestamp: now }])
457
-
458
- data = @client.gauges.get_periods(id, operation: 'lte', threshold: 4, starts: before4h)
459
- expect(data.size).to be 1
460
- expect(data[0][0]).to eql(now - 30)
461
- expect(data[0][1]).to eql(now)
600
+ VCR.use_cassette('Metric ID with special characters/Should update tags for gauge definition') do
601
+ deff = @client.gauges.get(id_gauge)
602
+ deff.tags = {
603
+ name1: 'value1',
604
+ name2: 'value2',
605
+ name3: 'value3'
606
+ }
607
+ @client.gauges.update_tags(deff)
608
+ deff_updated = @client.gauges.get(id_gauge)
609
+ expected_result = {
610
+ 'name1' => 'value1',
611
+ 'name2' => 'value2',
612
+ 'name3' => 'value3',
613
+ 'tag' => 'value'
614
+ }
615
+ expect(deff_updated.tags).to eq(expected_result)
462
616
  end
463
617
  end
464
618
 
465
- it 'Should return platform memory def' do
466
- tenant_id = '28026b36-8fe4-4332-84c8-524e173a68bf'
467
- setup_client tenant: tenant_id
468
-
469
- VCR.use_cassette('Gauge_metrics/Platform mem def') do
470
- # The next id is not a real one, but shortened for rubocpo
471
- mem_id = 'MI~R~[snert~platform~/OP_SYSTEM=Apple (Capitan) 42/MEMORY=Mem]~MT~Total Memory'
472
- data = @client.gauges.get(mem_id)
473
-
474
- expect(data).not_to be_nil
475
- expect(data.id).not_to be_nil
476
- expect(data.tenant_id).to eq(tenant_id)
619
+ it 'Should update tags for Availability definition' do
620
+ VCR.use_cassette('Metric ID with special characters/Should update tags for Availability definition') do
621
+ deff_avail = @client.avail.get(id_avail)
622
+ deff_avail.tags = {
623
+ name1: 'value1',
624
+ name2: 'value2',
625
+ name3: 'value3'
626
+ }
627
+ @client.avail.update_tags(deff_avail)
628
+ deff_avail_updated = @client.avail.get(id_avail)
629
+ expected_result = {
630
+ 'name1' => 'value1',
631
+ 'name2' => 'value2',
632
+ 'name3' => 'value3',
633
+ 'tag' => 'value'
634
+ }
635
+ expect(deff_avail_updated.tags).to eq(expected_result)
477
636
  end
478
637
  end
479
638
 
480
- it 'Should return platform memory' do
481
- setup_client tenant: '28026b36-8fe4-4332-84c8-524e173a68bf'
482
-
483
- VCR.use_cassette('Gauge_metrics/Platform mem') do
484
- # The next id is not a real one, but shortened for rubocpo
485
- mem_id = 'MI~R~[snert~platform~/OP_SYSTEM=Apple (Capitan) 42/MEMORY=Mem]~MT~Total Memory'
486
- data = @client.gauges.get_data(mem_id)
487
- expect(data.size).to be 71
639
+ it 'Get metric definition by id' do
640
+ VCR.use_cassette('Metric ID with special characters/Get metric definition by id') do
641
+ @client.gauges.get(id_gauge)
488
642
  end
489
643
  end
490
644
 
491
- it 'Should return the version' do
492
- VCR.use_cassette('Metrics/Status') do
493
- data = @client.fetch_version_and_status
494
- expect(data).not_to be_nil
645
+ it 'Retrieve metric rate points' do
646
+ VCR.use_cassette('Metric ID with special characters/Retrieve metric rate points') do
647
+ @client.gauges.get(id_gauge)
648
+ @client.counters.get_rate id_counter
495
649
  end
496
650
  end
497
651
  end