Skip to content

Commit 29e55b6

Browse files
roachtest: Add db-console-endpoints Nightly roachtest
This commit creates a new roachtest that performs a smoke test against a bunch of endpoints used by the DB console. This test is registered as a Nightly test. After some time baking in master, we can move this to an acceptance test. Additionally, the test can be run as a mixed version test. A future commit will register that as a Nightly. Part of: https://cockroachlabs.atlassian.net/browse/CRDB-49090 Release note: None
1 parent 152ab3f commit 29e55b6

File tree

9 files changed

+908
-4
lines changed

9 files changed

+908
-4
lines changed

pkg/cmd/roachtest/roachtestutil/httpclient.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ type RoachtestHTTPClient struct {
4646
cluster cluster.Cluster
4747
l *logger.Logger
4848
virtualClusterName string
49+
headers map[string]string
4950
// Used for safely adding to the cookie jar.
5051
mu syncutil.Mutex
5152
}
5253

5354
type RoachtestHTTPOptions struct {
5455
Timeout time.Duration
5556
VirtualClusterName string
57+
Headers map[string]string
5658
}
5759

5860
func HTTPTimeout(timeout time.Duration) func(options *RoachtestHTTPOptions) {
@@ -67,6 +69,12 @@ func VirtualCluster(name string) func(*RoachtestHTTPOptions) {
6769
}
6870
}
6971

72+
func WithHeaders(headers map[string]string) func(*RoachtestHTTPOptions) {
73+
return func(options *RoachtestHTTPOptions) {
74+
options.Headers = headers
75+
}
76+
}
77+
7078
// DefaultHTTPClient returns a default RoachtestHTTPClient.
7179
// This should be the default HTTP client used if you are
7280
// trying to make a request to a secure cluster.
@@ -93,6 +101,7 @@ func DefaultHTTPClient(
93101
roachtestHTTP.client.Timeout = httpOptions.Timeout
94102
}
95103
roachtestHTTP.virtualClusterName = httpOptions.VirtualClusterName
104+
roachtestHTTP.headers = httpOptions.Headers
96105

97106
return &roachtestHTTP
98107
}
@@ -101,7 +110,12 @@ func (r *RoachtestHTTPClient) Get(ctx context.Context, url string) (*http.Respon
101110
if err := r.addCookies(ctx, url); err != nil {
102111
return nil, err
103112
}
104-
return r.client.Get(ctx, url)
113+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
114+
if err != nil {
115+
return nil, err
116+
}
117+
r.addHeaders(req)
118+
return r.client.Do(req)
105119
}
106120

