github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/features/Health.feature (about)

     1  Feature: Run health-check against registered proxies.
     2  
     3      Background:
     4          Given request JWT token is valid admin token
     5  
     6      Scenario: Check healthcheck status is active
     7          Given request JSON payload:
     8              """
     9              {
    10                  "name":"example-ok",
    11                  "active":false,
    12                  "proxy":{
    13                      "preserve_host":false,
    14                      "listen_path":"/example-ok/*",
    15                      "upstreams":{
    16                          "balancing":"roundrobin",
    17                          "targets":[
    18                              {
    19                                  "target":"http://localhost:9089/hello-world"
    20                              }
    21                          ]
    22                      },
    23                      "strip_path":false,
    24                      "append_path":false,
    25                      "methods":[
    26                          "GET"
    27                      ]
    28                  },
    29                  "health_check":{
    30                      "url":"http://localhost:9089/status-ok"
    31                  }
    32              }
    33              """
    34          When I request "/apis" API path with "POST" method
    35          Then I should receive 201 response code
    36          And header "Location" should be "/apis/example-ok"
    37  
    38          When I request "/status" API path with "GET" method
    39          Then I should receive 200 response code
    40  
    41  
    42      Scenario: Request health-checks statuses
    43          Given request JSON payload:
    44              """
    45              {
    46                  "name":"example-ok",
    47                  "active":true,
    48                  "proxy":{
    49                      "preserve_host":false,
    50                      "listen_path":"/example-ok/*",
    51                      "upstreams":{
    52                          "balancing":"roundrobin",
    53                          "targets":[
    54                              {
    55                                  "target":"http://localhost:9089/hello-world"
    56                              }
    57                          ]
    58                      },
    59                      "strip_path":false,
    60                      "append_path":false,
    61                      "methods":[
    62                          "GET"
    63                      ]
    64                  },
    65                  "health_check":{
    66                      "url":"http://localhost:9089/status-ok"
    67                  }
    68              }
    69              """
    70          When I request "/apis" API path with "POST" method
    71          Then I should receive 201 response code
    72          And header "Location" should be "/apis/example-ok"
    73  
    74          When I request "/status" API path with "GET" method
    75          Then I should receive 200 response code
    76          And response JSON body has "system" path
    77          And response JSON body has "status" path with value 'OK'
    78          And response JSON body has "timestamp" path
    79  
    80          Given request JSON payload:
    81              """
    82              {
    83                  "name":"example-ok2",
    84                  "active":true,
    85                  "proxy":{
    86                      "preserve_host":false,
    87                      "listen_path":"/example-ok2/*",
    88                      "upstreams":{
    89                          "balancing":"roundrobin",
    90                          "targets":[
    91                              {
    92                                  "target":"http://localhost:9089/hello-world"
    93                              }
    94                          ]
    95                      },
    96                      "strip_path":false,
    97                      "append_path":false,
    98                      "methods":[
    99                          "GET"
   100                      ]
   101                  },
   102                  "health_check":{
   103                      "url":"http://localhost:9089/status-ok"
   104                  }
   105              }
   106              """
   107          When I request "/apis" API path with "POST" method
   108          Then I should receive 201 response code
   109          And header "Location" should be "/apis/example-ok2"
   110  
   111          When I request "/status" API path with "GET" method
   112          Then I should receive 200 response code
   113          And response JSON body has "system" path
   114          And response JSON body has "status" path with value 'OK'
   115          And response JSON body has "timestamp" path
   116  
   117          Given request JSON payload:
   118              """
   119              {
   120                  "name":"example-partial",
   121                  "active":true,
   122                  "proxy":{
   123                      "preserve_host":false,
   124                      "listen_path":"/example-partial/*",
   125                      "upstreams":{
   126                          "balancing":"roundrobin",
   127                          "targets":[
   128                              {
   129                                  "target":"http://localhost:9089/hello-world"
   130                              }
   131                          ]
   132                      },
   133                      "strip_path":false,
   134                      "append_path":false,
   135                      "methods":[
   136                          "GET"
   137                      ]
   138                  },
   139                  "health_check":{
   140                      "url":"http://localhost:9089/status-partial"
   141                  }
   142              }
   143              """
   144          When I request "/apis" API path with "POST" method
   145          Then I should receive 201 response code
   146          And header "Location" should be "/apis/example-partial"
   147  
   148          When I request "/status" API path with "GET" method
   149          Then I should receive 200 response code
   150          And response JSON body has "system" path
   151          And response JSON body has "status" path with value 'Partially Available'
   152          And response JSON body has "timestamp" path
   153          And response JSON body has "failures.example-partial" path
   154  
   155          Given request JSON payload:
   156              """
   157              {
   158                  "name":"example-broken",
   159                  "active":true,
   160                  "proxy":{
   161                      "preserve_host":false,
   162                      "listen_path":"/example-broken/*",
   163                      "upstreams":{
   164                          "balancing":"roundrobin",
   165                          "targets":[
   166                              {
   167                                  "target":"http://localhost:9089/hello-world"
   168                              }
   169                          ]
   170                      },
   171                      "strip_path":false,
   172                      "append_path":false,
   173                      "methods":[
   174                          "GET"
   175                      ]
   176                  },
   177                  "health_check":{
   178                      "url":"http://localhost:9089/status-broken"
   179                  }
   180              }
   181              """
   182          When I request "/apis" API path with "POST" method
   183          Then I should receive 201 response code
   184          And header "Location" should be "/apis/example-broken"
   185  
   186          When I request "/status" API path with "GET" method
   187          Then I should receive 200 response code
   188          And response JSON body has "system" path
   189          And response JSON body has "status" path with value 'Partially Available'
   190          And response JSON body has "timestamp" path
   191          And response JSON body has "failures.example-partial" path
   192          And response JSON body has "failures.example-broken" path
   193  
   194      Scenario: Request health-check service status
   195          Given request JSON payload:
   196              """
   197              {
   198                  "name":"example-partial",
   199                  "active":true,
   200                  "proxy":{
   201                      "preserve_host":false,
   202                      "listen_path":"/example-partial/*",
   203                      "upstreams":{
   204                          "balancing":"roundrobin",
   205                          "targets":[
   206                              {
   207                                  "target":"http://localhost:9089/hello-world"
   208                              }
   209                          ]
   210                      },
   211                      "strip_path":false,
   212                      "append_path":false,
   213                      "methods":[
   214                          "GET"
   215                      ]
   216                  },
   217                  "health_check":{
   218                      "url":"http://localhost:9089/status-partial"
   219                  }
   220              }
   221              """
   222          When I request "/apis" API path with "POST" method
   223          Then I should receive 201 response code
   224          And header "Location" should be "/apis/example-partial"
   225  
   226          When I request "/status/example-partial" API path with "GET" method
   227          Then I should receive 400 response code
   228          And response JSON body has "system" path
   229          And response JSON body has "status" path with value 'Partially Available'
   230          And response JSON body has "timestamp" path
   231          And response JSON body has "failures.rabbitmq" path with value 'Failed during RabbitMQ health check'
   232  
   233          Given request JSON payload:
   234              """
   235              {
   236                  "name":"example-broken",
   237                  "active":true,
   238                  "proxy":{
   239                      "preserve_host":false,
   240                      "listen_path":"/example-broken/*",
   241                      "upstreams":{
   242                          "balancing":"roundrobin",
   243                          "targets":[
   244                              {
   245                                  "target":"http://localhost:9089/hello-world"
   246                              }
   247                          ]
   248                      },
   249                      "strip_path":false,
   250                      "append_path":false,
   251                      "methods":[
   252                          "GET"
   253                      ]
   254                  },
   255                  "health_check":{
   256                      "url":"http://localhost:9089/status-broken"
   257                  }
   258              }
   259              """
   260          When I request "/apis" API path with "POST" method
   261          Then I should receive 201 response code
   262          And header "Location" should be "/apis/example-broken"
   263  
   264          When I request "/status/example-broken" API path with "GET" method
   265          Then I should receive 503 response code
   266          And response JSON body has "system" path
   267          And response JSON body has "status" path with value 'Unavailable'
   268          And response JSON body has "timestamp" path
   269          And response JSON body has "failures.mongodb" path with value 'Failed during MongoDB health check'
   270  
   271          When I request "/status/does-not-exist" API path with "GET" method
   272          Then I should receive 404 response code
   273          And the response should contain "Definition name is not found"