-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP. Refactor the code to abstract the engine to be used
Signed-off-by: cmoulliard <[email protected]>
- Loading branch information
1 parent
10fdf1c
commit 4a3e7e9
Showing
5 changed files
with
92 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package container | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
type Engine interface { | ||
IdpCmd() *exec.Cmd | ||
} | ||
|
||
func ContainerClient() string { | ||
if os.Getenv("CONTAINER_ENGINE") == "podman" { | ||
return "podman" | ||
} else { | ||
return "docker" | ||
} | ||
} |
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,27 @@ | ||
//go:build e2e | ||
|
||
package podman | ||
|
||
import ( | ||
"github.com/cnoe-io/idpbuilder/tests/e2e" | ||
"github.com/cnoe-io/idpbuilder/tests/e2e/container" | ||
"github.com/cnoe-io/idpbuilder/tests/e2e/shared" | ||
"os" | ||
"os/exec" | ||
"testing" | ||
) | ||
|
||
type PodmanEngine struct { | ||
container.Engine | ||
} | ||
|
||
func (p *PodmanEngine) IdpCmd() *exec.Cmd { | ||
cmd := exec.Command(e2e.IdpbuilderBinaryLocation) | ||
cmd.Env = append(os.Environ(), "KIND_EXPERIMENTAL_PROVIDER=podman") | ||
return cmd | ||
} | ||
|
||
func Test_CreateCluster(t *testing.T) { | ||
p := &PodmanEngine{} | ||
shared.TestCreateCluster(t, container.ContainerClient(), p.IdpCmd()) | ||
} |
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,2 @@ | ||
FROM scratch | ||
COPY test-dockerfile . |
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,42 @@ | ||
//go:build e2e | ||
|
||
package shared | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/cnoe-io/idpbuilder/tests/e2e" | ||
"github.com/stretchr/testify/assert" | ||
"os/exec" | ||
"testing" | ||
"time" | ||
) | ||
|
||
type ContainerEngine string | ||
|
||
func cleanUp(t *testing.T) { | ||
t.Log("cleaning up") | ||
} | ||
|
||
// test idpbuilder create | ||
func TestCreateCluster(t *testing.T, engine string, cmd *exec.Cmd) { | ||
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Minute) | ||
defer cancel() | ||
defer cleanUp(t) | ||
|
||
t.Log("running idpbuilder create") | ||
cmd.Args = append(cmd.Args, "create") | ||
b, err := cmd.CombinedOutput() | ||
assert.NoError(t, err, b) | ||
|
||
kubeClient, err := e2e.GetKubeClient() | ||
assert.NoError(t, err, fmt.Sprintf("error while getting client: %s", err)) | ||
|
||
e2e.TestArgoCDApps(ctx, t, kubeClient, e2e.CorePackages) | ||
|
||
argoBaseUrl := fmt.Sprintf("https://argocd.%s:%s", e2e.DefaultBaseDomain, e2e.DefaultPort) | ||
giteaBaseUrl := fmt.Sprintf("https://gitea.%s:%s", e2e.DefaultBaseDomain, e2e.DefaultPort) | ||
e2e.TestCoreEndpoints(ctx, t, argoBaseUrl, giteaBaseUrl) | ||
|
||
e2e.TestGiteaRegistry(ctx, t, engine, fmt.Sprintf("gitea.%s", e2e.DefaultBaseDomain), e2e.DefaultPort) | ||
} |