107121
func (r *RoachtestHTTPClient) GetJSON(
@@ -113,6 +127,21 @@ func (r *RoachtestHTTPClient) GetJSON(
113127
return httputil.GetJSONWithOptions(*r.client.Client, path, response, opts...)
114128
}
115129

130+
func (r *RoachtestHTTPClient) Post(
131+
ctx context.Context, url string, contentType string, body io.Reader,
132+
) (*http.Response, error) {
133+
if err := r.addCookies(ctx, url); err != nil {
134+
return nil, err
135+
}
136+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
137+
if err != nil {
138+
return nil, err
139+
}
140+
req.Header.Set("Content-Type", contentType)
141+
r.addHeaders(req)
142+
return r.client.Do(req)
143+
}
144+
116145
func (r *RoachtestHTTPClient) PostProtobuf(
117146
ctx context.Context, path string, request, response protoutil.Message,
118147
) error {
@@ -251,3 +280,9 @@ func (r *RoachtestHTTPClient) Download(ctx context.Context, url string, filename
251280
}
252281
return nil
253282
}
283+
284+
func (r *RoachtestHTTPClient) addHeaders(req *http.Request) {
285+
for key, value := range r.headers {
286+
req.Header.Set(key, value)
287+
}
288+
}

pkg/cmd/roachtest/tests/BUILD.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ go_library(
5656
"copy.go",
5757
"copyfrom.go",
5858
"costfuzz.go",
59-
"db_console.go",
59+
"db_console_cypress.go",
60+
"db_console_endpoints.go",
6061
"decommission.go",
6162
"decommission_self.go",
6263
"decommissionbench.go",
@@ -211,6 +212,9 @@ go_library(
211212
"knexfile.js",
212213
"create-msk-topic/main.go.txt",
213214
"db-console/Dockerfile",
215+
"db-console/admin_endpoints.json",
216+
"db-console/api_v2_endpoints.json",
217+
"db-console/status_endpoints.json",
214218
],
215219
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/tests",
216220
visibility = ["//visibility:public"],
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"endpoints": [
3+
{
4+
"url": "/_admin/v1/users",
5+
"method": "GET"
6+
},
7+
{
8+
"url": "/_admin/v1/databases",
9+
"method": "GET"
10+
},
11+
{
12+
"url": "/_admin/v1/databases/{database}",
13+
"method": "GET"
14+
},
15+
{
16+
"url": "/_admin/v1/databases/{database}/tables/{table}",
17+
"method": "GET"
18+
},
19+
{
20+
"url": "/_admin/v1/databases/{database}/tables/{table}/stats",
21+
"method": "GET"
22+
},
23+
{
24+
"url": "/_admin/v1/nontablestats",
25+
"method": "GET"
26+
},
27+
{
28+
"url": "/_admin/v1/events",
29+
"method": "GET"
30+
},
31+
{
32+
"url": "/_admin/v1/uidata",
33+
"method": "POST",
34+
"skip": "needs non trivial validation"
35+
},
36+
{
37+
"url": "/_admin/v1/uidata",
38+
"method": "GET",
39+
"skip": "needs non trivial validation"
40+
},
41+
{
42+
"url": "/_admin/v1/cluster",
43+
"method": "GET"
44+
},
45+
{
46+
"url": "/_admin/v1/settings",
47+
"method": "GET"
48+
},
49+
{
50+
"url": "/_admin/v1/health",
51+
"method": "GET"
52+
},
53+
{
54+
"url": "/health",
55+
"method": "GET"
56+
},
57+
{
58+
"url": "/_admin/v1/liveness",
59+
"method": "GET"
60+
},
61+
{
62+
"url": "/_admin/v1/jobs",
63+
"method": "GET"
64+
},
65+
{
66+
"url": "/_admin/v1/jobs/{job_id}",
67+
"method": "GET"
68+
},
69+
{
70+
"url": "/_admin/v1/locations",
71+
"method": "GET"
72+
},
73+
{
74+
"url": "/_admin/v1/queryplan",
75+
"method": "GET",
76+
"skip": "needs non trivial validation"
77+
},
78+
{
79+
"url": "/_admin/v1/rangelog",
80+
"method": "GET"
81+
},
82+
{
83+
"url": "/_admin/v1/rangelog/{range_id}",
84+
"method": "GET"
85+
},
86+
{
87+
"url": "/_admin/v1/data_distribution",
88+
"method": "GET"
89+
},
90+
{
91+
"url": "/_admin/v1/metricmetadata",
92+
"method": "GET"
93+
},
94+
{
95+
"url": "/_admin/v1/chartcatalog",
96+
"method": "GET"
97+
},
98+
{
99+
"url": "/_admin/v1/enqueue_range",
100+
"method": "POST"
101+
},
102+
{
103+
"url": "/_admin/v1/trace_snapshots",
104+
"method": "GET"
105+
},
106+
{
107+
"url": "/_admin/v1/trace_snapshots",
108+
"method": "POST",
109+
"skip": "needs non trivial validation"
110+
},
111+
{
112+
"url": "/_admin/v1/trace_snapshots/{snapshot_id}",
113+
"method": "GET",
114+
"skip": "needs non trivial validation"
115+
},
116+
{
117+
"url": "/_admin/v1/traces",
118+
"method": "POST"
119+
},
120+
{
121+
"url": "/_admin/v1/settracerecordingtype",
122+
"method": "POST"
123+
},
124+
{
125+
"url": "/_admin/v1/tenants",
126+
"method": "GET"
127+
}
128+
]
129+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"endpoints": [
3+
{
4+
"url": "/api/v2/sessions/",
5+
"method": "GET"
6+
},
7+
{
8+
"url": "/api/v2/nodes/",
9+
"method": "GET"
10+
},
11+
{
12+
"url": "/api/v2/nodes/{node_id}/ranges/",
13+
"method": "GET"
14+
},
15+
{
16+
"url": "/api/v2/ranges/hot/",
17+
"method": "GET"
18+
},
19+
{
20+
"url": "/api/v2/ranges/{range_id}/",
21+
"method": "GET"
22+
},
23+
{
24+
"url": "/api/v2/health/",
25+
"method": "GET"
26+
},
27+
{
28+
"url": "/api/v2/users/",
29+
"method": "GET"
30+
},
31+
{
32+
"url": "/api/v2/events/",
33+
"method": "GET"
34+
},
35+
{
36+
"url": "/api/v2/databases/",
37+
"method": "GET"
38+
},
39+
{
40+
"url": "/api/v2/databases/{database_name}/",
41+
"method": "GET"
42+
},
43+
{
44+
"url": "/api/v2/databases/{database_name}/grants/",
45+
"method": "GET"
46+
},
47+
{
48+
"url": "/api/v2/databases/{database_name}/tables/",
49+
"method": "GET"
50+
},
51+
{
52+
"url": "/api/v2/databases/{database_name}/tables/{table_name}/",
53+
"method": "GET"
54+
},
55+
{
56+
"url": "/api/v2/rules/",
57+
"method": "GET"
58+
},
59+
{
60+
"url": "/api/v2/sql/",
61+
"method": "POST"
62+
},
63+
{
64+
"url": "/api/v2/database_metadata/",
65+
"method": "GET"
66+
},
67+
{
68+
"url": "/api/v2/database_metadata/{database_id}/",
69+
"method": "GET"
70+
},
71+
{
72+
"url": "/api/v2/table_metadata/",
73+
"method": "GET"
74+
},
75+
{
76+
"url": "/api/v2/table_metadata/{table_id}/",
77+
"method": "GET",
78+
"skip": "needs non trivial validation"
79+
},
80+
{
81+
"url": "/api/v2/table_metadata/updatejob/",
82+
"method": "GET"
83+
},
84+
{
85+
"url": "/api/v2/grants/databases/{database_id}/",
86+
"method": "GET"
87+
},
88+
{
89+
"url": "/api/v2/grants/tables/{table_id}/",
90+
"method": "GET"
91+
}
92+
]
93+
}

0 commit comments

Comments
 (0)