MCPcopy
hub / github.com/kopia/kopia / TestServerStart

Function TestServerStart

tests/end_to_end_test/server_start_test.go:36–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34const defaultServerControlUsername = "server-control"
35
36func TestServerStart(t *testing.T) {
37 ctx := testlogging.Context(t)
38
39 runner := testenv.NewInProcRunner(t)
40 e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
41
42 defer e.RunAndExpectSuccess(t, "repo", "disconnect")
43
44 e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir, "--override-hostname=fake-hostname", "--override-username=fake-username", "--max-upload-speed=10000000001")
45
46 e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
47 e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
48
49 var sp testutil.ServerParameters
50
51 wait, _ := e.RunAndProcessStderr(t, sp.ProcessOutput,
52 "server", "start",
53 "--ui",
54 "--address=localhost:0",
55 "--random-password",
56 "--random-server-control-password",
57 "--tls-generate-cert",
58 "--tls-generate-rsa-key-size=2048", // use shorter key size to speed up generation
59 "--override-hostname=fake-hostname",
60 "--override-username=fake-username",
61 "--ui-title-prefix", "Blah: <script>bleh</script> ",
62 )
63
64 defer wait()
65
66 t.Logf("detected server parameters %#v", sp)
67
68 cli, err := apiclient.NewKopiaAPIClient(apiclient.Options{
69 BaseURL: sp.BaseURL,
70 Username: "kopia",
71 Password: sp.Password,
72 TrustedServerCertificateFingerprint: sp.SHA256Fingerprint,
73 LogRequests: true,
74 })
75 require.NoError(t, err)
76 require.NoError(t, cli.FetchCSRFTokenForTesting(ctx))
77
78 controlClient, err := apiclient.NewKopiaAPIClient(apiclient.Options{
79 BaseURL: sp.BaseURL,
80 Username: defaultServerControlUsername,
81 Password: sp.ServerControlPassword,
82 TrustedServerCertificateFingerprint: sp.SHA256Fingerprint,
83 LogRequests: true,
84 })
85 require.NoError(t, err)
86
87 defer serverapi.Shutdown(ctx, controlClient)
88
89 waitUntilServerStarted(ctx, t, controlClient)
90 verifyUIServedWithCorrectTitle(t, cli, sp)
91
92 verifyServerConnected(t, controlClient, true)
93 verifyUIServerConnected(t, cli, true)

Callers

nothing calls this directly

Calls 15

RunAndExpectSuccessMethod · 0.95
RunAndProcessStderrMethod · 0.95
ContextFunction · 0.92
NewInProcRunnerFunction · 0.92
NewCLITestFunction · 0.92
NewKopiaAPIClientFunction · 0.92
ShutdownFunction · 0.92
GetThrottlingLimitsFunction · 0.92
SetThrottlingLimitsFunction · 0.92
CreateSnapshotSourceFunction · 0.92
CancelUploadFunction · 0.92

Tested by

no test coverage detected