@@ -47,6 +47,34 @@ func Validate(ctx context.Context, client api.Client, config *ValidationSpec) er
47
47
}
48
48
}
49
49
50
+ // run executor queries
51
+ if config .Executor .Enabled {
52
+ log .Printf ("%s validating executor connections" , validate .EmojiFingerPointRight )
53
+
54
+ executorQuery := `query executors($query: String, $active: Boolean, $first: Int, $after: String) {
55
+ executors(query: $query, active: $active, first: $first, after: $after){
56
+ totalCount
57
+ }
58
+ }`
59
+ executorVars := map [string ]interface {}{
60
+ "query" : "" ,
61
+ "active" : true ,
62
+ "first" : 100 ,
63
+ "after" : "" ,
64
+ }
65
+
66
+ totalCount , err := checkExecutors (ctx , client , executorQuery , executorVars )
67
+ if err != nil {
68
+ return err
69
+ }
70
+ if totalCount == 0 {
71
+ log .Printf ("%s validation failed, 0 executors found" , validate .FlashingLightEmoji )
72
+ }
73
+ if totalCount >= 1 {
74
+ log .Printf ("%s executors found, %d executor(s) connected to Sourcegraph instance" , validate .SuccessEmoji , totalCount )
75
+ }
76
+ }
77
+
50
78
if config .Smtp .Enabled {
51
79
log .Printf ("%s validating smtp connection" , validate .EmojiFingerPointRight )
52
80
@@ -88,6 +116,30 @@ func Validate(ctx context.Context, client api.Client, config *ValidationSpec) er
88
116
return nil
89
117
}
90
118
119
+ func checkExecutors (ctx context.Context , client api.Client , query string , variables map [string ]interface {}) (int , error ) {
120
+ q := clientQuery {
121
+ opName : "CheckExecutorConnection" ,
122
+ query : query ,
123
+ variables : variables ,
124
+ }
125
+
126
+ var result struct {
127
+ Executor struct {
128
+ TotalCount int `json:"totalCount"`
129
+ } `json:"executors"`
130
+ }
131
+
132
+ ok , err := client .NewRequest (q .query , q .variables ).Do (ctx , & result )
133
+ if err != nil {
134
+ return - 1 , errors .Wrap (err , "checkExecutors failed" )
135
+ }
136
+ if ! ok {
137
+ return - 1 , errors .New ("checkExecutors failed, no data to unmarshal" )
138
+ }
139
+
140
+ return result .Executor .TotalCount , nil
141
+ }
142
+
91
143
func removeExternalService (ctx context.Context , client api.Client , id string ) error {
92
144
q := clientQuery {
93
145
opName : "DeleteExternalService" ,
0 commit comments