Skip to content

Commit

Permalink
WiP: gcp/tests
Browse files Browse the repository at this point in the history
Signed-off-by: Beraldo Leal <[email protected]>
  • Loading branch information
beraldoleal committed Jun 28, 2024
1 parent b9b9242 commit 8af2b8b
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/cloud-api-adaptor/test/e2e/gcp_common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// (C) Copyright Confidential Containers Contributors
// SPDX-License-Identifier: Apache-2.0

package e2e

import (
"testing"
"time"

pv "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/gcp"
)

// GCPAssert implements the CloudAssert interface.
type GCPAssert struct {
Vpc *pv.GCPVPC
}

func NewGCPAssert() GCPAssert {
return GCPAssert{
Vpc: pv.GCPProps.GcpVPC,
}
}

func (aa GCPAssert) DefaultTimeout() time.Duration {
return 1 * time.Minute
}

func (aa GCPAssert) HasPodVM(t *testing.T, id string) {
// // The `id` parameter is not the instance ID but rather the pod's name, so
// // it will need to scan all running pods on the subnet to find one that
// // starts with the prefix.
// podvmPrefix := "podvm-" + id

// describeInstances, err := aa.Vpc.Client.DescribeInstances(context.TODO(),
// &ec2.DescribeInstancesInput{
// Filters: []ec2types.Filter{
// {
// Name: aws.String("subnet-id"),
// Values: []string{aa.Vpc.SubnetId},
// },
// },
// })
// if err != nil {
// t.Errorf("Podvm name=%s not found: %v", id, err)
// }

// found := false
// for _, reservation := range describeInstances.Reservations {
// for _, instance := range reservation.Instances {
// // Code == 48 (terminated)
// // Some podvm from previous tests might be on terminated stage
// // so let's ignore them.
// if instance.State.Code != aws.Int32(48) {
// for _, tag := range instance.Tags {
// if *tag.Key == "Name" &&
// strings.HasPrefix(*tag.Value, podvmPrefix) {
// found = true
// }
// }
// }
// }
// }

// if !found {
// t.Errorf("Podvm name=%s not found", id)
// }
}

func (aa GCPAssert) GetInstanceType(t *testing.T, podName string) (string, error) {
return "", nil
}
105 changes: 105 additions & 0 deletions src/cloud-api-adaptor/test/e2e/gcp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//go:build gcp

// (C) Copyright Confidential Containers Contributors
// SPDX-License-Identifier: Apache-2.0

package e2e

import (
"testing"
// pv "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/gcp"
)

func TestGCPCreateSimplePod(t *testing.T) {
assert := GCPAssert{}
DoTestCreateSimplePod(t, testEnv, assert)
}

func TestGCPCreatePodWithConfigMap(t *testing.T) {
t.Skip("Test not passing")
assert := NewGCPAssert()

DoTestCreatePodWithConfigMap(t, testEnv, assert)
}

func TestGCPCreatePodWithSecret(t *testing.T) {
t.Skip("Test not passing")
assert := NewGCPAssert()

DoTestCreatePodWithSecret(t, testEnv, assert)
}

// func TestAwsCreatePeerPodContainerWithExternalIPAccess(t *testing.T) {
// t.Skip("Test not passing")
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodContainerWithExternalIPAccess(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodWithJob(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodWithJob(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodAndCheckUserLogs(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodAndCheckUserLogs(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodAndCheckWorkDirLogs(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodAndCheckWorkDirLogs(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodAndCheckEnvVariableLogsWithImageOnly(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodAndCheckEnvVariableLogsWithImageOnly(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodAndCheckEnvVariableLogsWithDeploymentOnly(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodAndCheckEnvVariableLogsWithDeploymentOnly(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodAndCheckEnvVariableLogsWithImageAndDeployment(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodAndCheckEnvVariableLogsWithImageAndDeployment(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodWithLargeImage(t *testing.T) {
// assert := NewAWSAssert()
//
// DoTestCreatePeerPodWithLargeImage(t, testEnv, assert)
// }
//
// func TestAwsCreatePeerPodWithPVC(t *testing.T) {
// t.Skip("To be implemented")
// }
//
// func TestAwsCreatePeerPodWithAuthenticatedImagewithValidCredentials(t *testing.T) {
// t.Skip("To be implemented")
// }
//
// func TestAwsCreatePeerPodWithAuthenticatedImageWithInvalidCredentials(t *testing.T) {
// t.Skip("To be implemented")
// }
//
// func TestAwsCreatePeerPodWithAuthenticatedImageWithoutCredentials(t *testing.T) {
// t.Skip("To be implemented")
// }
//
// func TestAwsDeletePod(t *testing.T) {
// assert := NewAWSAssert()
// DoTestDeleteSimplePod(t, testEnv, assert)
// }
//
// func TestAwsCreateNginxDeployment(t *testing.T) {
// assert := NewAWSAssert()
// DoTestNginxDeployment(t, testEnv, assert)
// }

0 comments on commit 8af2b8b

Please sign in to comment.