mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
PR comments
This commit is contained in:
parent
524e37c322
commit
85155f52b3
3
.github/workflows/dendrite.yml
vendored
3
.github/workflows/dendrite.yml
vendored
|
|
@ -102,6 +102,7 @@ jobs:
|
|||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- uses: actions/cache@v3
|
||||
# manually set up caches, as they otherwise clash with different steps using setup-go with cache=true
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
|
|
@ -114,7 +115,7 @@ jobs:
|
|||
with:
|
||||
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: go test -json -v ./... | gotestfmt
|
||||
- run: go test -json -v ./... 2>&1 | gotestfmt
|
||||
env:
|
||||
POSTGRES_HOST: localhost
|
||||
POSTGRES_USER: postgres
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/codeclysm/extract"
|
||||
"github.com/docker/docker/api/types"
|
||||
|
|
@ -464,9 +462,18 @@ func loadAndRunTests(dockerClient *client.Client, volumeName, v string, branchTo
|
|||
return fmt.Errorf("failed to run tests on version %s: %s", v, err)
|
||||
}
|
||||
|
||||
// test that create-account is working
|
||||
err = testCreateAccount(dockerClient, v, containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// test that create-account is working
|
||||
func testCreateAccount(dockerClient *client.Client, v string, containerID string) error {
|
||||
createUser := strings.ToLower("createaccountuser-" + v)
|
||||
log.Printf("Creating account %s with create-account\n", createUser)
|
||||
log.Printf("%s: Creating account %s with create-account\n", v, createUser)
|
||||
|
||||
respID, err := dockerClient.ContainerExecCreate(context.Background(), containerID, types.ExecConfig{
|
||||
AttachStderr: true,
|
||||
AttachStdout: true,
|
||||
|
|
@ -479,73 +486,22 @@ func loadAndRunTests(dockerClient *client.Client, volumeName, v string, branchTo
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to ContainerExecCreate: %w", err)
|
||||
}
|
||||
resp, err := InspectExecResp(context.Background(), dockerClient, respID.ID)
|
||||
|
||||
response, err := dockerClient.ContainerExecAttach(context.Background(), respID.ID, types.ExecStartCheck{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to InspectExecResp: %w", err)
|
||||
return fmt.Errorf("failed to attach to container: %w", err)
|
||||
}
|
||||
if !strings.Contains(resp.StdErr, "AccessToken") || resp.ExitCode != 0 {
|
||||
return fmt.Errorf("failed to create-account (exit code %d): %s", resp.ExitCode, resp.StdErr)
|
||||
defer response.Close()
|
||||
|
||||
data, _ := ioutil.ReadAll(response.Reader)
|
||||
fmt.Println(string(data))
|
||||
|
||||
if !bytes.Contains(data, []byte("AccessToken")) {
|
||||
return fmt.Errorf("failed to create-account: %s", string(data))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ExecResult struct {
|
||||
StdOut string
|
||||
StdErr string
|
||||
ExitCode int
|
||||
}
|
||||
|
||||
// https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/integration/internal/container/exec.go#L38
|
||||
func InspectExecResp(ctx context.Context, dockerClient *client.Client, id string) (ExecResult, error) {
|
||||
var execResult ExecResult
|
||||
|
||||
resp, err := dockerClient.ContainerExecAttach(ctx, id, types.ExecStartCheck{})
|
||||
if err != nil {
|
||||
return execResult, err
|
||||
}
|
||||
defer resp.Close()
|
||||
|
||||
// read the output
|
||||
var outBuf, errBuf bytes.Buffer
|
||||
outputDone := make(chan error)
|
||||
|
||||
go func() {
|
||||
// StdCopy demultiplexes the stream into two buffers
|
||||
_, err = stdcopy.StdCopy(&outBuf, &errBuf, resp.Reader)
|
||||
outputDone <- err
|
||||
}()
|
||||
|
||||
select {
|
||||
case err = <-outputDone:
|
||||
if err != nil {
|
||||
return execResult, err
|
||||
}
|
||||
break
|
||||
|
||||
case <-ctx.Done():
|
||||
return execResult, ctx.Err()
|
||||
}
|
||||
|
||||
stdout, err := ioutil.ReadAll(&outBuf)
|
||||
if err != nil {
|
||||
return execResult, err
|
||||
}
|
||||
stderr, err := ioutil.ReadAll(&errBuf)
|
||||
if err != nil {
|
||||
return execResult, err
|
||||
}
|
||||
|
||||
res, err := dockerClient.ContainerExecInspect(ctx, id)
|
||||
if err != nil {
|
||||
return execResult, err
|
||||
}
|
||||
|
||||
execResult.ExitCode = res.ExitCode
|
||||
execResult.StdOut = string(stdout)
|
||||
execResult.StdErr = string(stderr)
|
||||
return execResult, nil
|
||||
}
|
||||
|
||||
func verifyTests(dockerClient *client.Client, volumeName string, versions []string, branchToImageID map[string]string) error {
|
||||
lastVer := versions[len(versions)-1]
|
||||
csAPIURL, containerID, err := runImage(dockerClient, volumeName, lastVer, branchToImageID[lastVer])
|
||||
|
|
|
|||
Loading…
Reference in a new issue