(tb testing.TB, ctx context.Context)
| 115 | } |
| 116 | |
| 117 | func wstestServer(tb testing.TB, ctx context.Context) (url string, closeFn func() error, err error) { |
| 118 | defer errd.Wrap(&err, "failed to start autobahn wstest server") |
| 119 | |
| 120 | serverAddr, err := unusedListenAddr() |
| 121 | if err != nil { |
| 122 | return "", nil, err |
| 123 | } |
| 124 | _, serverPort, err := net.SplitHostPort(serverAddr) |
| 125 | if err != nil { |
| 126 | return "", nil, err |
| 127 | } |
| 128 | |
| 129 | url = "ws://" + serverAddr |
| 130 | const outDir = "ci/out/autobahn-report" |
| 131 | |
| 132 | specFile, err := tempJSONFile(map[string]any{ |
| 133 | "url": url, |
| 134 | "outdir": outDir, |
| 135 | "cases": autobahnCases, |
| 136 | "exclude-cases": excludedAutobahnCases, |
| 137 | }) |
| 138 | if err != nil { |
| 139 | return "", nil, fmt.Errorf("failed to write spec: %w", err) |
| 140 | } |
| 141 | |
| 142 | ctx, cancel := context.WithTimeout(ctx, time.Hour) |
| 143 | defer func() { |
| 144 | if err != nil { |
| 145 | cancel() |
| 146 | } |
| 147 | }() |
| 148 | |
| 149 | dockerPull := exec.CommandContext(ctx, "docker", "pull", "crossbario/autobahn-testsuite") |
| 150 | dockerPull.Stdout = util.WriterFunc(func(p []byte) (int, error) { |
| 151 | tb.Log(string(p)) |
| 152 | return len(p), nil |
| 153 | }) |
| 154 | dockerPull.Stderr = util.WriterFunc(func(p []byte) (int, error) { |
| 155 | tb.Log(string(p)) |
| 156 | return len(p), nil |
| 157 | }) |
| 158 | tb.Log(dockerPull) |
| 159 | err = dockerPull.Run() |
| 160 | if err != nil { |
| 161 | return "", nil, fmt.Errorf("failed to pull docker image: %w", err) |
| 162 | } |
| 163 | |
| 164 | wd, err := os.Getwd() |
| 165 | if err != nil { |
| 166 | return "", nil, err |
| 167 | } |
| 168 | |
| 169 | var args []string |
| 170 | args = append(args, "run", "-i", "--rm", |
| 171 | "-v", fmt.Sprintf("%s:%[1]s", specFile), |
| 172 | "-v", fmt.Sprintf("%s/ci:/ci", wd), |
| 173 | fmt.Sprintf("-p=%s:%s", serverAddr, serverPort), |
| 174 | "crossbario/autobahn-testsuite", |
no test coverage detected
searching dependent graphs…