Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
118 lines
3.3 KiB
Go
118 lines
3.3 KiB
Go
// sharedchannel-test is an integration test tool that validates shared channel
|
|
// synchronization between two real Mattermost server instances.
|
|
//
|
|
// It can either manage the server lifecycle itself (build, start, stop) or
|
|
// connect to already-running instances.
|
|
//
|
|
// Usage:
|
|
//
|
|
// go run . --license /path/to/license.mattermost-license
|
|
// go run . --server-a http://already:9065 --server-b http://running:9066 --manage=false
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
)
|
|
|
|
type Config struct {
|
|
ServerAURL string
|
|
ServerBURL string
|
|
LicensePath string
|
|
ServerDir string
|
|
Manage bool
|
|
AdminUser string
|
|
AdminPass string
|
|
}
|
|
|
|
func main() {
|
|
cfg := Config{}
|
|
|
|
flag.StringVar(&cfg.ServerAURL, "server-a", "http://localhost:9065", "Server A URL")
|
|
flag.StringVar(&cfg.ServerBURL, "server-b", "http://localhost:9066", "Server B URL")
|
|
flag.StringVar(&cfg.LicensePath, "license", "", "Path to enterprise license file (required)")
|
|
flag.StringVar(&cfg.ServerDir, "server-dir", "", "Path to server directory (for managed mode)")
|
|
flag.BoolVar(&cfg.Manage, "manage", true, "Manage server lifecycle (build/start/stop)")
|
|
flag.StringVar(&cfg.AdminUser, "admin-user", "admin", "Admin username to create")
|
|
flag.StringVar(&cfg.AdminPass, "admin-pass", "Admin1234567890", "Admin password")
|
|
flag.Parse()
|
|
|
|
if cfg.LicensePath == "" {
|
|
fmt.Fprintln(os.Stderr, "error: --license is required")
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
logger, err := newLogger()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "error creating logger: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
defer logger.Flush()
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
sigCh := make(chan os.Signal, 1)
|
|
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
|
|
go func() {
|
|
<-sigCh
|
|
logger.Info("Received signal, shutting down...")
|
|
cancel()
|
|
}()
|
|
|
|
runner := NewTestRunner(cfg, logger)
|
|
if err := runner.Run(ctx); err != nil {
|
|
logger.Error("Test run failed", mlog.Err(err))
|
|
logger.Flush()
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// newLogger creates an mlog.Logger with two console targets:
|
|
// - stdout: info, warn, and debug (progress messages, PASS results)
|
|
// - stderr: error, fatal, panic (FAIL results, fatal errors)
|
|
//
|
|
// Both use the plain formatter with color enabled so level names
|
|
// are visually distinct (cyan=info, yellow=warn, red=error).
|
|
func newLogger() (*mlog.Logger, error) {
|
|
logger, err := mlog.NewLogger()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
formatOpts := json.RawMessage(`{"enable_color": true, "enable_caller": false}`)
|
|
|
|
logCfg := mlog.LoggerConfiguration{
|
|
"stdout": mlog.TargetCfg{
|
|
Type: "console",
|
|
Format: "plain",
|
|
Levels: []mlog.Level{mlog.LvlInfo, mlog.LvlWarn, mlog.LvlDebug},
|
|
Options: json.RawMessage(`{"out": "stdout"}`),
|
|
FormatOptions: formatOpts,
|
|
MaxQueueSize: 1000,
|
|
},
|
|
"stderr": mlog.TargetCfg{
|
|
Type: "console",
|
|
Format: "plain",
|
|
Levels: []mlog.Level{mlog.LvlError, mlog.LvlFatal, mlog.LvlPanic},
|
|
Options: json.RawMessage(`{"out": "stderr"}`),
|
|
FormatOptions: formatOpts,
|
|
MaxQueueSize: 1000,
|
|
},
|
|
}
|
|
|
|
if err := logger.ConfigureTargets(logCfg, nil); err != nil {
|
|
return nil, fmt.Errorf("configure log targets: %w", err)
|
|
}
|
|
|
|
return logger, nil
|
|
}
|