# 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
    # before silence alarm list WARNING,receivers=lisi
    - query: |
        sleep 5;
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm ls --tags level=WARNING,receivers=lisi
      expected: expected/silence-before-graphql-warn.yml
    # before silence alarm list level=CRITICAL,receivers=zhangsan
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm ls --tags level=CRITICAL,receivers=zhangsan
      expected: expected/silence-before-graphql-critical.yml
    # query auto complete tag key and value
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm autocomplete-keys
      expected: expected/tag-keys.yml
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm autocomplete-values --key=level
      expected: expected/tag-values.yml
    # before silence webhook
    - query: curl -s -XPOST http://${provider_host}:${provider_9090}/alarm/read
      expected: expected/silence-before-webhook.yml
    # after silence alarm list WARNING,receivers=lisi
    - query: |
        sleep 30;
        swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm ls --tags level=WARNING,receivers=lisi
      expected: expected/silence-after-graphql-warn.yml
    # after silence alarm list level=CRITICAL,receivers=zhangsan
    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql alarm ls --tags level=CRITICAL,receivers=zhangsan
      expected: expected/silence-after-graphql-critical.yml
    # after silence webhook
    - query: curl -s -XPOST http://${provider_host}:${provider_9090}/alarm/read
      expected: expected/silence-after-webhook.yml
