# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file is used to show how to write configuration files and can be used to test.

cases:
  # service cases
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
    expected: expected/service.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_under_replicated_partitions --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_offline_partitions_count --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_partition_count --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_leader_count --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_active_controller_count --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_leader_election_rate --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_unclean_leader_elections_per_second --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_max_lag --service-name=kafka::kafka-cluster
    expected: expected/metrics-has-value-service-label.yml

  # instance cases
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance ls --service-name=kafka::kafka-cluster
    expected: expected/instance.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_cpu_time_total --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_memory_usage_percentage --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-jvm-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_messages_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_bytes_in_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_bytes_out_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_replication_bytes_in_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_replication_bytes_out_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_under_replicated_partitions --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_under_min_isr_partition_count --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_partition_count --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_leader_count --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_isr_shrinks_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_isr_expands_per_second --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_max_lag --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_purgatory_size --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-instance-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_garbage_collector_count --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-gc-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_request_queue_time_ms --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-source-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_remote_time_ms --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-source-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_response_queue_time_ms --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-source-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_response_send_time_ms --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value-source-label.yml
  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_kafka_broker_network_processor_avg_idle_percent --service-name=kafka::kafka-cluster --instance-name=broker1:7071
    expected: expected/metrics-has-value.yml
