Skip to content

Commit 561d5e9

Browse files
committed
feat: Move more tests to GHE
Move more tests to GHE, avoiding as much as possible GitHUb.com, and using the local GHE instance instead. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent bfcbb1b commit 561d5e9

11 files changed

+50
-53
lines changed

test/gitea_access_control_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func TestGiteaACLCommentsAllowingRememberOkToTestFalse(t *testing.T) {
290290
cfgMapData := map[string]string{
291291
"remember-ok-to-test": "false",
292292
}
293-
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, cfgMapData)()
293+
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, "pipelines-as-code", cfgMapData)()
294294

295295
_, f := tgitea.TestPR(t, topts)
296296
defer f()

test/gitea_params_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestGiteaParamsOnRepoCRWithCustomConsole(t *testing.T) {
110110
"custom-console-url-pr-tasklog": "https://url/log/{{ custom }}",
111111
"tekton-dashboard-url": "",
112112
}
113-
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, cfgMapData)()
113+
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, "pipelines-as-code", cfgMapData)()
114114
_, f := tgitea.TestPR(t, topts)
115115
defer f()
116116
// topts.Regexp = regexp.MustCompile(`(?m).*Custom Console.*https://url/detail/myconsole.*https://url/log/myconsole`)

test/gitea_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ func TestGiteaErrorSnippetCustomLines(t *testing.T) {
891891
cfgMapData := map[string]string{
892892
"error-log-snippet-number-of-lines": "5",
893893
}
894-
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, cfgMapData)()
894+
defer configmap.ChangeGlobalConfig(ctx, t, topts.ParamsRun, "pipelines-as-code", cfgMapData)()
895895

896896
_, f := tgitea.TestPR(t, topts)
897897
defer f()

test/github_pullrequest_oktotest_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121
)
2222

