2016-02-20 23:50:41 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
2022-03-15 12:42:43 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
2016-02-20 23:50:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestHTTP_SystemGarbageCollect(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
2017-07-20 05:14:36 +00:00
|
|
|
httpTest(t, nil, func(s *TestAgent) {
|
2016-02-20 23:50:41 +00:00
|
|
|
// Make the HTTP request
|
|
|
|
req, err := http.NewRequest("PUT", "/v1/system/gc", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
respW := httptest.NewRecorder()
|
|
|
|
|
|
|
|
// Make the request
|
|
|
|
if _, err := s.Server.GarbageCollectRequest(respW, req); err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2016-08-03 23:08:30 +00:00
|
|
|
|
|
|
|
func TestHTTP_ReconcileJobSummaries(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
2017-07-20 05:14:36 +00:00
|
|
|
httpTest(t, nil, func(s *TestAgent) {
|
2016-08-03 23:08:30 +00:00
|
|
|
// Make the HTTP request
|
2016-08-04 01:08:37 +00:00
|
|
|
req, err := http.NewRequest("PUT", "/v1/system/reconcile/summaries", nil)
|
2016-08-03 23:08:30 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
respW := httptest.NewRecorder()
|
|
|
|
|
|
|
|
// Make the request
|
|
|
|
if _, err := s.Server.ReconcileJobSummaries(respW, req); err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if respW.Code != 200 {
|
|
|
|
t.Fatalf("expected: %v, actual: %v", 200, respW.Code)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|