You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
678 B

  1. package main
  2. import (
  3. "errors"
  4. "fmt"
  5. "os"
  6. e2e "github.com/tendermint/tendermint/test/e2e/pkg"
  7. )
  8. // Cleanup removes the Docker Compose containers and testnet directory.
  9. func Cleanup(testnet *e2e.Testnet) error {
  10. if testnet.Dir == "" {
  11. return errors.New("no directory set")
  12. }
  13. _, err := os.Stat(testnet.Dir)
  14. if os.IsNotExist(err) {
  15. return nil
  16. } else if err != nil {
  17. return err
  18. }
  19. logger.Info("Removing Docker containers and networks")
  20. err = execCompose(testnet.Dir, "down")
  21. if err != nil {
  22. return err
  23. }
  24. logger.Info(fmt.Sprintf("Removing testnet directory %q", testnet.Dir))
  25. err = os.RemoveAll(testnet.Dir)
  26. if err != nil {
  27. return err
  28. }
  29. return nil
  30. }