23-
func TestGithubPullRequestOkToTest(t *testing.T) {
23+
func TestGithubGHEPullRequestOkToTest(t *testing.T) {
2424
if os.Getenv("NIGHTLY_E2E_TEST") != "true" {
2525
t.Skip("Skipping test since only enabled for nightly")
2626
}
2727
ctx := context.TODO()
2828
g := &tgithub.PRTest{
2929
Label: "Github OkToTest comment",
3030
YamlFiles: []string{"testdata/pipelinerun.yaml"},
31+
GHE: true,
3132
}
3233
g.RunPullRequest(ctx, t)
3334
defer g.TearDown(ctx, t)
@@ -46,7 +47,7 @@ func TestGithubPullRequestOkToTest(t *testing.T) {
4647
Sender: g.Options.Organization,
4748
}
4849

49-
installID, err := strconv.ParseInt(os.Getenv("TEST_GITHUB_REPO_INSTALLATION_ID"), 10, 64)
50+
installID, err := strconv.ParseInt(os.Getenv("TEST_GITHUB_SECOND_APPLICATION_ID"), 10, 64)
5051
assert.NilError(t, err)
5152
event := github.IssueCommentEvent{
5253
Comment: &github.IssueComment{
@@ -59,9 +60,7 @@ func TestGithubPullRequestOkToTest(t *testing.T) {
5960
Issue: &github.Issue{
6061
State: github.Ptr("open"),
6162
PullRequestLinks: &github.PullRequestLinks{
62-
HTMLURL: github.Ptr(fmt.Sprintf("%s/%s/pull/%d",
63-
os.Getenv("TEST_GITHUB_API_URL"),
64-
os.Getenv("TEST_GITHUB_REPO_OWNER"), g.PRNumber)),
63+
HTMLURL: github.Ptr(fmt.Sprintf("%s/pull/%d", runevent.URL, g.PRNumber)),
6564
},
6665
},
6766
Repo: &github.Repository{
@@ -77,10 +76,10 @@ func TestGithubPullRequestOkToTest(t *testing.T) {
7776

7877
err = payload.Send(ctx,
7978
g.Cnx,
80-
os.Getenv("TEST_EL_URL"),
81-
os.Getenv("TEST_EL_WEBHOOK_SECRET"),
82-
os.Getenv("TEST_GITHUB_API_URL"),
83-
os.Getenv("TEST_GITHUB_REPO_INSTALLATION_ID"),
79+
os.Getenv("TEST_GITHUB_SECOND_EL_URL"),
80+
os.Getenv("TEST_GITHUB_SECOND_WEBHOOK_SECRET"),
81+
os.Getenv("TEST_GITHUB_SECOND_API_URL"),
82+
os.Getenv("TEST_GITHUB_SECOND_APPLICATION_ID"),
8483
event,
8584
"issue_comment",
8685
)

test/github_pullrequest_privaterepository_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import (
1414
"gotest.tools/v3/assert"
1515
)
1616

17-
func TestGithubPullRequestGitClone(t *testing.T) {
17+
func TestGithubGHEPullRequestGitCloneTask(t *testing.T) {
1818
if os.Getenv("NIGHTLY_E2E_TEST") != "true" {
1919
t.Skip("Skipping test since only enabled for nightly")
2020
}
2121
ctx := context.Background()
2222
g := &tgithub.PRTest{
23-
Label: "Github - Private Repo",
23+
Label: "Github GHE - Private Repo with git-clone task",
2424
YamlFiles: []string{"testdata/pipelinerun_git_clone_private.yaml"},
25+
GHE: true,
2526
}
2627
g.RunPullRequest(ctx, t)
2728

@@ -30,7 +31,7 @@ func TestGithubPullRequestGitClone(t *testing.T) {
3031

3132
maxLines := int64(1000)
3233
assert.NilError(t, wait.RegexpMatchingInControllerLog(ctx, g.Cnx, *regexp.MustCompile(".*fetched git-clone task"),
33-
10, "controller", &maxLines), "Error while checking the logs of the pipelines-as-code controller pod")
34+
10, "ghe-controller", &maxLines), "Error while checking the logs of the pipelines-as-code controller pod")
3435
defer g.TearDown(ctx, t)
3536
}
3637

test/github_pullrequest_rerequest_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ import (
2121

2222
// TestGithubPullRerequest is a test that will create a pull request and check
2323
// if we can rerequest a specific check or the full check suite.
24-
func TestGithubPullRerequest(t *testing.T) {
24+
func TestGithubGHEPullRerequest(t *testing.T) {
2525
if os.Getenv("NIGHTLY_E2E_TEST") != "true" {
2626
t.Skip("Skipping test since only enabled for nightly")
2727
}
2828
ctx := context.TODO()
2929
g := &tgithub.PRTest{
3030
Label: "Github Rerequest",
3131
YamlFiles: []string{"testdata/pipelinerun.yaml"},
32+
GHE: true,
3233
}
3334
g.RunPullRequest(ctx, t)
3435
defer g.TearDown(ctx, t)
@@ -49,7 +50,7 @@ func TestGithubPullRerequest(t *testing.T) {
4950
Sender: g.Options.Organization,
5051
}
5152

52-
installID, err := strconv.ParseInt(os.Getenv("TEST_GITHUB_REPO_INSTALLATION_ID"), 10, 64)
53+
installID, err := strconv.ParseInt(os.Getenv("TEST_GITHUB_SECOND_APPLICATION_ID"), 10, 64)
5354
assert.NilError(t, err)
5455
event := github.CheckRunEvent{
5556
Action: github.Ptr("rerequested"),
@@ -80,10 +81,10 @@ func TestGithubPullRerequest(t *testing.T) {
8081

8182
err = payload.Send(ctx,
8283
g.Cnx,
83-
os.Getenv("TEST_EL_URL"),
84-
os.Getenv("TEST_EL_WEBHOOK_SECRET"),
85-
os.Getenv("TEST_GITHUB_API_URL"),
86-
os.Getenv("TEST_GITHUB_REPO_INSTALLATION_ID"),
84+
os.Getenv("TEST_GITHUB_SECOND_EL_URL"),
85+
os.Getenv("TEST_GITHUB_SECOND_WEBHOOK_SECRET"),
86+
os.Getenv("TEST_GITHUB_SECOND_API_URL"),
87+
os.Getenv("TEST_GITHUB_SECOND_APPLICATION_ID"),
8788
event,
8889
"check_run",
8990
)
@@ -130,10 +131,10 @@ func TestGithubPullRerequest(t *testing.T) {
130131

131132
err = payload.Send(ctx,
132133
g.Cnx,
133-
os.Getenv("TEST_EL_URL"),
134-
os.Getenv("TEST_EL_WEBHOOK_SECRET"),
135-
os.Getenv("TEST_GITHUB_API_URL"),
136-
os.Getenv("TEST_GITHUB_REPO_INSTALLATION_ID"),
134+
os.Getenv("TEST_GITHUB_SECOND_EL_URL"),
135+
os.Getenv("TEST_GITHUB_SECOND_WEBHOOK_SECRET"),
136+
os.Getenv("TEST_GITHUB_SECOND_API_URL"),
137+
os.Getenv("TEST_GITHUB_SECOND_APPLICATION_ID"),
137138
csEvent,
138139
"check_suite",
139140
)

test/github_pullrequest_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ func commentBodyHash(body string) string {
5151
return digest
5252
}
5353

54-
func TestGithubPullRequest(t *testing.T) {
54+
func TestGithubGHEPullRequestBasic(t *testing.T) {
5555
ctx := context.Background()
5656
g := &tgithub.PRTest{
5757
Label: "Github PullRequest",
5858
YamlFiles: []string{"testdata/pipelinerun.yaml"},
59+
GHE: true,
5960
}
6061
g.RunPullRequest(ctx, t)
6162
defer g.TearDown(ctx, t)
@@ -642,22 +643,23 @@ func TestGithubGHEPullRequestNoPipelineRunCancelledOnPRClosed(t *testing.T) {
642643
assert.Equal(t, false, isCancelled, fmt.Sprintf("PipelineRun got cancelled while we wanted it `Running`, last reason: %v", prReason))
643644
}
644645

645-
func TestGithubCancelInProgressSettingFromConfigMapOnPR(t *testing.T) {
646+
func TestGithubGHECancelInProgressSettingFromConfigMapOnPR(t *testing.T) {
646647
ctx := context.Background()
647-
ctx, runcnx, _, _, err := tgithub.Setup(ctx, false, false)
648+
ctx, runcnx, _, _, err := tgithub.Setup(ctx, true, false)
648649
assert.NilError(t, err)
649650

650651
patchData := map[string]string{
651652
"enable-cancel-in-progress-on-pull-requests": "true",
652653
}
653654

654-
configMapTearDown := configmap.ChangeGlobalConfig(ctx, t, runcnx, patchData)
655+
configMapTearDown := configmap.ChangeGlobalConfig(ctx, t, runcnx, "ghe-configmap", patchData)
655656
defer configMapTearDown()
656657

657658
g := &tgithub.PRTest{
658659
Label: "Github PullRequest",
659660
YamlFiles: []string{"testdata/pipelinerun-gitops.yaml"},
660661
NoStatusCheck: true,
662+
GHE: true,
661663
}
662664
g.RunPullRequest(ctx, t)
663665
defer g.TearDown(ctx, t)
@@ -687,22 +689,23 @@ func TestGithubCancelInProgressSettingFromConfigMapOnPR(t *testing.T) {
687689
assert.NilError(t, err)
688690
}
689691

690-
func TestGithubCancelInProgressSettingFromConfigMapOnPush(t *testing.T) {
692+
func TestGithubGHECancelInProgressSettingFromConfigMapOnPush(t *testing.T) {
691693
ctx := context.Background()
692-
ctx, runcnx, _, _, err := tgithub.Setup(ctx, false, false)
694+
ctx, runcnx, _, _, err := tgithub.Setup(ctx, true, false)
693695
assert.NilError(t, err)
694696

695697
patchData := map[string]string{
696698
"enable-cancel-in-progress-on-push": "true",
697699
}
698700

699-
configMapTearDown := configmap.ChangeGlobalConfig(ctx, t, runcnx, patchData)
701+
configMapTearDown := configmap.ChangeGlobalConfig(ctx, t, runcnx, "ghe-configmap", patchData)
700702
defer configMapTearDown()
701703

702704
g := &tgithub.PRTest{
703705
Label: "Github PullRequest",
704706
YamlFiles: []string{"testdata/pipelinerun-gitops.yaml"},
705707
NoStatusCheck: true,
708+
GHE: true,
706709
}
707710
g.RunPushRequest(ctx, t)
708711
defer g.TearDown(ctx, t)

test/github_push_retest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ func TestGithubGHEPushRequestGitOpsCommentCancel(t *testing.T) {
224224
assert.Assert(t, cancelled, "No cancelled pipeline run found")
225225
}
226226

227-
func TestGithubPullRequestRetestPullRequestNumberSubstitution(t *testing.T) {
227+
func TestGithubGHEPullRequestRetestPullRequestNumberSubstitution(t *testing.T) {
228228
targetNS := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-ns")
229229
ctx := context.Background()
230-
g := &tgithub.PRTest{}
230+
g := &tgithub.PRTest{GHE: true}
231231

232232
ctx, runcnx, opts, ghcnx, err := tgithub.Setup(ctx, g.GHE, g.Webhook)
233233
assert.NilError(t, err)

test/github_push_test.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package test
44

55
import (
66
"context"
7-
"fmt"
87
"os"
98
"testing"
109

@@ -47,19 +46,13 @@ func TestGithubGHEPush(t *testing.T) {
4746
defer g.TearDown(ctx, t)
4847
}
4948

50-
func TestGithubPushRequestCELMatchOnTitle(t *testing.T) {
49+
func TestGithubGHEPushRequestCELMatchOnTitle(t *testing.T) {
5150
ctx := context.Background()
52-
for _, onWebhook := range []bool{false, true} {
53-
if onWebhook && os.Getenv("TEST_GITHUB_REPO_OWNER_WEBHOOK") == "" {
54-
t.Skip("TEST_GITHUB_REPO_OWNER_WEBHOOK is not set")
55-
continue
56-
}
57-
g := &tgithub.PRTest{
58-
Label: fmt.Sprintf("Github push request test CEL match on title onWebhook=%v", onWebhook),
59-
YamlFiles: []string{"testdata/pipelinerun-cel-annotation-for-title-match.yaml"},
60-
Webhook: onWebhook,
61-
}
62-
g.RunPushRequest(ctx, t)
63-
defer g.TearDown(ctx, t)
51+
g := &tgithub.PRTest{
52+
Label: "Github push request test CEL match on title",
53+
YamlFiles: []string{"testdata/pipelinerun-cel-annotation-for-title-match.yaml"},
54+
GHE: true,
6455
}
56+
g.RunPushRequest(ctx, t)
57+
defer g.TearDown(ctx, t)
6558
}

test/github_scope_token_to_list_of_private_public_repos_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func verifyGHTokenScope(t *testing.T, remoteTaskURL, remoteTaskName string, data
9393
assert.NilError(t, err)
9494

9595
targetNS := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-ns")
96-
defer configmap.ChangeGlobalConfig(ctx, t, runcnx, data)()
96+
defer configmap.ChangeGlobalConfig(ctx, t, runcnx, "pipelines-as-code", data)()
9797

9898
entries, err := payload.GetEntries(map[string]string{
9999
".tekton/pr.yaml": "testdata/pipelinerun_remote_task_annotations.yaml",

0 commit comments

Comments
 (0)