{"action":"created","issue":{"url":"https://api.github.com/repos/gatling/gatling/issues/3371","repository_url":"https://api.github.com/repos/gatling/gatling","labels_url":"https://api.github.com/repos/gatling/gatling/issues/3371/labels{/name}","comments_url":"https://api.github.com/repos/gatling/gatling/issues/3371/comments","events_url":"https://api.github.com/repos/gatling/gatling/issues/3371/events","html_url":"https://github.com/gatling/gatling/issues/3371","id":270250368,"number":3371,"title":"Gatling doesn't update to new Etag when it changes","user":{"login":"mmneuro","id":33280343,"avatar_url":"https://avatars3.githubusercontent.com/u/33280343?v=4","gravatar_id":"","url":"https://api.github.com/users/mmneuro","html_url":"https://github.com/mmneuro","followers_url":"https://api.github.com/users/mmneuro/followers","following_url":"https://api.github.com/users/mmneuro/following{/other_user}","gists_url":"https://api.github.com/users/mmneuro/gists{/gist_id}","starred_url":"https://api.github.com/users/mmneuro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmneuro/subscriptions","organizations_url":"https://api.github.com/users/mmneuro/orgs","repos_url":"https://api.github.com/users/mmneuro/repos","events_url":"https://api.github.com/users/mmneuro/events{/privacy}","received_events_url":"https://api.github.com/users/mmneuro/received_events","type":"User","site_admin":false},"labels":[{"id":464536391,"url":"https://api.github.com/repos/gatling/gatling/labels/Waiting%20for%20User","name":"Waiting for User","color":"f9d0c4","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-01T09:40:07Z","updated_at":"2017-11-02T10:44:29Z","closed_at":null,"author_association":"NONE","body":"I wanted to make a stress test on our staging system and make sure our cache works correct, so i made a test scenario where i repeat a request and make assertion on the HTTP status code, whether it is 200 or 304.\r\n\r\nSo it looks like this:\r\n\r\n```scala\r\nvar apiCall = exec(http(\"apiCallName\").get(\"path/of/the/API/endpoint\").header(\"Accept-Encoding\",\"gzip, deflate\")).\r\npause(minPause milliseconds, maxPause milliseconds).repeat(repeatsNo) {\r\nexec(http(\"apiCallName\").get(\"path/of/the/API/endpoint\".header(\"Accept-Encoding\",\"gzip, deflate\").check(status.is(200))).\r\npause(minPause milliseconds, maxPause milliseconds);\r\n}\r\n```\r\n\r\nThe execution begins, with one successful request (no assertion on that anyway), and then all the other requests (these inside the repeat block) are reported as failed because gatling correctly uses the etag and receives an HTTP status code of 304.\r\n\r\nThen, as the stress tests continues, I change the data on the database, so the response changes, and also the Etag changes.\r\n\r\nThen, all subsequent responses that gatling receives are with HTTP status code 200, where the correct should be to receive one request with HTTP status code 200, and then use the new Etag and get reponses with HTTP status code 304.\r\n\r\nI doubled checked by undoing the changes on the data on the database, so the Etag issued by the server changes back to the previous value (I suppose that Etag is created by a hash function on the response, so because subsequent responses are the same with the first response, they get issued with the same Etag value on the response header). Then, gatling gets responses with HTTP status 304, which means that gatling has stored the first Etag it received, and then uses it an all subsequent requests, no matter if the Etag changes.\r\n\r\nAlso tried disableClientSharing, perUserNameResolution on the HTTP configuration but no luck.\r\n\r\nThanks in advance"},"comment":{"url":"https://api.github.com/repos/gatling/gatling/issues/comments/341382920","html_url":"https://github.com/gatling/gatling/issues/3371#issuecomment-341382920","issue_url":"https://api.github.com/repos/gatling/gatling/issues/3371","id":341382920,"user":{"login":"mmneuro","id":33280343,"avatar_url":"https://avatars3.githubusercontent.com/u/33280343?v=4","gravatar_id":"","url":"https://api.github.com/users/mmneuro","html_url":"https://github.com/mmneuro","followers_url":"https://api.github.com/users/mmneuro/followers","following_url":"https://api.github.com/users/mmneuro/following{/other_user}","gists_url":"https://api.github.com/users/mmneuro/gists{/gist_id}","starred_url":"https://api.github.com/users/mmneuro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmneuro/subscriptions","organizations_url":"https://api.github.com/users/mmneuro/orgs","repos_url":"https://api.github.com/users/mmneuro/repos","events_url":"https://api.github.com/users/mmneuro/events{/privacy}","received_events_url":"https://api.github.com/users/mmneuro/received_events","type":"User","site_admin":false},"created_at":"2017-11-02T10:44:29Z","updated_at":"2017-11-02T10:44:29Z","author_association":"NONE","body":"Hi,\r\n\r\nI am using Gatling version 2.3.\r\n\r\nI can't provide a sample app but i am getting the desired functionality by manually storing and reusing the Etag by changing the aforementioned code to:\r\n\r\n`var apiCall = exec(http(\"apiCallName\").get(\"path/of/the/API/endpoint\").header(\"Accept-Encoding\",\"gzip, deflate\").check(header(\"Etag\").saveAs(\"lastEtag\"))).pause(minPause milliseconds, maxPause milliseconds).repeat(repeatsNo) {\r\nexec(http(\"apiCallName\").get(\"path/of/the/API/endpoint\").header(\"Accept-Encoding\",\"gzip, deflate\").\r\nheader(\"If-None-Match\", if(\"${lastEtag}\".charAt(0) == 'W') \"${lastEtag}\".substring(2) else \"${lastEtag}\").check(status.is(200)).check(header(\"Etag\").saveAs(\"lastEtag\"))).pause(minPause milliseconds, maxPause milliseconds);\r\n}`\r\n\r\nand also disabling caching on the http configuration using disableCaching."}}
{"actor":{"display_login":"mmneuro"}}