# 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.

  cases:
    # service list
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
      expected: expected/service.yml
    # service instance list
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=e2e-service-provider
      expected: expected/service-instance.yml
    # service instance metrics linear
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_jvm_memory_max --instance-name=provider1 --service-name=e2e-service-provider
      expected: expected/metrics-has-value.yml
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_jvm_threads_live --instance-name=provider1 --service-name=e2e-service-provider
      expected: expected/metrics-has-value.yml
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=meter_process_files_max --instance-name=provider1 --service-name=e2e-service-provider
      expected: expected/metrics-has-value.yml
    - query: |
        curl -s -XPOST http://${sender_host}:${sender_9093}/sendBatchMetrics > /dev/null;
        sleep 10;
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=batch_test --instance-name=test-instance --service-name=test-service
      expected: expected/metrics-has-value.yml
    # virtual cache
    - query: |
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=cache_read_resp_time  --service-id=R3VhdmFDYWNoZS1sb2NhbA==.0
      expected: expected/virtual_cache_has_metrics.yml
    - query: |
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=cache_write_sla  --service-id=R3VhdmFDYWNoZS1sb2NhbA==.0
      expected: expected/virtual_cache_has_metrics.yml
    - query: |
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=cache_access_cpm  --service-id=R3VhdmFDYWNoZS1sb2NhbA==.0
      expected: expected/virtual_cache_has_metrics.yml
    - query: |
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression="top_n(top_n_cache_write_command,10,des)" --service-id=R3VhdmFDYWNoZS1sb2NhbA==.0
      expected: expected/virtual_cache_has_topN_records.yml
      # virtual database
    - query: |
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=database_access_resp_time  --service-id=bG9jYWxob3N0Oi0x.0
      expected: expected/metrics-has-value.yml
