executor: parse tracking_url and error on missing application_id
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package executor
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseAppID_FromStdout(t *testing.T) {
|
||||
stdout := "some prefix\nSubmitted application application_123_456\n"
|
||||
stderr := "random log\n"
|
||||
appID, trackingURL, ok := parseSparkSubmitOutput(stdout, stderr)
|
||||
if !ok {
|
||||
t.Fatal("expected ok")
|
||||
}
|
||||
if appID != "application_123_456" {
|
||||
t.Errorf("appID=%q, want application_123_456", appID)
|
||||
}
|
||||
if trackingURL != "" {
|
||||
t.Errorf("trackingURL=%q, want empty", trackingURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAppID_FromStderr(t *testing.T) {
|
||||
stdout := ""
|
||||
stderr := "Submitted application application_123_456\n"
|
||||
appID, trackingURL, ok := parseSparkSubmitOutput(stdout, stderr)
|
||||
if !ok {
|
||||
t.Fatal("expected ok")
|
||||
}
|
||||
if appID != "application_123_456" {
|
||||
t.Errorf("appID=%q, want application_123_456", appID)
|
||||
}
|
||||
if trackingURL != "" {
|
||||
t.Errorf("trackingURL=%q, want empty", trackingURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAppID_FromTrackingURL(t *testing.T) {
|
||||
stdout := ""
|
||||
stderr := "Log line\ntracking URL: http://rm.example.com:8088/proxy/application_123_456/\n"
|
||||
appID, trackingURL, ok := parseSparkSubmitOutput(stdout, stderr)
|
||||
if !ok {
|
||||
t.Fatal("expected ok")
|
||||
}
|
||||
if appID != "application_123_456" {
|
||||
t.Errorf("appID=%q, want application_123_456", appID)
|
||||
}
|
||||
wantURL := "http://rm.example.com:8088/proxy/application_123_456/"
|
||||
if trackingURL != wantURL {
|
||||
t.Errorf("trackingURL=%q, want %q", trackingURL, wantURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAppID_NoAppID(t *testing.T) {
|
||||
stdout := ""
|
||||
stderr := "some random log"
|
||||
appID, trackingURL, ok := parseSparkSubmitOutput(stdout, stderr)
|
||||
if ok {
|
||||
t.Fatal("expected not ok")
|
||||
}
|
||||
if appID != "" {
|
||||
t.Errorf("appID=%q, want empty", appID)
|
||||
}
|
||||
if trackingURL != "" {
|
||||
t.Errorf("trackingURL=%q, want empty", trackingURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAppID_BadTrackingURL(t *testing.T) {
|
||||
stdout := ""
|
||||
stderr := "tracking URL: http://rm.example.com:8088/proxy/not-an-app/\n"
|
||||
appID, trackingURL, ok := parseSparkSubmitOutput(stdout, stderr)
|
||||
if ok {
|
||||
t.Fatal("expected not ok")
|
||||
}
|
||||
if appID != "" {
|
||||
t.Errorf("appID=%q, want empty", appID)
|
||||
}
|
||||
if trackingURL != "" {
|
||||
t.Errorf("trackingURL=%q, want empty", trackingURL)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user