-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tinkerbell ci test harness to e2e test framework
- Loading branch information
1 parent
6a20e4b
commit ead7874
Showing
5 changed files
with
112 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package e2e | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/aws/eks-anywhere/internal/pkg/ec2" | ||
"github.com/aws/eks-anywhere/pkg/logger" | ||
) | ||
|
||
type TestHarness interface { | ||
createInstance(testSession *E2ESession) (string, error) | ||
} | ||
|
||
type TestHarnessType string | ||
|
||
const ( | ||
Ec2TestHarnessType TestHarnessType = "ec2" | ||
VSphereTestHarnessType TestHarnessType = "vSphere" | ||
) | ||
|
||
func newTestHarness(testHarnessType TestHarnessType) TestHarness { | ||
if testHarnessType == VSphereTestHarnessType { | ||
return VSphereTestHarness{} | ||
} else { | ||
return Ec2TestHarness{} | ||
} | ||
} | ||
|
||
type Ec2TestHarness struct{} | ||
type VSphereTestHarness struct{} | ||
|
||
func (VSphereTestHarness) createInstance(e *E2ESession) (string, error) { | ||
name := getTestHarnessName(e.jobId) | ||
logger.V(1).Info("Creating vSphere Test Runner instance", "name", name) | ||
// 1) create vsphere vm to serve as test runner instance | ||
// 2) figure out how to get ssm instance id out of the vm post deployment. | ||
// Hopefully I can filter by instance name, ip, or mac addr of the vm in ssm console | ||
|
||
//e.instanceId = instanceId | ||
return "", errors.New("") | ||
} | ||
|
||
func (Ec2TestHarness) createInstance(e *E2ESession) (string, error) { | ||
name := getTestHarnessName(e.jobId) | ||
logger.V(1).Info("Creating ec2 Test Runner instance", "name", name) | ||
instanceId, err := ec2.CreateInstance(e.session, e.amiId, key, tag, e.instanceProfileName, e.subnetId, name) | ||
if err != nil { | ||
return "", fmt.Errorf("creating instance for e2e tests: %v", err) | ||
} | ||
logger.V(1).Info("Instance created", "instance-id", instanceId) | ||
e.instanceId = instanceId | ||
return instanceId, nil | ||
} | ||
|
||
func getTestHarnessName(jobId string) string { | ||
return fmt.Sprintf("eksa-e2e-%s", jobId) | ||
} |
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,30 @@ | ||
package e2e | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
|
||
"github.com/aws/eks-anywhere/pkg/logger" | ||
e2etests "github.com/aws/eks-anywhere/test/framework" | ||
) | ||
|
||
const ( | ||
tinkerbellTestsRe = `^.*Tinkerbell.*$` | ||
) | ||
|
||
func (e *E2ESession) setupTinkerbellEnv(testRegex string) error { | ||
re := regexp.MustCompile(tinkerbellTestsRe) | ||
if !re.MatchString(testRegex) { | ||
logger.V(2).Info("Not running Tinkerbell tests, skipping Env variable setup") | ||
return nil | ||
} | ||
|
||
requiredEnvVars := e2etests.RequiredTinkerbellEnvVars() | ||
for _, eVar := range requiredEnvVars { | ||
if val, ok := os.LookupEnv(eVar); ok { | ||
e.testEnvVars[eVar] = val | ||
} | ||
} | ||
|
||
return nil | ||
} |
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