-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide integration tests behind the integration build tag. (#361)
* Hide integration tests behind the integration build tag. * Re-add the kubernetes_integration_test.go. * Fix kubernetes_integration_test.go imports.
- Loading branch information
1 parent
75ac0c6
commit b6c233c
Showing
7 changed files
with
102 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// +build integration | ||
|
||
package test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestRunWithKudo(t *testing.T) { | ||
harness := Harness{ | ||
T: t, | ||
CRDDir: "../../config/crds/", | ||
ManifestsDir: "../../config/samples/test-framework/", | ||
TestDirs: []string{"./test_data/"}, | ||
StartControlPlane: true, | ||
} | ||
|
||
harness.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// +build integration | ||
|
||
package utils | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/envtest" | ||
) | ||
|
||
func TestCreateOrUpdate(t *testing.T) { | ||
env := &envtest.Environment{} | ||
|
||
config, err := env.Start() | ||
assert.Nil(t, err) | ||
|
||
defer env.Stop() | ||
|
||
client, err := client.New(config, client.Options{}) | ||
assert.Nil(t, err) | ||
|
||
// Run the test a bunch of times to try to trigger a conflict and ensure that it handles conflicts properly. | ||
for i := 0; i < 10; i++ { | ||
depToUpdate := WithSpec(NewPod("update-me", fmt.Sprintf("default-%d", i)), map[string]interface{}{ | ||
"containers": []map[string]interface{}{ | ||
{ | ||
"image": "nginx", | ||
"name": "nginx", | ||
}, | ||
}, | ||
}) | ||
|
||
assert.Nil(t, CreateOrUpdate(context.TODO(), client, SetAnnotation(depToUpdate, "test", "hi"), true)) | ||
|
||
quit := make(chan bool) | ||
|
||
go func() { | ||
for { | ||
select { | ||
case <-quit: | ||
return | ||
default: | ||
CreateOrUpdate(context.TODO(), client, SetAnnotation(depToUpdate, "test", fmt.Sprintf("%d", i)), false) | ||
time.Sleep(time.Millisecond * 75) | ||
} | ||
} | ||
}() | ||
|
||
time.Sleep(time.Millisecond * 50) | ||
|
||
assert.Nil(t, CreateOrUpdate(context.TODO(), client, SetAnnotation(depToUpdate, "test", "hello"), true)) | ||
|
||
quit <- true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ COPY config/ config/ | |
COPY pkg/ pkg/ | ||
COPY cmd/ cmd/ | ||
|
||
ENTRYPOINT make test | ||
ENTRYPOINT make integration-test |