(platform switchblade.Platform, fixtures string)
| 12 | ) |
| 13 | |
| 14 | func testFrameworks(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) { |
| 15 | return func(t *testing.T, context spec.G, it spec.S) { |
| 16 | var ( |
| 17 | Expect = NewWithT(t).Expect |
| 18 | Eventually = NewWithT(t).Eventually |
| 19 | name string |
| 20 | ) |
| 21 | |
| 22 | it.Before(func() { |
| 23 | var err error |
| 24 | name, err = switchblade.RandomName() |
| 25 | Expect(err).NotTo(HaveOccurred()) |
| 26 | }) |
| 27 | |
| 28 | it.After(func() { |
| 29 | if t.Failed() && name != "" { |
| 30 | t.Logf("❌ FAILED TEST - App/Container: %s", name) |
| 31 | t.Logf(" Platform: %s", settings.Platform) |
| 32 | } |
| 33 | // Only attempt cleanup if test actually ran (not skipped) and name was set |
| 34 | if name != "" && !t.Skipped() && (!settings.KeepFailedContainers || !t.Failed()) { |
| 35 | Expect(platform.Delete.Execute(name)).To(Succeed()) |
| 36 | } |
| 37 | }) |
| 38 | |
| 39 | context("APM Agents", func() { |
| 40 | context("with New Relic service binding", func() { |
| 41 | it("detects and installs New Relic agent", func() { |
| 42 | deployment, logs, err := platform.Deploy. |
| 43 | WithServices(map[string]switchblade.Service{ |
| 44 | "newrelic": { |
| 45 | "licenseKey": "test-license-key-1234567890abcdef", |
| 46 | }, |
| 47 | }). |
| 48 | WithEnv(map[string]string{ |
| 49 | "BP_JAVA_VERSION": "11", |
| 50 | }). |
| 51 | Execute(name, filepath.Join(fixtures, "containers", "spring_boot_staged")) |
| 52 | Expect(err).NotTo(HaveOccurred(), logs.String) |
| 53 | |
| 54 | // Verify New Relic agent was detected |
| 55 | Expect(logs.String()).To(ContainSubstring("New Relic Agent")) |
| 56 | Eventually(deployment).Should(matchers.Serve(ContainSubstring(""))) |
| 57 | }) |
| 58 | |
| 59 | it("configures New Relic with license key from service binding", func() { |
| 60 | deployment, logs, err := platform.Deploy. |
| 61 | WithServices(map[string]switchblade.Service{ |
| 62 | "my-newrelic-service": { |
| 63 | "licenseKey": "abc123def456ghi789jkl012mno345pq", |
| 64 | }, |
| 65 | }). |
| 66 | WithEnv(map[string]string{ |
| 67 | "BP_JAVA_VERSION": "17", |
| 68 | }). |
| 69 | Execute(name, filepath.Join(fixtures, "apps", "integration_valid")) |
| 70 | Expect(err).NotTo(HaveOccurred(), logs.String) |
| 71 |
no test coverage detected