{"action":"created","comment":{"url":"https://api.github.com/repos/sigma-dev/sigma/pulls/comments/130162337","pull_request_review_id":53012338,"id":130162337,"diff_hunk":"@@ -0,0 +1,243 @@\n+package sigtest\n+\n+import (\n+\t\"bytes\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"path\"\n+\t\"runtime\"\n+\t\"strconv\"\n+\t\"strings\"\n+\t\"testing\"\n+\t\"time\"\n+\n+\t\"github.com/sigma-dev/sigma/cmd\"\n+\tsigmaconfig \"github.com/sigma-dev/sigma/config\"\n+)\n+\n+func RunTestDev(t *testing.T, standalone bool) {\n+\tReset(&Config)\n+\trmFunc := setupDockerSaveDir(&Config)\n+\tif standalone {\n+\t\tdefer rmFunc()\n+\t}\n+\tsetupCommon(&Config)\n+\n+\tsetupNullDB(&Config)\n+\tsetupChannelInit(&Config)\n+\n+\tnotifyWait(t, \"dev\", \"test\", Config)\n+\tRunTests(t, Config, standalone)\n+}\n+\n+func RunTestDocker(t *testing.T, standalone bool) {\n+\tReset(&Config)\n+\trmFunc := setupDockerSaveDir(&Config)\n+\tsetupCommon(&Config)\n+\n+\tcbClearFunc := setupCouchbaseDB(&Config)\n+\n+\trbClearFunc := setupRabbit(&Config)\n+\tif standalone {\n+\t\tdefer rmFunc()\n+\t}\n+\trbClearFunc()\n+\tcbClearFunc()\n+\tsetupAuthDB(&Config)\n+\n+\tnotifyWait(t, \"docker\", \"test\", Config)\n+\tRunTests(t, Config, standalone)\n+}\n+\n+func RunTestNomad(t *testing.T, standalone bool) {\n+\tReset(&Config)\n+\tsetupCommon(&Config)\n+\tsetupAuthLDAP(&Config)\n+\tsetupNomad(&Config)\n+\tcbClearFunc := setupCouchbaseDB(&Config)\n+\trbClearFunc := setupRabbit(&Config)\n+\tcbClearFunc()\n+\trbClearFunc()\n+\tnotifyWait(t, \"nomad\", \"test\", Config)\n+\tRunTests(t, Config, standalone)\n+}\n+\n+func notify(t *testing.T, this string, queryParam string, cfg TestConfig) {\n+\tif cfg.Notify == \"\" {\n+\t\treturn\n+\t}\n+\tcfg.TestMode = this\n+\tif !strings.Contains(cfg.Notify, \"http\") {\n+\t\tcfg.Notify = \"http://\" + cfg.Notify\n+\t}\n+\tcfg.Args = append(cfg.Args, \"--couchbase-host\", cfg.notifyURL(8091), \"--rabbit-url\", cfg.notifyURL(5672), \"--nomad-client-url\", cfg.notifyURL(4646), \"--auth-ldap-host\", cfg.notifyURL(0))\n+\turl := fmt.Sprintf(\"%v?%v=%v\", cfg.Notify, queryParam, this)\n+\tb, err := json.Marshal(cfg)\n+\tif err != nil {\n+\t\tt.Fatal(\"Error Marshaling Config: \", err)\n+\t\tt.FailNow()\n+\t\tos.Exit(1)\n+\t}\n+\tr := bytes.NewReader(b)\n+\ti := 10\n+\tfor ; i > 0; i-- {\n+\t\tresp, err := http.Post(url, \"text/json\", r)\n+\t\tif resp != nil && resp.StatusCode == http.StatusInternalServerError {\n+\t\t\tt.Fatal(\"Could not setup test... failing\", err)\n+\t\t\tt.FailNow()\n+\t\t\tos.Exit(1)\n+\t\t}\n+\t\tif err != nil || resp == nil || resp.StatusCode != http.StatusOK {\n+\t\t\tt.Log(\"Error Posting to Endpoint: \", err)\n+\t\t\ttime.Sleep(10 * time.Second)\n+\t\t\tcontinue\n+\t\t}\n+\t\tresp.Body.Close()\n+\t\tbreak\n+\t}\n+\tif i == 0 {\n+\t\tt.Fatal(\"Could not reach endpoint. Failing.\", err)\n+\t\tt.FailNow()\n+\t\tos.Exit(1)\n+\t}\n+\treturn\n+}\n+\n+func notifyWait(t *testing.T, this string, queryParam string, cfg TestConfig) {\n+\tnotify(t, this, queryParam, cfg)\n+\tif cfg.Wait == \"\" {\n+\t\treturn\n+\t}\n+\ttm, err := time.ParseDuration(cfg.Wait)\n+\tif err != nil {\n+\t\tt.Log(\"Bad Duration: \", err, \" not waiting.\")\n+\t\treturn\n+\t}\n+\ttime.Sleep(tm)\n+}\n+\n+func RunTests(t *testing.T, cfg TestConfig, standalone bool) {\n+\tchannel := make(chan bool)\n+\tif standalone {\n+\t\tc := cmd.SigmaCmd\n+\t\tc.SetArgs(cfg.Args)\n+\t\tsigmaconfig.InitFlags(c)\n+\t\tgo func() {\n+\t\t\tcmd.SigmaCmd.Execute()","path":"tests/functional/sigtest/run.go","position":128,"original_position":128,"commit_id":"e09f16b88790ce77d13529f5456abc5b3b495bec","original_commit_id":"e09f16b88790ce77d13529f5456abc5b3b495bec","user":{"login":"stephenrlouie","id":2810544,"avatar_url":"https://avatars0.githubusercontent.com/u/2810544?v=4","gravatar_id":"","url":"https://api.github.com/users/stephenrlouie","html_url":"https://github.com/stephenrlouie","followers_url":"https://api.github.com/users/stephenrlouie/followers","following_url":"https://api.github.com/users/stephenrlouie/following{/other_user}","gists_url":"https://api.github.com/users/stephenrlouie/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenrlouie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenrlouie/subscriptions","organizations_url":"https://api.github.com/users/stephenrlouie/orgs","repos_url":"https://api.github.com/users/stephenrlouie/repos","events_url":"https://api.github.com/users/stephenrlouie/events{/privacy}","received_events_url":"https://api.github.com/users/stephenrlouie/received_events","type":"User","site_admin":false},"body":"Err catch?","created_at":"2017-07-28T18:58:16Z","updated_at":"2017-07-28T18:58:16Z","html_url":"https://github.com/sigma-dev/sigma/pull/270#discussion_r130162337","pull_request_url":"https://api.github.com/repos/sigma-dev/sigma/pulls/270","_links":{"self":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/comments/130162337"},"html":{"href":"https://github.com/sigma-dev/sigma/pull/270#discussion_r130162337"},"pull_request":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/270"}}},"pull_request":{"url":"https://api.github.com/repos/sigma-dev/sigma/pulls/270","id":131807862,"html_url":"https://github.com/sigma-dev/sigma/pull/270","diff_url":"https://github.com/sigma-dev/sigma/pull/270.diff","patch_url":"https://github.com/sigma-dev/sigma/pull/270.patch","issue_url":"https://api.github.com/repos/sigma-dev/sigma/issues/270","number":270,"state":"open","locked":false,"title":"New Functional Tests","user":{"login":"mikeynap","id":704427,"avatar_url":"https://avatars0.githubusercontent.com/u/704427?v=4","gravatar_id":"","url":"https://api.github.com/users/mikeynap","html_url":"https://github.com/mikeynap","followers_url":"https://api.github.com/users/mikeynap/followers","following_url":"https://api.github.com/users/mikeynap/following{/other_user}","gists_url":"https://api.github.com/users/mikeynap/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeynap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeynap/subscriptions","organizations_url":"https://api.github.com/users/mikeynap/orgs","repos_url":"https://api.github.com/users/mikeynap/repos","events_url":"https://api.github.com/users/mikeynap/events{/privacy}","received_events_url":"https://api.github.com/users/mikeynap/received_events","type":"User","site_admin":false},"body":"See the functional test case of https://github.com/sigma-dev/sigma/blob/master/tests/plan.md\r\n- Functional Tests that run in Dev/Docker/Nomad[lol] mode.\r\n- Supports starting/stopping sigma directly if `go test GitHub.com/sigma-dev/sigma/tests/functional` is used. \r\n- The `go test -run` command can be used to specify which test cases to run. `go test -run TestDev` runs all the subtests in Dev configuration. A specific subtest can be run with `go test -run TestDev/SubTestName`. Regexes can be used as normal.\r\n- Running `go test GitHub.com/sigma-dev/sigma/tests/functional/sigtest` assumes sigma has been started externally. It is up to the caller to start/stop the sigma instances between runs. Also expects an -address flag to specify the endpoint to hit. Since this mode/package does not directly start/stop/clear sigma/thedb, the -run argument is required (otherwise it would try to run all three modes back to back, but that obviously would fail since sigma would not have been shutdown between calls). \r\n\r\nThe tests also support a few cases for running with an external orchestrator:\r\n- An optional -wait flag can be provided to wait before the major tests cases (dev/docker,etc) so that some other service can restart/reconfigure the sigma instance between calls. If doing some automated deployment, setting wait to be a few minutes should be sufficient for the deployer to reconfigure sigma. \r\n- An optional -notify flag can be provided to hit an endpoint when one of the major test cases is about to start. This can be used to trigger a specific configuration of sigma. The url will include a test=testThatWillRun query parameter.\r\n- If these are both used, the -run parameter should not be required (one should be able to run all three tests with an external sigma since it will be orchestrated.).\r\n- An alternate strategy is to not supply a -wait parameter and have the endpoint keep the initial status post alive until it has setup sigma.","created_at":"2017-07-21T16:06:10Z","updated_at":"2017-07-28T18:58:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d658afeb23d4d2a1238e5fe2661698bd8b2c111","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sigma-dev/sigma/pulls/270/commits","review_comments_url":"https://api.github.com/repos/sigma-dev/sigma/pulls/270/comments","review_comment_url":"https://api.github.com/repos/sigma-dev/sigma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sigma-dev/sigma/issues/270/comments","statuses_url":"https://api.github.com/repos/sigma-dev/sigma/statuses/e09f16b88790ce77d13529f5456abc5b3b495bec","head":{"label":"sigma-dev:testStrat","ref":"testStrat","sha":"e09f16b88790ce77d13529f5456abc5b3b495bec","user":{"login":"sigma-dev","id":27972812,"avatar_url":"https://avatars0.githubusercontent.com/u/27972812?v=4","gravatar_id":"","url":"https://api.github.com/users/sigma-dev","html_url":"https://github.com/sigma-dev","followers_url":"https://api.github.com/users/sigma-dev/followers","following_url":"https://api.github.com/users/sigma-dev/following{/other_user}","gists_url":"https://api.github.com/users/sigma-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/sigma-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigma-dev/subscriptions","organizations_url":"https://api.github.com/users/sigma-dev/orgs","repos_url":"https://api.github.com/users/sigma-dev/repos","events_url":"https://api.github.com/users/sigma-dev/events{/privacy}","received_events_url":"https://api.github.com/users/sigma-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":89404176,"name":"sigma","full_name":"sigma-dev/sigma","owner":{"login":"sigma-dev","id":27972812,"avatar_url":"https://avatars0.githubusercontent.com/u/27972812?v=4","gravatar_id":"","url":"https://api.github.com/users/sigma-dev","html_url":"https://github.com/sigma-dev","followers_url":"https://api.github.com/users/sigma-dev/followers","following_url":"https://api.github.com/users/sigma-dev/following{/other_user}","gists_url":"https://api.github.com/users/sigma-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/sigma-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigma-dev/subscriptions","organizations_url":"https://api.github.com/users/sigma-dev/orgs","repos_url":"https://api.github.com/users/sigma-dev/repos","events_url":"https://api.github.com/users/sigma-dev/events{/privacy}","received_events_url":"https://api.github.com/users/sigma-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sigma-dev/sigma","description":null,"fork":false,"url":"https://api.github.com/repos/sigma-dev/sigma","forks_url":"https://api.github.com/repos/sigma-dev/sigma/forks","keys_url":"https://api.github.com/repos/sigma-dev/sigma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sigma-dev/sigma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sigma-dev/sigma/teams","hooks_url":"https://api.github.com/repos/sigma-dev/sigma/hooks","issue_events_url":"https://api.github.com/repos/sigma-dev/sigma/issues/events{/number}","events_url":"https://api.github.com/repos/sigma-dev/sigma/events","assignees_url":"https://api.github.com/repos/sigma-dev/sigma/assignees{/user}","branches_url":"https://api.github.com/repos/sigma-dev/sigma/branches{/branch}","tags_url":"https://api.github.com/repos/sigma-dev/sigma/tags","blobs_url":"https://api.github.com/repos/sigma-dev/sigma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sigma-dev/sigma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sigma-dev/sigma/git/refs{/sha}","trees_url":"https://api.github.com/repos/sigma-dev/sigma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sigma-dev/sigma/statuses/{sha}","languages_url":"https://api.github.com/repos/sigma-dev/sigma/languages","stargazers_url":"https://api.github.com/repos/sigma-dev/sigma/stargazers","contributors_url":"https://api.github.com/repos/sigma-dev/sigma/contributors","subscribers_url":"https://api.github.com/repos/sigma-dev/sigma/subscribers","subscription_url":"https://api.github.com/repos/sigma-dev/sigma/subscription","commits_url":"https://api.github.com/repos/sigma-dev/sigma/commits{/sha}","git_commits_url":"https://api.github.com/repos/sigma-dev/sigma/git/commits{/sha}","comments_url":"https://api.github.com/repos/sigma-dev/sigma/comments{/number}","issue_comment_url":"https://api.github.com/repos/sigma-dev/sigma/issues/comments{/number}","contents_url":"https://api.github.com/repos/sigma-dev/sigma/contents/{+path}","compare_url":"https://api.github.com/repos/sigma-dev/sigma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sigma-dev/sigma/merges","archive_url":"https://api.github.com/repos/sigma-dev/sigma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sigma-dev/sigma/downloads","issues_url":"https://api.github.com/repos/sigma-dev/sigma/issues{/number}","pulls_url":"https://api.github.com/repos/sigma-dev/sigma/pulls{/number}","milestones_url":"https://api.github.com/repos/sigma-dev/sigma/milestones{/number}","notifications_url":"https://api.github.com/repos/sigma-dev/sigma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sigma-dev/sigma/labels{/name}","releases_url":"https://api.github.com/repos/sigma-dev/sigma/releases{/id}","deployments_url":"https://api.github.com/repos/sigma-dev/sigma/deployments","created_at":"2017-04-25T20:33:14Z","updated_at":"2017-06-29T21:12:04Z","pushed_at":"2017-07-28T18:56:42Z","git_url":"git://github.com/sigma-dev/sigma.git","ssh_url":"git@github.com:sigma-dev/sigma.git","clone_url":"https://github.com/sigma-dev/sigma.git","svn_url":"https://github.com/sigma-dev/sigma","homepage":"https://sigma-dev.github.io/sigma","size":9896,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":6,"default_branch":"master"}},"base":{"label":"sigma-dev:master","ref":"master","sha":"b11eb5a5f0cb67ab18a54a41dd6c01f8e8242a75","user":{"login":"sigma-dev","id":27972812,"avatar_url":"https://avatars0.githubusercontent.com/u/27972812?v=4","gravatar_id":"","url":"https://api.github.com/users/sigma-dev","html_url":"https://github.com/sigma-dev","followers_url":"https://api.github.com/users/sigma-dev/followers","following_url":"https://api.github.com/users/sigma-dev/following{/other_user}","gists_url":"https://api.github.com/users/sigma-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/sigma-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigma-dev/subscriptions","organizations_url":"https://api.github.com/users/sigma-dev/orgs","repos_url":"https://api.github.com/users/sigma-dev/repos","events_url":"https://api.github.com/users/sigma-dev/events{/privacy}","received_events_url":"https://api.github.com/users/sigma-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":89404176,"name":"sigma","full_name":"sigma-dev/sigma","owner":{"login":"sigma-dev","id":27972812,"avatar_url":"https://avatars0.githubusercontent.com/u/27972812?v=4","gravatar_id":"","url":"https://api.github.com/users/sigma-dev","html_url":"https://github.com/sigma-dev","followers_url":"https://api.github.com/users/sigma-dev/followers","following_url":"https://api.github.com/users/sigma-dev/following{/other_user}","gists_url":"https://api.github.com/users/sigma-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/sigma-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigma-dev/subscriptions","organizations_url":"https://api.github.com/users/sigma-dev/orgs","repos_url":"https://api.github.com/users/sigma-dev/repos","events_url":"https://api.github.com/users/sigma-dev/events{/privacy}","received_events_url":"https://api.github.com/users/sigma-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sigma-dev/sigma","description":null,"fork":false,"url":"https://api.github.com/repos/sigma-dev/sigma","forks_url":"https://api.github.com/repos/sigma-dev/sigma/forks","keys_url":"https://api.github.com/repos/sigma-dev/sigma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sigma-dev/sigma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sigma-dev/sigma/teams","hooks_url":"https://api.github.com/repos/sigma-dev/sigma/hooks","issue_events_url":"https://api.github.com/repos/sigma-dev/sigma/issues/events{/number}","events_url":"https://api.github.com/repos/sigma-dev/sigma/events","assignees_url":"https://api.github.com/repos/sigma-dev/sigma/assignees{/user}","branches_url":"https://api.github.com/repos/sigma-dev/sigma/branches{/branch}","tags_url":"https://api.github.com/repos/sigma-dev/sigma/tags","blobs_url":"https://api.github.com/repos/sigma-dev/sigma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sigma-dev/sigma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sigma-dev/sigma/git/refs{/sha}","trees_url":"https://api.github.com/repos/sigma-dev/sigma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sigma-dev/sigma/statuses/{sha}","languages_url":"https://api.github.com/repos/sigma-dev/sigma/languages","stargazers_url":"https://api.github.com/repos/sigma-dev/sigma/stargazers","contributors_url":"https://api.github.com/repos/sigma-dev/sigma/contributors","subscribers_url":"https://api.github.com/repos/sigma-dev/sigma/subscribers","subscription_url":"https://api.github.com/repos/sigma-dev/sigma/subscription","commits_url":"https://api.github.com/repos/sigma-dev/sigma/commits{/sha}","git_commits_url":"https://api.github.com/repos/sigma-dev/sigma/git/commits{/sha}","comments_url":"https://api.github.com/repos/sigma-dev/sigma/comments{/number}","issue_comment_url":"https://api.github.com/repos/sigma-dev/sigma/issues/comments{/number}","contents_url":"https://api.github.com/repos/sigma-dev/sigma/contents/{+path}","compare_url":"https://api.github.com/repos/sigma-dev/sigma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sigma-dev/sigma/merges","archive_url":"https://api.github.com/repos/sigma-dev/sigma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sigma-dev/sigma/downloads","issues_url":"https://api.github.com/repos/sigma-dev/sigma/issues{/number}","pulls_url":"https://api.github.com/repos/sigma-dev/sigma/pulls{/number}","milestones_url":"https://api.github.com/repos/sigma-dev/sigma/milestones{/number}","notifications_url":"https://api.github.com/repos/sigma-dev/sigma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sigma-dev/sigma/labels{/name}","releases_url":"https://api.github.com/repos/sigma-dev/sigma/releases{/id}","deployments_url":"https://api.github.com/repos/sigma-dev/sigma/deployments","created_at":"2017-04-25T20:33:14Z","updated_at":"2017-06-29T21:12:04Z","pushed_at":"2017-07-28T18:56:42Z","git_url":"git://github.com/sigma-dev/sigma.git","ssh_url":"git@github.com:sigma-dev/sigma.git","clone_url":"https://github.com/sigma-dev/sigma.git","svn_url":"https://github.com/sigma-dev/sigma","homepage":"https://sigma-dev.github.io/sigma","size":9896,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/270"},"html":{"href":"https://github.com/sigma-dev/sigma/pull/270"},"issue":{"href":"https://api.github.com/repos/sigma-dev/sigma/issues/270"},"comments":{"href":"https://api.github.com/repos/sigma-dev/sigma/issues/270/comments"},"review_comments":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/270/comments"},"review_comment":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sigma-dev/sigma/pulls/270/commits"},"statuses":{"href":"https://api.github.com/repos/sigma-dev/sigma/statuses/e09f16b88790ce77d13529f5456abc5b3b495bec"}}}}
{"actor":{"display_login":"stephenrlouie"}}