Ft/rework acceptance tests follow up (#684)
* Enable CI Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Add default local file for IaaS image test Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Opensearch acceptance test typo Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Postgresflex acceptance test fix ignore Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Redis acceptance test remove mid uuid Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Objectstorage acceptance test ignore region for import Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> * Add more environment variables for CI build Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de> --------- Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
This commit is contained in:
parent
e2995347ec
commit
a0c2c30ced
8 changed files with 71 additions and 26 deletions
|
|
@ -3,6 +3,8 @@ package iaas_test
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -124,6 +126,9 @@ var imageResource = map[string]string{
|
|||
"boot_menu": "true",
|
||||
}
|
||||
|
||||
// if no local file is provided the test should create a default file and work with this instead of failing
|
||||
var localFileForIaasImage os.File
|
||||
|
||||
func networkResourceConfig(name, nameservers string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "stackit_network" "network" {
|
||||
|
|
@ -331,6 +336,14 @@ func serviceAccountAttachmentResourceConfig() string {
|
|||
}
|
||||
|
||||
func imageResourceConfig(name string) string {
|
||||
if imageResource["local_file_path"] == "default" {
|
||||
localFileForIaasImage = testutil.CreateDefaultLocalFile()
|
||||
filePath, err := filepath.Abs(localFileForIaasImage.Name())
|
||||
if err != nil {
|
||||
fmt.Println("Absolute path for localFileForIaasImage could not be retrieved.")
|
||||
}
|
||||
imageResource["local_file_path"] = filePath
|
||||
}
|
||||
return fmt.Sprintf(`
|
||||
resource "stackit_image" "image" {
|
||||
project_id = "%s"
|
||||
|
|
@ -1866,6 +1879,15 @@ func testAccCheckIaaSImageDestroy(s *terraform.State) error {
|
|||
ctx := context.Background()
|
||||
var client *iaas.APIClient
|
||||
var err error
|
||||
|
||||
if _, err := os.Stat(localFileForIaasImage.Name()); err == nil {
|
||||
// file exists, delete it
|
||||
err := os.Remove(localFileForIaasImage.Name())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error deleting localFileForIaasImage file: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if testutil.IaaSCustomEndpoint == "" {
|
||||
client, err = iaas.NewAPIClient(
|
||||
config.WithRegion("eu01"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue