-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathbrats_suite_test.go
More file actions
84 lines (69 loc) · 2.24 KB
/
Copy pathbrats_suite_test.go
File metadata and controls
84 lines (69 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package brats_test
import (
"flag"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/cloudfoundry/libbuildpack"
"github.com/cloudfoundry/libbuildpack/bratshelper"
"github.com/cloudfoundry/libbuildpack/cutlass"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = func() bool {
testing.Init()
return true
}()
func init() {
flag.StringVar(&cutlass.DefaultMemory, "memory", "128M", "default memory for pushed apps")
flag.StringVar(&cutlass.DefaultDisk, "disk", "512M", "default disk for pushed apps")
flag.Parse()
}
var _ = SynchronizedBeforeSuite(func() []byte {
// Run once
return bratshelper.InitBpData(os.Getenv("CF_STACK"), ApiHasStackAssociation()).Marshal()
}, func(data []byte) {
// Run on all nodes
bratshelper.Data.Unmarshal(data)
Expect(cutlass.CopyCfHome()).To(Succeed())
cutlass.SeedRandom()
cutlass.DefaultStdoutStderr = GinkgoWriter
})
var _ = SynchronizedAfterSuite(func() {
// Run on all nodes
}, func() {
// Run once
Expect(cutlass.DeleteOrphanedRoutes()).To(Succeed())
Expect(cutlass.DeleteBuildpack(strings.Replace(bratshelper.Data.Cached, "_buildpack", "", 1))).To(Succeed())
Expect(cutlass.DeleteBuildpack(strings.Replace(bratshelper.Data.Uncached, "_buildpack", "", 1))).To(Succeed())
Expect(os.Remove(bratshelper.Data.CachedFile)).To(Succeed())
})
func TestBrats(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Brats Suite")
}
func CopyBrats(version string) *cutlass.App {
dir, err := cutlass.CopyFixture(filepath.Join(bratshelper.Data.BpDir, "fixtures", "brats"))
Expect(err).ToNot(HaveOccurred())
if version == "" {
manifest, err := libbuildpack.NewManifest(bratshelper.Data.BpDir, nil, time.Now())
Expect(err).ToNot(HaveOccurred())
dep, err := manifest.DefaultVersion("python")
Expect(err).ToNot(HaveOccurred())
version = dep.Version
}
data := "python-" + version
Expect(os.WriteFile(filepath.Join(dir, "runtime.txt"), []byte(data), 0644)).To(Succeed())
return cutlass.New(dir)
}
func PushApp(app *cutlass.App) {
Expect(app.Push()).To(Succeed())
Eventually(app.InstanceStates, 20*time.Second).Should(Equal([]string{"RUNNING"}))
}
func ApiHasStackAssociation() bool {
supported, err := cutlass.ApiGreaterThan("2.113.0")
Expect(err).NotTo(HaveOccurred())
return supported
}