kruize / autotune

Autonomous Performance Tuning for Kubernetes!
Apache License 2.0
155 stars 53 forks source link

Negative tests for update results failed with requests.exceptions.ChunkedEncodingError #773

Open chandrams opened 1 year ago

chandrams commented 1 year ago

Some of the tests related to valid/null/blank json key in updateResults.json failed with the below exception, this was not seen earlier though the test behavior was incorrect and test would return 201 earlier

test_update_results.py:105: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../helpers/kruize.py:89: in update_results
    response = requests.post(url, json=result_json)
/home/csubrama/.local/lib/python3.9/site-packages/requests/api.py:115: in post
    return request("post", url, data=data, json=json, **kwargs)
/home/csubrama/.local/lib/python3.9/site-packages/requests/api.py:59: in request
    return session.request(method=method, url=url, **kwargs)
/home/csubrama/.local/lib/python3.9/site-packages/requests/sessions.py:587: in request
    resp = self.send(prep, **send_kwargs)
/home/csubrama/.local/lib/python3.9/site-packages/requests/sessions.py:745: in send
    r.content
/home/csubrama/.local/lib/python3.9/site-packages/requests/models.py:899: in content
    self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def generate():
        # Special case for urllib3.
        if hasattr(self.raw, "stream"):
            try:
                yield from self.raw.stream(chunk_size, decode_content=True)
            except ProtocolError as e:
>               raise ChunkedEncodingError(e)
E               requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read, 2 more expected)', IncompleteRead(0 bytes read, 2 more expected))

/home/csubrama/.local/lib/python3.9/site-packages/requests/models.py:818: ChunkedEncodingError
chandrams commented 1 year ago

Result logs - negative.zip

chandrams commented 1 year ago

When I run one of the tests manually using curl commands, I see this not sure why pytest is throwing the exception in the description:

curl http://<IP>:<PORT>/createExperiment -d @create_exp.json 

{"message":"Experiment registered successfully with Kruize. View registered experiments at /listExperiments","httpcode":201,"documentationLink":"","status":"SUCCESS"}

curl http://<IP>:<PORT>/createExperiment -d @update_results_null_cpuRequest_sum.json 

{"message":"Internal Server Error: Cannot invoke \"com.autotune.common.data.ValidationOutputData.isSuccess()\" because \"addedToDB\" is null","httpcode":500,"documentationLink":"","status":"ERROR"}

Create experiment json

[{
  "version": "1.0",
  "experiment_name": "quarkus-resteasy-kruize-min-http-response-time-db-10",
  "cluster_name": "cluster-one-division-bell",
  "performance_profile": "resource-optimization-openshift",
  "mode": "monitor",
  "target_cluster": "remote",
  "kubernetes_objects": [
    {
      "type": "deployment",
      "name": "tfb-qrh-deployment",
      "namespace": "default",
      "containers": [
        {
          "container_image_name": "kruize/tfb-db:1.15",
          "container_name": "tfb-server-0"
        },
        {
          "container_image_name": "kruize/tfb-qrh:1.13.2.F_et17",
          "container_name": "tfb-server-1"
        }
      ]
    }
  ],
  "trial_settings": {
    "measurement_duration": "15min"
  },
  "recommendation_settings": {
    "threshold": "0.1"
  }
}]

Update Results json

[
  {
    "version": "1.0",
    "experiment_name": "quarkus-resteasy-kruize-min-http-response-time-db-10",
    "interval_start_time": "2022-01-23T18:25:43.511Z",
    "interval_end_time": "2022-01-23T18:40:43.511Z",
    "kubernetes_objects": [
      {
        "type": "deployment",
        "name": "tfb-qrh-sample",
        "namespace": "default",
        "containers": [
          {
            "container_image_name": "kruize/tfb-qrh:1.13.2.F_et17",
            "container_name": "tfb-server",
            "metrics": [
              {
                "name": "cpuRequest",
                "results": {
                  "aggregation_info": {
                    "sum": null,
                    "avg": 1.1,
                    "format": "cores"
                  }
                }
              },
              {
                "name": "cpuLimit",
                "results": {
                  "aggregation_info": {
                    "sum": 5.4,
                    "avg": 22.1,
                    "format": "cores"
                  }
                }
              },
              {
                "name": "cpuUsage",
                "results": {
    "aggregation_info": {
                    "min": 0.5,
                    "max": 2.4,
                    "sum": 3.4,
                    "avg": 1.5,
                    "format": "cores"
                  }
                }
              },
              {
                "name": "cpuThrottle",
                "results": {
                  "aggregation_info": {
                    "sum": 1.09,
                    "max": 0.09,
                    "avg": 0.045,
                    "format": "cores"
                  }
                }
              },
              {
                "name": "memoryRequest",
                "results": {
                  "aggregation_info": {
                    "sum": 250.85,
                    "avg": 51.1,
                    "format": "MiB"
                  }
                }
              },
              {
                "name": "memoryLimit",
                "results": {
                  "aggregation_info": {
                    "sum": 500,
                    "avg": 100,
                    "format": "MiB"
                  }
                     }
              },
              {
                "name": "memoryUsage",
                "results": {
                  "aggregation_info": {
                    "min": 21.5,
                    "max": 198.4,
                    "sum": 298.5,
                    "avg": 41.5,
                    "format": "MiB"
                  }
                }
              },
              {
                "name": "memoryRSS",
                "results": {
                  "aggregation_info": {
                    "min": 26.5,
                    "max": 125.54,
                    "sum": 225.64,
                    "avg": 46.5,
                    "format": "MiB"
                  }
                }
              }
            ]
          }
        ]
      }
    ]
  }
]