Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/engines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,41 +309,47 @@ func TestEngines(t *testing.T) {
statusCode: http.StatusOK,
body: responseV3,
args: []string{"engines"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "NAME[\\s]*HOST[\\s]*BUILD[\\s]*PLATFORM[\\s]*TYPE[\\s]*CURRENT JOB ID[\\s]*REGISTRATION PROPERTIES[\\s]*QUEUES[\\s]*[\\s]*387f74cd4e1f[\\s]*387f74cd4e1f[\\s]*23166[\\s]*linux-x64[\\s]*STANDARD[\\s]*-1[\\s]*\\[Standard 387f74cd4e1f 387f74cd4e1f 23166 linux-x64\\][\\s]*\\[Default\\]",
},
{
name: "get engines no headers",
statusCode: http.StatusOK,
body: responseV3,
args: []string{"engines", "--no-headers"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "[\\s]*387f74cd4e1f[\\s]*387f74cd4e1f[\\s]*23166[\\s]*linux-x64[\\s]*STANDARD[\\s]*-1[\\s]*\\[Standard 387f74cd4e1f 387f74cd4e1f 23166 linux-x64\\][\\s]*\\[Default\\]",
},
{
name: "get engines json",
statusCode: http.StatusOK,
args: []string{"engines", "--json"},
body: responseV3,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputJson: responseV3,
},
{
name: "get engines json via output type",
statusCode: http.StatusOK,
args: []string{"engines", "--output=json"},
body: responseV3,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputJson: responseV3,
},
{
name: "get engines count",
statusCode: http.StatusOK,
body: responseV3FourEngines,
args: []string{"engines", "--count"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "4",
},
{
name: "get engines custom columns",
statusCode: http.StatusOK,
body: responseV3FourEngines,
args: []string{"engines", "--output=custom-columns=ENGINEMANAGER:.engineManagerNodeName,TRANSACTIONPORT:.transactionPort,CURRENTJOB:.currentJobID"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "[\\s]*ENGINEMANAGER[\\s]*TRANSACTIONPORT[\\s]*CURRENTJOB[\\s]*fmeflowcore[\\s]*40935[\\s]*-1[\\s]*fmeflowcore[\\s]*36883[\\s]*-1[\\s]*fmeflowcore[\\s]*44089[\\s]*-1[\\s]*fmeflowcore[\\s]*44795[\\s]*-1",
},

Expand Down
78 changes: 51 additions & 27 deletions cmd/jobs_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,31 +463,36 @@ func TestJobs(t *testing.T) {
name: "unknown flag",
statusCode: http.StatusOK,
args: []string{"jobs", "--badflag"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantErrOutputRegex: "unknown flag: --badflag",
},
{
name: "500 bad status code",
statusCode: http.StatusInternalServerError,
wantErrText: "500 Internal Server Error",
args: []string{"jobs"},
name: "500 bad status code",
statusCode: http.StatusInternalServerError,
wantErrText: "500 Internal Server Error",
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
args: []string{"jobs"},
},
{
name: "404 bad status code",
statusCode: http.StatusNotFound,
wantErrText: "404 Not Found",
args: []string{"jobs"},
name: "404 bad status code",
statusCode: http.StatusNotFound,
wantErrText: "404 Not Found",
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
args: []string{"jobs"},
},
{
name: "get jobs table output",
statusCode: http.StatusOK,
args: []string{"jobs"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$",
httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)),
},
{
name: "get jobs all table output",
statusCode: http.StatusOK,
args: []string{"jobs", "--all"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$",
httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)),
},
Expand All @@ -496,132 +501,151 @@ func TestJobs(t *testing.T) {
statusCode: http.StatusOK,
body: responseV3Running,
args: []string{"jobs", "--running"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*$",
},
{
name: "get jobs active",
statusCode: http.StatusOK,
body: responseV3Active,
args: []string{"jobs", "--active"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$",
},
{
name: "get jobs completed",
statusCode: http.StatusOK,
body: responseV3Completed,
args: []string{"jobs", "--completed"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$",
},
{
name: "get jobs queued",
statusCode: http.StatusOK,
body: responseV3Queued,
args: []string{"jobs", "--queued"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$",
},
{
name: "get jobs queued no headers",
statusCode: http.StatusOK,
body: responseV3Queued,
args: []string{"jobs", "--queued", "--no-headers"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$",
},
{
name: "get jobs queued json",
statusCode: http.StatusOK,
args: []string{"jobs", "--queued", "--json"},
body: responseV3Queued,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputJson: responseV3Queued,
},
{
name: "get jobs queued json output type",
statusCode: http.StatusOK,
args: []string{"jobs", "--queued", "--output=json"},
body: responseV3Queued,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputJson: responseV3Queued,
},
{
name: "workspace flag requires repository",
statusCode: http.StatusOK,
args: []string{"jobs", "--workspace", "austinApartments.fmw"},
wantErrText: "required flag(s) \"repository\" not set",
body: responseV3Completed,
name: "workspace flag requires repository",
statusCode: http.StatusOK,
args: []string{"jobs", "--workspace", "austinApartments.fmw"},
wantErrText: "required flag(s) \"repository\" not set",
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "queued and active can't both be specified",
statusCode: http.StatusOK,
args: []string{"jobs", "--queued", "--active"},
wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set",
body: responseV3Completed,
name: "queued and active can't both be specified",
statusCode: http.StatusOK,
args: []string{"jobs", "--queued", "--active"},
wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set",
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "running and active can't both be specified",
statusCode: http.StatusOK,
args: []string{"jobs", "--running", "--active"},
wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set",
body: responseV3Completed,
name: "running and active can't both be specified",
statusCode: http.StatusOK,
args: []string{"jobs", "--running", "--active"},
wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set",
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs by repository",
statusCode: http.StatusOK,
args: []string{"jobs", "--repository", "Samples"},
wantFormParams: map[string]string{"repository": "Samples"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs by workspace",
statusCode: http.StatusOK,
args: []string{"jobs", "--repository", "Samples", "--workspace", "austinApartments.fmw"},
wantFormParams: map[string]string{"workspace": "austinApartments.fmw", "repository": "Samples"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs by source id",
statusCode: http.StatusOK,
args: []string{"jobs", "--source-id", "some-source-id"},
wantFormParams: map[string]string{"sourceID": "some-source-id"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs by user",
statusCode: http.StatusOK,
args: []string{"jobs", "--user-name", "admin"},
wantFormParams: map[string]string{"userName": "admin"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs by source-type",
statusCode: http.StatusOK,
args: []string{"jobs", "--source-type", "source"},
wantFormParams: map[string]string{"sourceType": "source"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
body: responseV3Completed,
},
{
name: "get jobs completed custom columns",
statusCode: http.StatusOK,
body: responseV3Completed,
args: []string{"jobs", "--completed", "--output", "custom-columns=CPU:.cpuTime,FEATURES OUTPUT:.result.numFeaturesOutput"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*CPU[\\s]*FEATURES OUTPUT[\\s]*994[\\s]*49[\\s]*697[\\s]*0[\\s]*$",
},
{
name: "get single job",
statusCode: http.StatusOK,
args: []string{"jobs", "--id", "1"},
body: responseV3SingleJob,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*145929514b24[\\s]*none2none.fmw[\\s]*ABORTED[\\s]*$",
},
{
name: "get single job json",
statusCode: http.StatusOK,
args: []string{"jobs", "--id", "1", "--json"},
body: responseV3SingleJob,
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantOutputJson: responseV3SingleJobOutput,
},
{
name: "get single job does not exist",
statusCode: http.StatusNotFound,
args: []string{"jobs", "--id", "243"},
wantErrText: "404 Not Found",
name: "get single job does not exist",
statusCode: http.StatusNotFound,
args: []string{"jobs", "--id", "243"},
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
wantErrText: "404 Not Found",
},
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/projects_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type projectExportSelectedItem struct {
ID string `json:"id"`
}

var projectDownloadV4BuildThreshold = 23766

// backupCmd represents the backup command
func newProjectDownloadCmd() *cobra.Command {
f := projectsDownloadFlags{}
Expand All @@ -49,7 +51,7 @@ func newProjectDownloadCmd() *cobra.Command {
// get build to decide if we should use v3 or v4
if f.apiVersion == "" {
fmeflowBuild := viper.GetInt("build")
if fmeflowBuild < projectUploadV4BuildThreshold {
if fmeflowBuild < projectDownloadV4BuildThreshold {
f.apiVersion = apiVersionFlagV3
} else {
f.apiVersion = apiVersionFlagV4
Expand Down
Loading