for tests that require custom docker-compose file (located in test directory)
(ctx context.Context, pkg string, wg *sync.WaitGroup, xmlFile string)
| 824 | |
| 825 | // for tests that require custom docker-compose file (located in test directory) |
| 826 | func runCustomClusterTest(ctx context.Context, pkg string, wg *sync.WaitGroup, xmlFile string) error { |
| 827 | fmt.Printf("Bringing up cluster for package: %s\n", pkg) |
| 828 | var err error |
| 829 | compose := composeFileFor(pkg) |
| 830 | prefix := getClusterPrefix() |
| 831 | err = startCluster(compose, prefix) |
| 832 | if err != nil { |
| 833 | return err |
| 834 | } |
| 835 | if !*keepCluster { |
| 836 | wg.Add(1) |
| 837 | // Wrap in a closure so the `err` read by stopCluster is the |
| 838 | // value AT DEFER RUN TIME (i.e. after runTestsFor returns). |
| 839 | // The original form `defer stopCluster(..., err)` captured err |
| 840 | // at defer-STATEMENT time, which is always nil here, so |
| 841 | // stopCluster never dumped container logs on test failure. |
| 842 | defer func() { |
| 843 | stopCluster(compose, prefix, wg, err) |
| 844 | }() |
| 845 | } |
| 846 | |
| 847 | err = runTestsFor(ctx, pkg, prefix, xmlFile) |
| 848 | return err |
| 849 | } |
| 850 | |
| 851 | func findPackagesFor(testName string) []string { |
| 852 | if len(testName) == 0 { |
no test coverage detected