Files
athens/e2etests/run_athens.go
Ashish Ranjan 3f26845cff move to github actions from drone (#1823)
* add github actions workflow for tag releases

* migrate drone build &test step to github actions

* fix minio service

* fix indentation

* fix dependency syntax

* remove needs keyword

* fix service hostnames, add protectedredis

* update protected redis docker image

* fix too many args error

* exclude vendor dir from gofmt

* fix fmt errors

* fix fmt errors

* rm .drone.yml

* rename workflow name

* break test step

* remove vendor step

* use makefile rule

* use buildx
2023-02-22 22:47:37 -08:00

63 lines
1.3 KiB
Go

//go:build e2etests
// +build e2etests
package e2etests
import (
"context"
"fmt"
"net/http"
"os/exec"
"path"
"path/filepath"
"time"
)
func buildAthens(goBin, destPath string, env []string) (string, error) {
target := path.Join(destPath, "athens-proxy")
binFolder, err := filepath.Abs("../cmd/proxy")
if err != nil {
return "", fmt.Errorf("Failed to get athens source path %v", err)
}
cmd := exec.Command(goBin, "build", "-o", target, binFolder)
cmd.Env = env
output, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("Failed to build athens: %v - %s", err, string(output))
}
return target, nil
}
func stopAthens() error {
cmd := exec.Command("pkill", "athens-proxy")
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("Failed to stop athens: %v - %s", err, string(output))
}
return err
}
func runAthensAndWait(ctx context.Context, athensBin string, env []string) error {
cmd := exec.CommandContext(ctx, athensBin)
cmd.Env = env
cmd.Start()
ticker := time.NewTicker(time.Second)
timeout := time.After(20 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
resp, _ := http.Get("http://localhost:3000/readyz")
if resp.StatusCode == 200 {
return nil
}
case <-timeout:
return fmt.Errorf("Failed to run athens")
}
}
}