Skip to content

Commit a714440

Browse files
authored
Merge pull request #63 from safesoftware/fix-projects-upload
Fix project import with updated v4.
2 parents eeab993 + 48e9484 commit a714440

File tree

6 files changed

+144
-53
lines changed

6 files changed

+144
-53
lines changed

cmd/engines_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,41 +309,47 @@ func TestEngines(t *testing.T) {
309309
statusCode: http.StatusOK,
310310
body: responseV3,
311311
args: []string{"engines"},
312+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
312313
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\\]",
313314
},
314315
{
315316
name: "get engines no headers",
316317
statusCode: http.StatusOK,
317318
body: responseV3,
318319
args: []string{"engines", "--no-headers"},
320+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
319321
wantOutputRegex: "[\\s]*387f74cd4e1f[\\s]*387f74cd4e1f[\\s]*23166[\\s]*linux-x64[\\s]*STANDARD[\\s]*-1[\\s]*\\[Standard 387f74cd4e1f 387f74cd4e1f 23166 linux-x64\\][\\s]*\\[Default\\]",
320322
},
321323
{
322324
name: "get engines json",
323325
statusCode: http.StatusOK,
324326
args: []string{"engines", "--json"},
325327
body: responseV3,
328+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
326329
wantOutputJson: responseV3,
327330
},
328331
{
329332
name: "get engines json via output type",
330333
statusCode: http.StatusOK,
331334
args: []string{"engines", "--output=json"},
332335
body: responseV3,
336+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
333337
wantOutputJson: responseV3,
334338
},
335339
{
336340
name: "get engines count",
337341
statusCode: http.StatusOK,
338342
body: responseV3FourEngines,
339343
args: []string{"engines", "--count"},
344+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
340345
wantOutputRegex: "4",
341346
},
342347
{
343348
name: "get engines custom columns",
344349
statusCode: http.StatusOK,
345350
body: responseV3FourEngines,
346351
args: []string{"engines", "--output=custom-columns=ENGINEMANAGER:.engineManagerNodeName,TRANSACTIONPORT:.transactionPort,CURRENTJOB:.currentJobID"},
352+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
347353
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",
348354
},
349355

