{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/comments/72347212","id":72347212,"diff_hunk":"@@ -0,0 +1,126 @@\n+# Test helpers for BATS tests\n+\n+IMAGE=custom-script\n+DOCKERFILE=test.Dockerfile\n+TEST_CONTAINER=test\n+\n+certs_dir=\"$BATS_TEST_DIRNAME/certs\"\n+\n+build_docker_image() {\n+    echo \"Building test image...\"\n+    docker build -q -f $DOCKERFILE -t $IMAGE . 1>&2\n+}\n+\n+in_tmp_container() {\n+    docker run --rm $IMAGE \"$@\"\n+}\n+\n+rm_container() {\n+    docker rm -f $TEST_CONTAINER &>/dev/null && \\\n+        echo \"Deleted test container.\" || true\n+}\n+\n+mk_container() {\n+    rm_container && echo \"Creating test container with commands: $@\">&2 && \\\n+        docker create --name=$TEST_CONTAINER $IMAGE \"$@\" 1>/dev/null\n+}\n+\n+in_container() {\n+    set -e\n+    rm_container\n+    mk_container \"$@\"\n+    echo \"Starting test container...\">&2\n+    start_container\n+}\n+\n+start_container() {\n+    docker start --attach $TEST_CONTAINER\n+}\n+\n+container_diff() {\n+    docker diff $TEST_CONTAINER\n+}\n+\n+container_read_file() { # reads the file at container path $1\n+    set -eo pipefail\n+    docker cp $TEST_CONTAINER:\"$1\" - | tar x --to-stdout\n+} \n+\n+mk_certs() { # creates certs/{THUMBPRINT}.(crt|key) files under ./certs/ and prints THUMBPRINT\n+    set -eo pipefail\n+    mkdir -p \"$certs_dir\" && cd \"$certs_dir\" && rm -f \"$certs_dir/*\"\n+    openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes -batch &>/dev/null\n+    thumbprint=$(openssl x509 -in cert.pem -fingerprint -noout| sed 's/.*=//g' | sed 's/://g')","path":"integration-test/test/test_helper.bash","position":53,"original_position":53,"commit_id":"7396c150bd8e56ffb1a4ce6b60f0f5f4c70e8cab","original_commit_id":"7396c150bd8e56ffb1a4ce6b60f0f5f4c70e8cab","user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"body":"@boumenot I'm just preserving the terminology of waagent (authored by people stayed here too long as well)","created_at":"2016-07-26T22:07:27Z","updated_at":"2016-07-26T22:07:27Z","html_url":"https://github.com/Azure/custom-script-extension-linux/pull/32#discussion_r72347212","pull_request_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/comments/72347212"},"html":{"href":"https://github.com/Azure/custom-script-extension-linux/pull/32#discussion_r72347212"},"pull_request":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32","id":78793826,"html_url":"https://github.com/Azure/custom-script-extension-linux/pull/32","diff_url":"https://github.com/Azure/custom-script-extension-linux/pull/32.diff","patch_url":"https://github.com/Azure/custom-script-extension-linux/pull/32.patch","issue_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/32","number":32,"state":"open","locked":false,"title":"integration-test: add test scenarios","user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"body":"The integration tests use `bats` to run the scenarios as bash scripts.\r\n\r\nTo test the extension handler functionality, we simply:\r\n\r\n- build a Docker image using test.Dockerfile\r\n    - copy some files from ` make it look like a `/var/lib/waagent` directory\r\n    - copy extension binary into the container\r\n- remove the `test` container if it exists\r\n- create a Docker container (name: `test`) from image\r\n    - specify which handler subcommand will be invoked (e.g. `fake-waagent\r\n      install`)\r\n- push .settings file and certificate/private key to the container (.crt, .prv)\r\n    - do other things on the container that we need to craft the environment\r\n- start the container\r\n- collect the output from the command execution\r\n- validate using the following:\r\n    - check status code\r\n    - validate output of the command\r\n    - `docker diff test` to validate file changes in the container\r\n    - copy files out of container and validate their contents\r\n","created_at":"2016-07-26T05:33:50Z","updated_at":"2016-07-26T22:07:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"542b3440082bb39af33bc41fea1efd98955a135a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32/commits","review_comments_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32/comments","review_comment_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/32/comments","statuses_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/statuses/7396c150bd8e56ffb1a4ce6b60f0f5f4c70e8cab","head":{"label":"ahmetalpbalkan:integration-tests","ref":"integration-tests","sha":"7396c150bd8e56ffb1a4ce6b60f0f5f4c70e8cab","user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"repo":{"id":62758777,"name":"custom-script-extension-linux-1","full_name":"ahmetalpbalkan/custom-script-extension-linux-1","owner":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ahmetalpbalkan/custom-script-extension-linux-1","description":"Azure Custom Script Virtual Machine Extension","fork":true,"url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1","forks_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/forks","keys_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/teams","hooks_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/hooks","issue_events_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/issues/events{/number}","events_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/events","assignees_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/assignees{/user}","branches_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/branches{/branch}","tags_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/tags","blobs_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/statuses/{sha}","languages_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/languages","stargazers_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/stargazers","contributors_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/contributors","subscribers_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/subscribers","subscription_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/subscription","commits_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/contents/{+path}","compare_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/merges","archive_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/downloads","issues_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/issues{/number}","pulls_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/pulls{/number}","milestones_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/milestones{/number}","notifications_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/labels{/name}","releases_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/releases{/id}","deployments_url":"https://api.github.com/repos/ahmetalpbalkan/custom-script-extension-linux-1/deployments","created_at":"2016-07-06T22:59:45Z","updated_at":"2016-07-06T22:41:59Z","pushed_at":"2016-07-26T21:42:22Z","git_url":"git://github.com/ahmetalpbalkan/custom-script-extension-linux-1.git","ssh_url":"git@github.com:ahmetalpbalkan/custom-script-extension-linux-1.git","clone_url":"https://github.com/ahmetalpbalkan/custom-script-extension-linux-1.git","svn_url":"https://github.com/ahmetalpbalkan/custom-script-extension-linux-1","homepage":null,"size":319,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"10c9068bd9bdb0ce4b303498771bcc15389dffd7","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":62758014,"name":"custom-script-extension-linux","full_name":"Azure/custom-script-extension-linux","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/custom-script-extension-linux","description":"Azure Custom Script Virtual Machine Extension","fork":false,"url":"https://api.github.com/repos/Azure/custom-script-extension-linux","forks_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/forks","keys_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/teams","hooks_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/hooks","issue_events_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/events","assignees_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/tags","blobs_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/languages","stargazers_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/stargazers","contributors_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/contributors","subscribers_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/subscribers","subscription_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/subscription","commits_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/merges","archive_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/downloads","issues_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/labels{/name}","releases_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/custom-script-extension-linux/deployments","created_at":"2016-07-06T22:41:59Z","updated_at":"2016-07-06T23:43:13Z","pushed_at":"2016-07-26T21:43:13Z","git_url":"git://github.com/Azure/custom-script-extension-linux.git","ssh_url":"git@github.com:Azure/custom-script-extension-linux.git","clone_url":"https://github.com/Azure/custom-script-extension-linux.git","svn_url":"https://github.com/Azure/custom-script-extension-linux","homepage":null,"size":307,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32"},"html":{"href":"https://github.com/Azure/custom-script-extension-linux/pull/32"},"issue":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/32"},"comments":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/custom-script-extension-linux/statuses/7396c150bd8e56ffb1a4ce6b60f0f5f4c70e8cab"}}}}
{"actor":{"display_login":"ahmetalpbalkan"}}