{"id":23009,"date":"2024-02-27T15:01:47","date_gmt":"2024-02-27T06:01:47","guid":{"rendered":"https:\/\/labs.gree.jp\/blog\/?p=23009"},"modified":"2024-02-29T13:39:51","modified_gmt":"2024-02-29T04:39:51","slug":"cdn%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92varnishtest%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e8%a1%8c%e3%81%8a%e3%81%86","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2024\/02\/23009\/","title":{"rendered":"CDN\u306e\u30c6\u30b9\u30c8\u3092varnishtest\u3092\u4f7f\u3063\u3066\u884c\u304a\u3046"},"content":{"rendered":"<p>\u30a4\u30f3\u30d5\u30e9\u306e\u3044\u308f\u306a\u3061\u3083\u3093\u3055\u3093(@xcir)\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/labs.gree.jp\/blog\/?p=22991\">\u5148\u306e\u8a18\u4e8b\u3067\u306fTerraform\u3067Akamai\u3092\u904b\u7528\u3059\u308b<\/a>\u3068\u3044\u3046\u3053\u3068\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<br \/>\n\u8a18\u4e8b\u4e2d\u3067\u30c6\u30b9\u30c8\u306b\u3064\u3044\u3066\u89e6\u308c\u307e\u3057\u305f\u304c\u3001\u3075\u3068\u8003\u3048\u305f\u3089CDN\u306b\u5bfe\u3057\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3046\u4e8b\u4f8b\u3092\u3042\u307e\u308a\u805e\u3044\u305f\u3053\u3068\u306a\u3044\u306a\u3068\u601d\u3044\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u3092\u516c\u958b\u3057\u307e\u3059\u3002<\/p>\n<h1>CDN\u306e\u30c6\u30b9\u30c8\u3069\u3046\u3084\u3063\u3066\u3044\u307e\u3059\u304b\uff1f<\/h1>\n<p>CDN\u3067\u8907\u96d1\u306a\u51e6\u7406\u3092\u884c\u3046\u3088\u3046\u306b\u306a\u308a\u30c6\u30b9\u30c8\u304c\u3088\u308a\u91cd\u8981\u306a\u306e\u306f\u7591\u3044\u3082\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u3042\u307e\u308aCDN\u306b\u5bfe\u3057\u3066\u30c6\u30b9\u30c8\u3092\u3068\u3044\u3046\u3053\u3068\u3092\u805e\u304d\u307e\u305b\u3093\u3002<br \/>\n\u65b0\u898f\u306b\u4f5c\u6210\u3059\u308b\u5834\u5408\u3067\u3042\u308c\u3070CNAME\u5207\u308a\u66ff\u3048\u524d\u306bhosts\u3092\u66f8\u304d\u63db\u3048\u3066\u30d6\u30e9\u30a6\u30b6\u3067\u78ba\u8a8d\u3057\u305f\u308a\u3001CLI\u3067\u884c\u3046\u5834\u5408\u3067\u3082curl\u3067--resolve\u30aa\u30d7\u30b7\u30e7\u30f3\u3067200\u306a\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3060\u3051\u3068\u3044\u3046\u30b5\u30a4\u30c8\u3082\u591a\u305d\u3046\u3067\u3059\u3002<br \/>\n\u3082\u3061\u308d\u3093\u3001<a href=\"https:\/\/playwright.dev\/\">Playwright<\/a>\u306a\u3069\u3067\u30b5\u30a4\u30c8\u306eE2E\u30c6\u30b9\u30c8\u306e\u4e00\u74b0\u3067\u884c\u3063\u3066\u3044\u305f\u308a\u3001Pytest\u3084RSpec\u3067\u884c\u3063\u3066\u3044\u308b\u30b5\u30a4\u30c8\u3082\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u306fvarnishtest\u3092\u4f7f\u3063\u3066CDN\u306e\u30b7\u30f3\u30d7\u30eb\u306aUT\u3092\u884c\u3046\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h1>varnishtest\u3068\u306f<\/h1>\n<p>10\u5e74\u3050\u3089\u3044\u524d\u306b\u3082<a href=\"https:\/\/labs.gree.jp\/blog\/2013\/04\/7966\/\">Varnish\u3067\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u3053\u3046\uff01<\/a>\u3068\u3044\u3046\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u305d\u3061\u3089\u3082\u5408\u308f\u305b\u8aad\u3093\u3067\u307b\u3057\u3044\u306e\u3067\u3059\u304c\u3001\u8981\u306f<a href=\"https:\/\/varnish-cache.org\/\">VarnishCache<\/a>\u306e\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u3067\u3059\u3002<br \/>\n\u975e\u5e38\u306b\u7d30\u304b\u3044\u90e8\u5206\u306e\u30c6\u30b9\u30c8\u3082\u3067\u304d\u308b\u305f\u3081\u304b\u3001\u6700\u8fd1\u3067\u306f<a href=\"https:\/\/github.com\/haproxy\/haproxy\/blob\/master\/reg-tests\/connection\/h2_glitches.vtc\">HAProxy<\/a>\u3082varnishtest(\u6b63\u78ba\u306b\u306f\u5207\u308a\u51fa\u3057\u305f<a href=\"https:\/\/github.com\/vtest\/VTest\">VTest<\/a>\u3067\u3059\u304c)\u3092\u4f7f\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u3044\u3066\u8a18\u8ff0\u306f\u6bd4\u8f03\u7684\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<br \/>\n\u5f0a\u793e\u306f<a href=\"https:\/\/varnish-cache.org\/\">VarnishCache<\/a>\u3092\u9577\u5e74\u5229\u7528\u3057\u3066\u304a\u308a\u3001Varnish\u3067\u51e6\u7406\u3057\u3066\u3044\u308b\u30c9\u30e1\u30a4\u30f3\u306f\u3059\u3079\u3066varnishtest\u3092\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u3044\u308b\u3053\u3068\u3082\u3042\u308aCDN\u306b\u5bfe\u3057\u3066\u3082\u4f7f\u3046\u306e\u306f\u81ea\u7136\u3067\u3057\u305f\u3002<\/p>\n<h2>varnishtest\u3092\u5916\u90e8\u306b\u63a5\u7d9a\u3057\u3066\u30c6\u30b9\u30c8\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p>\u3068\u3053\u308d\u304cvarnishtest\u3092CDN\u306e\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u3068\u3057\u3066\u4f7f\u3046\u306b\u306f\u4e00\u82e6\u52b4\u3042\u308a\u307e\u3057\u305f\u3002<br \/>\n\u305d\u3082\u305d\u3082\u304cvarnish\u306e\u30c6\u30b9\u30c8\u30c4\u30fc\u30eb\u3067\u3042\u308a\u3001\u5916\u90e8\u306b\u63a5\u7d9a\u3059\u308b\u3053\u3068\u3092\uff08\u304a\u305d\u3089\u304f\uff09\u60f3\u5b9a\u3057\u3066\u3044\u307e\u305b\u3093\u3002<br \/>\n\u63a5\u7d9a\u5148\u3092IP\u30a2\u30c9\u30ec\u30b9\u3067\u6307\u5b9a\u3059\u308c\u3070\u53ef\u80fd\u3067\u3059\u304c\u5b9f\u904b\u7528\u3067\u884c\u3046\u306b\u306f\u53b3\u3057\u3044\u3067\u3059\u3002<br \/>\n\u4ed6\u306b\u3082\u30c6\u30b9\u30c8client\u304cHTTP\u306b\u3057\u304b\u5bfe\u5fdc\u3057\u3066\u304a\u3089\u305aHTTPS\u3067\u306f\u63a5\u7d9a\u3067\u304d\u306a\u3044\u3068\u3044\u3046\u554f\u984c\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u3089\u3092\u3069\u3046\u89e3\u6c7a\u3057\u305f\u304b\u3068\u3044\u3046\u3068\u5148\u306b\u89e6\u308c\u305fHAProxy\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"example.vtc\">vtest \"example.net\"\nfeature ignore_unknown_macro\n\nfeature cmd {haproxy --version 2&gt;&amp;1 | grep -q 'HA-*Proxy version'}\n\nhaproxy h1 -conf {\n    defaults\n        mode   http\n        timeout connect         5s\n        timeout server          5s\n        timeout client          5s\n\n    backend be1\n        #https\n        server srv1 ${target}:443 ssl verify none sni req.hdr(Host)\n    backend be2\n        #http\n        server srv1 ${target}:80\n\n    frontend fe1\n        #https\n        use_backend be1\n        bind \"fd@${fe1}\"\n    frontend fe2\n        #http\n        use_backend be2\n        bind \"fd@${fe2}\"\n} -start\n\n\n#-----------------------------------------\n\nclient c_http -connect ${h1_fe2_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run\n\nclient c_https -connect ${h1_fe1_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run<\/pre>\n<p>\u3053\u308c\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u542b\u307e\u308c\u308bexample.net\u3092\u5bfe\u8c61\u3068\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u5b9a\u7fa9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">client c_http -connect ${h1_fe2_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run\n\nclient c_https -connect ${h1_fe1_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run<\/pre>\n<p>\u5b9f\u969b\u306e\u30c6\u30b9\u30c8\u5b9a\u7fa9\u306f\u3053\u308c\u3060\u3051\u3067\u6bd4\u8f03\u7684\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002\u4ed6\u306e\u3068\u3053\u308d\u306fhaproxy\u306e\u8a2d\u5b9a\u3067\u3059\u3002<br \/>\n\u8981\u306fhaproxy\u306bDNS\u306e\u89e3\u6c7a\u3084https\u3067\u306e\u63a5\u7d9a\u3092\u4efb\u305b\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/vtc1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23039\" src=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/vtc1.png\" alt=\"\" width=\"400\" height=\"445\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/vtc1.png 400w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/vtc1-360x400.png 360w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/vtc1-180x200.png 180w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u307e\u305f\u6700\u521d\u306bhosts\u3092\u66f8\u304d\u63db\u3048\u3066\u30d6\u30e9\u30a6\u30b6\u3067\u30c6\u30b9\u30c8\u3059\u308b\u4f8b\u3092\u6319\u3052\u307e\u3057\u305f\u304c\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3092\u884c\u3046\u5834\u5408\u306f\u672c\u756a\u306b\u53cd\u6620\u3059\u308b\u524d\u306b\u5b9f\u65bd\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u308f\u3051\u3067\u63a5\u7d9a\u5148\u3092\u5909\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-23038\" src=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage-830x161.png\" alt=\"\" width=\"830\" height=\"161\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage-830x161.png 830w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage-600x116.png 600w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage-276x53.png 276w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage-768x149.png 768w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2024\/02\/akamai-stage.png 1116w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/a><\/p>\n<p>Akamai\u306e\u5834\u5408\u306fStaging\/Production\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304c\u3042\u308a\u3001\u5148\u306bStaging\u306b\u5c55\u958b\u3057\u305f\u5f8c\u306b\u63a5\u7d9a\u5148\u3092\u5909\u3048\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3044\u554f\u984c\u304c\u306a\u3051\u308c\u3070Production\u306b\u5c55\u958b\u3059\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<br \/>\n\u4ed6\u306eCDN\u3092\u4f7f\u3046\u5834\u5408\u3067\u3082\u591a\u304f\u306e\u5834\u5408\u306f\u5c11\u3057\u5909\u3048\u305f\u30c9\u30e1\u30a4\u30f3\u3067\u8a2d\u5b9a\u306e\u78ba\u8a8d\u3092\u884c\u3044\u554f\u984c\u304c\u306a\u3051\u308c\u3070\u5c55\u958b\u3059\u308b\u904b\u7528\u304c\u4e00\u822c\u7684\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u5148\u306eHAProxy\u306e\u8a2d\u5b9a\u3067\u306fexample.net\u306b\u63a5\u7d9a\u3059\u308b\u5b9a\u7fa9\u306f\u306a\u304f\u3001\u305d\u306e\u90e8\u5206\u306f<strong>${target}<\/strong>\u3068\u3044\u3046\u30de\u30af\u30ed\u5b9a\u7fa9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u3053\u306b\u63a5\u7d9a\u5148\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067CNAME\u5207\u308a\u66ff\u3048\u524d\u306eCDN\u8a2d\u5b9a\u3001Akamai\u3067\u3042\u308c\u3070\u7570\u306a\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3067\u306e\u30c6\u30b9\u30c8\u3001\u30c6\u30b9\u30c8\u306e\u66f8\u304d\u65b9\u306b\u3082\u3088\u308a\u307e\u3059\u304c\u30de\u30eb\u30c1CDN\u3067\u306e\u30c6\u30b9\u30c8\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h1>vtc-external-test<\/h1>\n<p><a href=\"https:\/\/github.com\/xcir\/vtc-external-test\">https:\/\/github.com\/xcir\/vtc-external-test<\/a><\/p>\n<h2>\u307e\u305a\u306f\u52d5\u304b\u3057\u3066\u307f\u308b<\/h2>\n<p>\u5148\u307b\u3069\u306e\u30c6\u30b9\u30c8\u30b5\u30f3\u30d7\u30eb\u3092example.net\u306b\u5bfe\u3057\u3066\u63a5\u7d9a\u3057\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">xcir@DESKTOP-UL5EP50:~\/git\/vtc-ext-test$ cat tests\/example.vtc \nvtest \"example.net\"\nfeature ignore_unknown_macro\n\nfeature cmd {haproxy --version 2&gt;&amp;1 | grep -q 'HA-*Proxy version'}\n\nhaproxy h1 -conf {\n    defaults\n        mode   http\n        timeout connect         5s\n        timeout server          5s\n        timeout client          5s\n\n    backend be1\n        #https\n        server srv1 ${target}:443 ssl verify none sni req.hdr(Host)\n    backend be2\n        #http\n        server srv1 ${target}:80\n\n    frontend fe1\n        #https\n        use_backend be1\n        bind \"fd@${fe1}\"\n    frontend fe2\n        #http\n        use_backend be2\n        bind \"fd@${fe2}\"\n} -start\n\n\n#-----------------------------------------\n\nclient c_http -connect ${h1_fe2_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run\n\nclient c_https -connect ${h1_fe1_sock} {\n    txreq -req GET -url \"\/\" -hdr \"Host: example.net\"\n    rxresp\n    expect resp.status        == \"200\"\n} -run\n\nxcir@DESKTOP-UL5EP50:~\/git\/vtc-ext-test$ .\/vtc.sh -c example.net tests\/example.vtc \n==============================================\n  Target Server: example.net\n            VTC: \/home\/xcir\/git\/vtc-ext-test\/tests\/example.vtc\n==============================================\n[+] Building 1.6s (6\/6) FINISHED\n....\n#    top  TEST \/mnt\/tests\/test.vtc passed (6.198)<\/pre>\n<p>\u3061\u306a\u307f\u306b\u62e1\u5f35\u5b50\u304cvtc\u3068\u306a\u3063\u3066\u3044\u308b\u306e\u306fvarnish test code\u306e\u7565\u3067\u3001vtc\u3068\u3044\u3046\u3068\u5b9f\u969b\u306e\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u3055\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">$ .\/vtc.sh -c example.net tests\/example.vtc \n==============================================\n  Target Server: example.net\n            VTC: <span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">home<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">xcir<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">git<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">vtc<\/span><span class=\"crayon-o\">-<\/span><span class=\"crayon-v\">ext<\/span><span class=\"crayon-o\">-<\/span><span class=\"crayon-r\">test<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">tests<\/span><span class=\"crayon-o\">\/<\/span><span class=\"crayon-v\">example<\/span><span class=\"crayon-e\">.vtc<\/span>\n==============================================\n**** dT    0.000\n*    top   TEST \/mnt\/tests\/test.vtc starting\n...\n**** c_http c-l|&lt;\/html&gt;\n**** c_http bodylen = 1256\n**   c_http === expect resp.status        == \"404\"\n---- c_http EXPECT resp.status (200) == \"404\" failed \u2605\u2605\n*    top   RESETTING after \/mnt\/tests\/test.vtc\n**   h1    Reset and free h1 haproxy 15\n**   h1    Wait\n**   h1    Stop HAproxy pid=15\n**** dT    5.579\n**** h1    Kill(2)=0: Success\n**** dT    5.580\n**** h1    STDOUT EOF\n**** dT    5.679\n**   h1    WAIT4 pid=15 status=0x0002 (user 0.121659 sys 0.022119)\n**** dT    5.680\n*    top   TEST \/mnt\/tests\/test.vtc FAILED\n#    top  TEST \/mnt\/tests\/test.vtc FAILED (5.681) exit=2<\/pre>\n<p>\u8a66\u3057\u306b200\u306eexpect\u90e8\u5206\u3092404\u306b\u3057\u3066\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u304d\u3061\u3093\u3068FAIL\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h2>\u8d77\u52d5\u30aa\u30d7\u30b7\u30e7\u30f3<\/h2>\n<table>\n<thead>\n<tr>\n<th>option<\/th>\n<th align=\"left\">\u8aac\u660e<\/th>\n<th align=\"left\">default<\/th>\n<th align=\"left\">example<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>-h<\/td>\n<td align=\"left\">help<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\">-<\/td>\n<\/tr>\n<tr>\n<td>-v<\/td>\n<td align=\"left\">verbose\u8868\u793a<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\">-<\/td>\n<\/tr>\n<tr>\n<td>-s<\/td>\n<td align=\"left\">\u30b3\u30f3\u30c6\u30ca\u306b\u5165\u308b<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\">-<\/td>\n<\/tr>\n<tr>\n<td>-f<\/td>\n<td align=\"left\">docker image\u306e\u30ea\u30d3\u30eb\u30c9\u3092\u884c\u3046<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\">-<\/td>\n<\/tr>\n<tr>\n<td>-n [target name]<\/td>\n<td align=\"left\">\u63a5\u7d9a\u5148\u3092<code>conf.sh<\/code>\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u3082\u306e\u3092\u5229\u7528\u3059\u308b<\/td>\n<td align=\"left\"><code>default<\/code><\/td>\n<td align=\"left\"><code>-n stg<\/code><\/td>\n<\/tr>\n<tr>\n<td>-c [connection server]<\/td>\n<td align=\"left\">\u660e\u793a\u7684\u306b\u63a5\u7d9a\u5148\u3092\u8a2d\u5b9a\u3059\u308b<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\"><code>-c example.net<\/code><\/td>\n<\/tr>\n<tr>\n<td>-o [extra varnishtest option]<\/td>\n<td align=\"left\">varnishtest\u306b\u8ffd\u52a0\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3059\u3002\u4e3b\u306b\u30de\u30af\u30ed\u5b9a\u7fa9\u3067\u5229\u7528<\/td>\n<td align=\"left\">-<\/td>\n<td align=\"left\"><code>-o \"-Dmacro=1\"<\/code><\/td>\n<\/tr>\n<tr>\n<td>[vtc_file or vtc_dir]<\/td>\n<td align=\"left\">vtc(varnish test case)\u30d5\u30a1\u30a4\u30eb\u304bvtc\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d1\u30b9\u3092\u6307\u5b9a\u3002glob\u3084\u8907\u6570\u6307\u5b9a\u4e0d\u53ef<\/td>\n<td align=\"left\"><code>tests\/<\/code><\/td>\n<td align=\"left\"><code>tests\/example.net.vtc<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u81ea\u5206\u306f\u6bce\u56de-c\u3067\u63a5\u7d9a\u5148\u3092\u6307\u5b9a\u3059\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u305f\u3081\u3001\u6b21\u306b\u8aac\u660e\u3059\u308bconf.sh\u3067\u63a5\u7d9a\u5148\u3092\u5b9a\u7fa9\u3057\u3066\u304a\u3044\u3066<\/p>\n<p>.\/vtc.sh -n prod tests\/foo.vtc<\/p>\n<p>\u3068\u3044\u3063\u305f\u3088\u3046\u306b\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>conf.sh<\/h3>\n<pre class=\"lang:sh decode:true\" title=\"conf.sh\">#!\/bin\/sh\n\n# Define the target server to be used with the -n option.\n# Example: if you want to target example.net when specifying `-n staging``, define C_staging=\"example.net\".\n# default is `C_default`.\nC_example=\"example.net\"\nC_default=\"${C_example}\"\n\n# Specify the path of the VTC.\n# This is the default value if VTC is not specified at execution.\nDEFAULT_VTC_DIR=\"${SCRIPT_DIR}\/tests\"\n\n# varnishd -j value(parallel)\nVTC_JOBS=3\n\n# varnishtest -b option(buffer size, default 1M)\nVTC_BUFFER_SIZE=3M\n\n# docker image name\nDOCKER_IMAGE_NAME=\"vtc-external-test\"<\/pre>\n<p>\u91cd\u8981\u306a\u306e\u306fC_[name]\u306e\u5909\u6570\u3067\u3059\u3002<br \/>\n\u8981\u306f\u3053\u308c\u304c\u63a5\u7d9a\u5148\u306a\u306e\u3067\u3001Akamai\u3067\u3042\u308c\u3070<\/p>\n<pre class=\"lang:sh decode:true\">C_stg=\"example.akamaized-staging.net\"\nC_prod=\"example.akamaized.net\"\nC_default=\"${C_stg}\"<\/pre>\n<p>\u3068\u66f8\u3044\u3066\u304a\u304f\u3068\u672a\u6307\u5b9a\u306e\u6642\u306fstg\u306b\u63a5\u7d9a\u3001prod\u3092\u6307\u5b9a\u3059\u308c\u3070\u672c\u756a\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3068\u3044\u3046\u5207\u308a\u66ff\u3048\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u66f8\u304d\u65b9\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p>\u5148\u307b\u3069\u306e\u30b5\u30f3\u30d7\u30eb\u306eHAProxy\u90e8\u5206\u306f\u5e38\u306b\u56fa\u5b9a\u306a\u306e\u3067\u305d\u306e\u90e8\u5206\u306f\u30b3\u30d4\u30da\u3057\u3064\u3064client\u90e8\u5206\u304b\u3089\u66f8\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u304a\u3001\u6b21\u306eVarnish\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304b\u3089include\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\uff08\u306f\u305a\uff09\u306e\u3067\u3001HAProxy\u90e8\u5206\u3092\u5207\u308a\u51fa\u3057\u3066\u30b7\u30f3\u30d7\u30eb\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\nclient\u90e8\u3082\u57fa\u672c\u306f\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3068\u30d8\u30c3\u30c0\u7a0b\u5ea6\u3057\u304b\u306a\u3044\u306e\u3067\u305d\u3053\u307e\u3067\u96e3\u3057\u304f\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u3044\u304f\u3064\u304b\u66f8\u304d\u65b9\u306e\u4f8b\u3092\u3042\u3052\u307e\u3059\u3002<\/p>\n<h3>Akamai\u306e\u30c7\u30d0\u30c3\u30b0\u30d8\u30c3\u30c0\u3092\u5229\u7528\u3059\u308b<\/h3>\n<p><a href=\"https:\/\/community.akamai.com\/customers\/s\/article\/Akamairxdxn3?language=en_US\">Pragma\u3067\u6307\u5b9a<\/a>\u3059\u308b\u3053\u3068\u3067\u8a73\u7d30\u306a\u60c5\u5831\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">client c_cid -connect ${h1_fe1_sock} {\n    txreq -req GET -url \"\/img\/test.gif\" -hdr \"Host: example.net\" -hdr \"Accept-Encoding: gzip\" \\\n    -hdr \"Pragma: akamai-x-check-cacheable,akamai-x-get-true-cache-key\"\n    rxresp\n    expect resp.status                            == \"200\"\n    expect resp.http.content-type                 == \"image\/gif\"\n    expect resp.http.x-check-cacheable            == \"YES\"\n    expect resp.http.cache-control                == \"max-age=10800, no-transform\"\n} -run<\/pre>\n<p>\u30c7\u30d0\u30c3\u30b0\u30d8\u30c3\u30c0\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u5bfe\u8c61\u304b\u3069\u3046\u304b\u3092\u30c6\u30b9\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u4ed6\u306b\u3082\u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\u306e\u30c1\u30a7\u30c3\u30af\u3082\u53ef\u80fd\u3067\u3059\u3002<br \/>\nPragma\u3092\u30d5\u30eb\u30bb\u30c3\u30c8\u3067\u6307\u5b9a\u3057\u3066\u3044\u306a\u3044\u306e\u306fvarnishtest\u306e\u5236\u9650\u3067\u30d8\u30c3\u30c0\u304c64\u884c\u3092\u8d85\u3048\u308b\u3068\u30a8\u30e9\u30fc\u3068\u306a\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u5272\u3068sensitive\u306a\u60c5\u5831\u304c\u3075\u304f\u307e\u308c\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u7d20\u306e\u307e\u307e\u51fa\u3055\u305a\u306b\u7279\u5b9a\u306e\u30d8\u30c3\u30c0\u3068\u30bb\u30c3\u30c8\u3067\u306a\u3044\u3068\u52d5\u304b\u306a\u3044\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u306e\u304c\u901a\u5e38\u3067\u3059\u3002<\/p>\n<h3>\u5916\u90e8\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u3088\u308a\u8a73\u7d30\u306a\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046(identify)<\/h3>\n<p>\u6700\u8fd1\u306f\u30b5\u30e0\u30cd\u30a4\u30eb\u306f\u52d5\u7684\u306b\u4f5c\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u304c\u3001\u7e26\u9577\u3084\u6a2a\u9577\u753b\u50cf\u3067\u610f\u56f3\u3057\u305f\u30b5\u30a4\u30ba\u306b\u53ce\u307e\u3063\u3066\u3044\u308b\u304b\u3001\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u610f\u56f3\u3057\u3066\u3044\u308b\u901a\u308a\u304b\u3068\u3044\u3063\u305f\u30c6\u30b9\u30c8\u3092\u884c\u3046\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<pre class=\"lang:default decode:true\">FROM ubuntu:jammy\n\nRUN export DEBIAN_FRONTEND=noninteractive &amp;&amp; \\\n    apt-get update &amp;&amp; \\\n    curl -s https:\/\/packagecloud.io\/install\/repositories\/varnishcache\/varnish74\/script.deb.sh | \/bin\/bash &amp;&amp; \\\n    apt-get install --no-install-recommends -yq haproxy curl ca-certificates &amp;&amp; \\\n    apt-get install --no-install-recommends -yq varnish &amp;&amp; \\\n    apt-get install --no-install-recommends -yq imagemagick \u2605\u3053\u308c\u3092\u8ffd\u52a0<\/pre>\n<p>Dockerfile\u306b\u30b3\u30de\u30f3\u30c9\uff08\u4eca\u56de\u306fidentify\u3092\u4f7f\u3046\u306e\u3067imagemagick\uff09\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<br \/>\n\u66f4\u65b0\u5f8c\u306evtc.sh\u521d\u56de\u5b9f\u884c\u6642\u306f-f\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\u3053\u3068\u3067image\u304c\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">client c_rsz1 -connect ${h1_fe1_sock} {\n    txreq -req GET -url \"\/52x52\/imgtest.png\" -hdr \"Host: example.net\" \\\n    -hdr \"Pragma: akamai-x-check-cacheable,akamai-x-get-true-cache-key\"\n    rxresp\n    expect resp.status                  == \"200\"\n    expect resp.http.x-check-cacheable  == \"YES\"\n    expect resp.http.cache-control      == \"max-age=3600, no-transform\"\n    expect resp.http.content-type       == \"image\/png\"\n    write_body testimg\n    shell -match \"PNG 52x52 \" { identify testimg }\n} -run\u3066<\/pre>\n<p>\u30c6\u30b9\u30c8\u306e\u30dd\u30a4\u30f3\u30c8\u306f<strong>write_body [filename]<\/strong>\u3068<strong>shell -match \"[REGEXP]\" {[command]}<\/strong>\u3067\u3059\u3002<br \/>\nwrite_body\u3092\u4f7f\u3046\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u3001shell\u3067\u4efb\u610f\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>\u30db\u30b9\u30c8\u540d\u3092\u5909\u3048\u305f\u3044<\/h3>\n<p>\u672c\u756a\u30c9\u30e1\u30a4\u30f3\u306fexample.net\u3067\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30c9\u30e1\u30a4\u30f3\u306fexample-stg.net\u306e\u5834\u5408\u3067vtc\u306f\u540c\u3058\u3082\u306e\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f\u30de\u30af\u30ed\u3092\u4f7f\u3046\u3068\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">client c_http -connect ${h1_fe1_sock} {\n  txreq -req GET -url \"\/\" -hdr \"Host: example${sfx}.net\"\n  rxresp\n  expect resp.status == \"200\"\n} -run\n<\/pre>\n<p>${sfx}\u304c\u30de\u30af\u30ed\u3067\u3001\u5f8c\u306fvtc.sh\u5b9f\u884c\u6642\u306b-Dsfx='[replacement]'\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true\">$ .\/vtc.sh -c example.net -o \"-Dsfx=''\" tests\/example.vtc \n==============================================\n  Target Server: example.net\n            VTC: \/home\/xcir\/work\/akamai\/infra-akamai-pm-terraform\/vtc\/tests\/example.vtc\n     VTC Option: -Dsfx=''\n==============================================\n#    top  TEST \/mnt\/tests\/test.vtc passed (5.926)\n<\/pre>\n<pre class=\"lang:sh decode:true\">$ .\/vtc.sh -c example.net -o \"-Dsfx='-stg'\" tests\/example.vtc \n==============================================\n  Target Server: example.net\n            VTC: \/home\/xcir\/work\/akamai\/infra-akamai-pm-terraform\/vtc\/tests\/example.vtc\n     VTC Option: -Dsfx='-stg'\n==============================================\n**** dT    0.000\n...\n***  c_http connected fd 6 from 127.0.0.1 38120 to 127.0.0.1:38985\n**   c_http === txreq -req GET -url \"\/\" -hdr \"Host: example-stg.net\"\n**** c_http txreq|GET \/ HTTP\/1.1\\r\n**** c_http txreq|Host: example-stg.net\\r\u2605\u2605example-stg.net\u306b\u306a\u3063\u3066\u3044\u308b\n**** c_http txreq|\\r\n...\n---- c_http EXPECT resp.status (404) == \"200\" failed\n*    top   RESETTING after \/mnt\/tests\/test.vtc\n**   h1    Reset and free h1 haproxy 15\n**   h1    Wait\n**   h1    Stop HAproxy pid=15\n**** h1    Kill(2)=0: Success\n**** dT    5.848\n**** h1    STDOUT EOF\n**** dT    5.947\n**   h1    WAIT4 pid=15 status=0x0002 (user 0.146294 sys 0.000000)\n**** dT    5.948\n*    top   TEST \/mnt\/tests\/test.vtc FAILED\n#    top  TEST \/mnt\/tests\/test.vtc FAILED (5.948) exit=2<\/pre>\n<p>\u4e00\u70b9\u6ce8\u610f\u304c\u3042\u308b\u306e\u306f\u672a\u6307\u5b9a\u306e\u5834\u5408\u306f\u305d\u306e\u307e\u307e\u306e\u6587\u5b57\u5217(${sfx})\u304c\u6b8b\u308b\u306e\u3067\u3001-stg\u304c\u4e0d\u8981\u306a\u6642\u3067\u3082\u6307\u5b9a\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>vtc\u306f\u69d8\u3005\u306a\u6a5f\u80fd\u304c\u3042\u308b\u306e\u3067\u8a73\u7d30\u306f<a href=\"https:\/\/varnish-cache.org\/docs\/trunk\/reference\/vtc.html\">\u3053\u3061\u3089\u3092\u53c2\u7167<\/a>\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30c6\u30b9\u30c8\u5b9f\u884c\u6642\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>\u5f53\u305f\u308a\u524d\u3067\u3059\u304cCDN\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305a\u30c6\u30b9\u30c8\u3092\u884c\u3046\u5834\u5408\u306f\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3060\u3063\u305f\u308a\u5225\u30c9\u30e1\u30a4\u30f3\u3060\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u30d1\u30fc\u30b8\u3092\u884c\u3046\u306a\u3069\u3057\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3048\u308b\u72b6\u614b\u306b\u3057\u307e\u3057\u3087\u3046<\/p>\n<h1>\u6700\u5f8c\u306b<\/h1>\n<p>CDN\u306b\u8907\u96d1\u306a\u30b3\u30fc\u30c9\u3092\u7f6e\u304f\u4ee5\u4e0a\u30c6\u30b9\u30c8\u3092\u5341\u5206\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u304b\u3068\u3044\u3063\u3066hosts\u66f8\u304d\u63db\u3048\u3067\u304c\u3093\u3070\u3063\u305f\u308a\u3059\u308b\u306e\u306f\u306a\u304b\u306a\u304b\u8f9b\u3044\u3067\u3059\u3057\u4e00\u3064\u306e\u6848\u3068\u3057\u3066varnishtest\u3092\u5229\u7528\u3057\u305f\u30c6\u30b9\u30c8\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306fCDN\u3092\u30c6\u30b9\u30c8\u3059\u308b\u304c\u30c6\u30fc\u30de\u3067\u3057\u305f\u304c\u3001\u3082\u3061\u308d\u3093CDN\u4ee5\u5916\u3067\u3082\u30c6\u30b9\u30c8\u306f\u53ef\u80fd\u306a\u306e\u3067\u3061\u3087\u3063\u3068\u3057\u305fHTTP\/S\u7d4c\u7531\u3067UT\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306b\u306f\u6709\u7528\u3060\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30d5\u30e9\u306e\u3044\u308f\u306a\u3061\u3083\u3093\u3055\u3093(@xcir)\u3067\u3059\u3002 \u5148\u306e\u8a18\u4e8b\u3067\u306fTerraform\u3067Akamai\u3092\u904b\u7528\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u66f8\u304d\u307e\u3057\u305f\u3002 \u8a18\u4e8b\u4e2d\u3067\u30c6\u30b9\u30c8\u306b\u3064\u3044\u3066\u89e6\u308c\u307e\u3057\u305f\u304c\u3001\u3075\u3068\u8003\u3048\u305f\u3089CDN\u306b\u5bfe\u3057\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3046\u4e8b\u4f8b\u3092\u3042\u307e\u308a\u805e\u3044\u305f [&hellip;]<\/p>\n","protected":false},"author":136,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[211,52],"class_list":["post-23009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-cdn","tag-varnish-cache"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/23009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/136"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=23009"}],"version-history":[{"count":31,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/23009\/revisions"}],"predecessor-version":[{"id":23073,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/23009\/revisions\/23073"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=23009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=23009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=23009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}