cmd/jobs_v3_test.go

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -463,31 +463,36 @@ func TestJobs(t *testing.T) {
463463
name: "unknown flag",
464464
statusCode: http.StatusOK,
465465
args: []string{"jobs", "--badflag"},
466+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
466467
wantErrOutputRegex: "unknown flag: --badflag",
467468
},
468469
{
469-
name: "500 bad status code",
470-
statusCode: http.StatusInternalServerError,
471-
wantErrText: "500 Internal Server Error",
472-
args: []string{"jobs"},
470+
name: "500 bad status code",
471+
statusCode: http.StatusInternalServerError,
472+
wantErrText: "500 Internal Server Error",
473+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
474+
args: []string{"jobs"},
473475
},
474476
{
475-
name: "404 bad status code",
476-
statusCode: http.StatusNotFound,
477-
wantErrText: "404 Not Found",
478-
args: []string{"jobs"},
477+
name: "404 bad status code",
478+
statusCode: http.StatusNotFound,
479+
wantErrText: "404 Not Found",
480+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
481+
args: []string{"jobs"},
479482
},
480483
{
481484
name: "get jobs table output",
482485
statusCode: http.StatusOK,
483486
args: []string{"jobs"},
487+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
484488
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]*$",
485489
httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)),
486490
},
487491
{
488492
name: "get jobs all table output",
489493
statusCode: http.StatusOK,
490494
args: []string{"jobs", "--all"},
495+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
491496
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]*$",
492497
httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)),
493498
},
@@ -496,132 +501,151 @@ func TestJobs(t *testing.T) {
496501
statusCode: http.StatusOK,
497502
body: responseV3Running,
498503
args: []string{"jobs", "--running"},
504+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
499505
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*$",
500506
},
501507
{
502508
name: "get jobs active",
503509
statusCode: http.StatusOK,
504510
body: responseV3Active,
505511
args: []string{"jobs", "--active"},
512+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
506513
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]*$",
507514
},
508515
{
509516
name: "get jobs completed",
510517
statusCode: http.StatusOK,
511518
body: responseV3Completed,
512519
args: []string{"jobs", "--completed"},
520+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
513521
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]*$",
514522
},
515523
{
516524
name: "get jobs queued",
517525
statusCode: http.StatusOK,
518526
body: responseV3Queued,
519527
args: []string{"jobs", "--queued"},
528+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
520529
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$",
521530
},
522531
{
523532
name: "get jobs queued no headers",
524533
statusCode: http.StatusOK,
525534
body: responseV3Queued,
526535
args: []string{"jobs", "--queued", "--no-headers"},
536+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
527537
wantOutputRegex: "^[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$",
528538
},
529539
{
530540
name: "get jobs queued json",
531541
statusCode: http.StatusOK,
532542
args: []string{"jobs", "--queued", "--json"},
533543
body: responseV3Queued,
544+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
534545
wantOutputJson: responseV3Queued,
535546
},
536547
{
537548
name: "get jobs queued json output type",
538549
statusCode: http.StatusOK,
539550
args: []string{"jobs", "--queued", "--output=json"},
540551
body: responseV3Queued,
552+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
541553
wantOutputJson: responseV3Queued,
542554
},
543555
{
544-
name: "workspace flag requires repository",
545-
statusCode: http.StatusOK,
546-
args: []string{"jobs", "--workspace", "austinApartments.fmw"},
547-
wantErrText: "required flag(s) \"repository\" not set",
548-
body: responseV3Completed,
556+
name: "workspace flag requires repository",
557+
statusCode: http.StatusOK,
558+
args: []string{"jobs", "--workspace", "austinApartments.fmw"},
559+
wantErrText: "required flag(s) \"repository\" not set",
560+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
561+
body: responseV3Completed,
549562
},
550563
{
551-
name: "queued and active can't both be specified",
552-
statusCode: http.StatusOK,
553-
args: []string{"jobs", "--queued", "--active"},
554-
wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set",
555-
body: responseV3Completed,
564+
name: "queued and active can't both be specified",
565+
statusCode: http.StatusOK,
566+
args: []string{"jobs", "--queued", "--active"},
567+
wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set",
568+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
569+
body: responseV3Completed,
556570
},
557571
{
558-
name: "running and active can't both be specified",
559-
statusCode: http.StatusOK,
560-
args: []string{"jobs", "--running", "--active"},
561-
wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set",
562-
body: responseV3Completed,
572+
name: "running and active can't both be specified",
573+
statusCode: http.StatusOK,
574+
args: []string{"jobs", "--running", "--active"},
575+
wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set",
576+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
577+
body: responseV3Completed,
563578
},
564579
{
565580
name: "get jobs by repository",
566581
statusCode: http.StatusOK,
567582
args: []string{"jobs", "--repository", "Samples"},
568583
wantFormParams: map[string]string{"repository": "Samples"},
584+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
569585
body: responseV3Completed,
570586
},
571587
{
572588
name: "get jobs by workspace",
573589
statusCode: http.StatusOK,
574590
args: []string{"jobs", "--repository", "Samples", "--workspace", "austinApartments.fmw"},
575591
wantFormParams: map[string]string{"workspace": "austinApartments.fmw", "repository": "Samples"},
592+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
576593
body: responseV3Completed,
577594
},
578595
{
579596
name: "get jobs by source id",
580597
statusCode: http.StatusOK,
581598
args: []string{"jobs", "--source-id", "some-source-id"},
582599
wantFormParams: map[string]string{"sourceID": "some-source-id"},
600+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
583601
body: responseV3Completed,
584602
},
585603
{
586604
name: "get jobs by user",
587605
statusCode: http.StatusOK,
588606
args: []string{"jobs", "--user-name", "admin"},
589607
wantFormParams: map[string]string{"userName": "admin"},
608+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
590609
body: responseV3Completed,
591610
},
592611
{
593612
name: "get jobs by source-type",
594613
statusCode: http.StatusOK,
595614
args: []string{"jobs", "--source-type", "source"},
596615
wantFormParams: map[string]string{"sourceType": "source"},
616+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
597617
body: responseV3Completed,
598618
},
599619
{
600620
name: "get jobs completed custom columns",
601621
statusCode: http.StatusOK,
602622
body: responseV3Completed,
603623
args: []string{"jobs", "--completed", "--output", "custom-columns=CPU:.cpuTime,FEATURES OUTPUT:.result.numFeaturesOutput"},
624+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
604625
wantOutputRegex: "^[\\s]*CPU[\\s]*FEATURES OUTPUT[\\s]*994[\\s]*49[\\s]*697[\\s]*0[\\s]*$",
605626
},
606627
{
607628
name: "get single job",
608629
statusCode: http.StatusOK,
609630
args: []string{"jobs", "--id", "1"},
610631
body: responseV3SingleJob,
632+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
611633
wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*145929514b24[\\s]*none2none.fmw[\\s]*ABORTED[\\s]*$",
612634
},
613635
{
614636
name: "get single job json",
615637
statusCode: http.StatusOK,
616638
args: []string{"jobs", "--id", "1", "--json"},
617639
body: responseV3SingleJob,
640+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
618641
wantOutputJson: responseV3SingleJobOutput,
619642
},
620643
{
621-
name: "get single job does not exist",
622-
statusCode: http.StatusNotFound,
623-
args: []string{"jobs", "--id", "243"},
624-
wantErrText: "404 Not Found",
644+
name: "get single job does not exist",
645+
statusCode: http.StatusNotFound,
646+
args: []string{"jobs", "--id", "243"},
647+
fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold)
648+
wantErrText: "404 Not Found",
625649
},
626650
}
627651

cmd/projects_download.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type projectExportSelectedItem struct {
3838
ID string `json:"id"`
3939
}
4040

41+
var projectDownloadV4BuildThreshold = 23766
42+
4143
// backupCmd represents the backup command
4244
func newProjectDownloadCmd() *cobra.Command {
4345
f := projectsDownloadFlags{}
@@ -49,7 +51,7 @@ func newProjectDownloadCmd() *cobra.Command {
4951
// get build to decide if we should use v3 or v4
5052
if f.apiVersion == "" {
5153
fmeflowBuild := viper.GetInt("build")
52-
if fmeflowBuild < projectUploadV4BuildThreshold {
54+
if fmeflowBuild < projectDownloadV4BuildThreshold {
5355
f.apiVersion = apiVersionFlagV3
5456
} else {
5557
f.apiVersion = apiVersionFlagV4

0 commit comments

Comments
 (0)