github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/cis/e2e/tests_utils.go (about) 1 package e2e 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "strings" 7 "testing" 8 "time" 9 10 "github.com/kyma-project/kyma-environment-broker/internal" 11 "github.com/kyma-project/kyma-environment-broker/internal/storage/postsql" 12 13 "github.com/google/uuid" 14 "github.com/sirupsen/logrus" 15 ) 16 17 const ( 18 globalAccountID = "48bc1348-66db-44a4-8a17-051458bc7365" 19 ) 20 21 func initTestDBInstancesTables(t *testing.T, connectionURL string) error { 22 connection, err := postsql.WaitForDatabaseAccess(connectionURL, 10, 100*time.Millisecond, logrus.New()) 23 if err != nil { 24 t.Logf("Cannot connect to database with URL %s", connectionURL) 25 return err 26 } 27 28 dirPath := "./../../../migrations/" 29 files, err := ioutil.ReadDir(dirPath) 30 if err != nil { 31 t.Logf("Cannot read files from directory %s", dirPath) 32 return err 33 } 34 35 for _, file := range files { 36 if strings.HasSuffix(file.Name(), "up.sql") { 37 v, err := ioutil.ReadFile(dirPath + file.Name()) 38 if err != nil { 39 t.Logf("Cannot read file %s", file.Name()) 40 } 41 if _, err = connection.Exec(string(v)); err != nil { 42 t.Logf("Cannot apply file %s", file.Name()) 43 return err 44 } 45 } 46 } 47 t.Log("Files applied to database") 48 49 return nil 50 } 51 52 func fixInstances() []internal.Instance { 53 var instances []internal.Instance 54 55 for index, subAccountID := range []string{ 56 "4dd1551a-6dc8-4c4b-a0e2-3d3913cb7a31", 57 "f6a7453c-a86d-4d83-a657-dbd65a7fcde1", 58 "1a7b635d-baf6-4bbb-9573-bf21babc914d", 59 "9d734189-e980-4109-b6f7-cacdb16fc44a", 60 "25f4a3c3-d200-4cc8-b051-d46c540a381f", 61 "efd1c2ee-6b59-430a-8b73-f180a33cdc94", 62 "75410b1d-573d-46dd-9a2c-cd8e5fc18822", 63 "36657e59-3f8f-4867-8d90-f4d450a500df", 64 "fb5bcbc4-4d68-41f0-9f64-afda61f28cd1", 65 "3e728728-bca1-480a-af7a-c8b4109e222d", 66 "451245fc-78bc-457d-a57a-c574dcc1e7cd", 67 "c21c94fc-c285-42b1-aef0-8e1f9b6879e5", 68 "723abcdf-07e2-4d46-b75d-31ca43c1c030", 69 "e1584649-df83-462a-b893-607e06f6f730", 70 "65af4a97-94f3-45de-9617-a20c10399641", 71 "1e786ce7-6566-40d7-9859-1d3bef146957", 72 "20c55392-dffa-4005-996a-1fc986cb1205", 73 "224b0e41-f3ae-49b7-9b1c-dc337db13584", 74 "8377c743-984b-4fee-ae4f-519140e160ea", 75 "08215ad3-386a-47e2-b77b-7e5f4e2a5c76", 76 "c23479b8-b0a2-4685-81f5-df0cd3de7e3a", 77 "83be2d80-aae5-4694-a09d-a5b1de335789", 78 "fcd36951-c0ea-4047-8023-42beaecd41cc", 79 "c4de62bb-6d0c-475d-a209-db998ffd1f02", 80 "a052e2c5-b7f5-4bb0-aeff-e737f09fd221", 81 "5235ce2a-170b-43b3-a02a-3c1574e4a167", 82 "c5b584b0-0392-4673-bb97-a4553f9b1018", 83 "ab8954a2-7b83-4998-8b50-c96402cabe9e", 84 "885c8cdd-f69c-4700-935b-7b8ef0fda965", 85 "02bdc38a-b276-4f9e-9cb7-739032bd897d", 86 "b3422a0f-c90a-4fef-b420-29a2e4817bf1", 87 "c88ca349-fa08-48b7-9ef6-897660e4c4f9", 88 "83067aa2-d43c-4141-8e07-eae5b6a30966", 89 "5a634683-21a2-4fdd-9514-03144006eee4", 90 "369d0081-9330-4870-a4fd-932436135a38", 91 "c8464176-28a4-4c82-a147-384b127a96cd", 92 "b6695987-0eb3-4445-837e-e8c8dc700661", 93 "74cea7ff-8ca5-4106-92eb-d0ef9af21e51", 94 "98ea0567-89e1-4287-9e0b-31a049813cea", 95 "730e1047-ba9d-482c-afea-4fac2a4a933b", 96 } { 97 instance := internal.Instance{ 98 InstanceID: fmt.Sprintf("instance-%d", index), 99 RuntimeID: uuid.New().String(), 100 SubAccountID: subAccountID, 101 GlobalAccountID: globalAccountID, 102 } 103 104 instances = append(instances, instance) 105 } 106 107 return instances 108 }