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
20 changes: 15 additions & 5 deletions bcda/cclf/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ func getCCLFFileMetadata(cmsID, fileName string) (cclfFileMetadata, error) {
aco = `(?:\.ACO)`
bcd = `(?:BCD\.)`

// CCLF filename convention for SSP with BCD identifier: P.BCD.A****.ZC[0|8][Y|R]**.Dyymmdd.Thhmmsst
// CCLF file name convention for SSP with BCD identifier: P.BCD.A****.ZC[0|8][Y|R]**.Dyymmdd.Thhmmsst
ssp = `A\d{4}`
// CCLF filename convention for NGACO: P.V***.ACO.ZC[0|8][Y|R].Dyymmdd.Thhmmsst
// CCLF file name convention for IOTA with PRT identifier: P.IOTA***.PRT.ZC[0|8](Y|R).Dyymmdd.Thhmmsst
iotaPrt = `IOTA\d{3}(?:\.PRT)`
// CCLF file name convention for NGACO: P.V***.ACO.ZC[0|8][Y|R].Dyymmdd.Thhmmsst
ngaco = `V\d{3}`
// CCLF file name convention for CEC: P.CEC.ZC[0|8][Y|R].Dyymmdd.Thhmmsst
cec = `CEC`
Expand All @@ -175,9 +177,17 @@ func getCCLFFileMetadata(cmsID, fileName string) (cclfFileMetadata, error) {
// CCLF file name convention for SBX: P.SBX*****.ACO.ZC(Y|R)**.Dyymmdd.Thhmmsst
sandbox = `SBX[A-Z]{2}\d{3}`

pattern = prefix + `(` + bcd + ssp + `|` + ngaco + aco + `|` + cec +
`|` + ckcc + aco + `|` + kcf + aco + `|` + dc + aco +
`|` + test + aco + `|` + sandbox + aco + `)` + suffix
pattern = prefix + `(` +
bcd + ssp + `|` +
iotaPrt + `|` +
ngaco + aco + `|` +
cec + `|` +
ckcc + aco + `|` +
kcf + aco + `|` +
dc + aco + `|` +
test + aco + `|` +
sandbox + aco +
`)` + suffix
)

filenameRegexp := regexp.MustCompile(pattern)
Expand Down
57 changes: 48 additions & 9 deletions bcda/cclf/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestGetCMSID(t *testing.T) {
{"missingBCD", "path/T.A0001.ACO.ZCY18.D18NOV20.T1000009", true, ""},
{"not ZCY or ZCR", "path/T.BCD.A0001.ZC18.D181120.T1000000", true, ""},
{"missing ZCY and ZCR", "path/T.BCD.A0001.ZCA18.D181120.T1000000", true, ""},
{"validIotaPath", "path/T.BCD.IOTA123.ZCY18.D181120.T2000000", false, "IOTA123"},
{"empty", "", true, ""},
}
for _, tt := range tests {
Expand Down Expand Up @@ -197,15 +198,16 @@ func TestValidateCSVFileName(t *testing.T) {

func TestGetCCLFMetadata(t *testing.T) {
const (
sspID, cecID, ngacoID, ckccID, kcfID, dcID, testID, sbxID = "A9999", "E9999", "V999", "C9999", "K9999", "D9999", "TEST999", "SBXBD001"
sspProd, sspTest = "P.BCD." + sspID, "T.BCD." + sspID
cecProd, cecTest = "P.CEC", "T.CEC"
ngacoProd, ngacoTest = "P." + ngacoID + ".ACO", "T." + ngacoID + ".ACO"
ckccProd, ckccTest = "P." + ckccID + ".ACO", "T." + ckccID + ".ACO"
kcfProd, kcfTest = "P." + kcfID + ".ACO", "T." + kcfID + ".ACO"
dcProd, dcTest = "P." + dcID + ".ACO", "T." + dcID + ".ACO"
testProd, testTest = "P." + testID + ".ACO", "T." + testID + ".ACO"
sbxProd, sbxTest = "P." + sbxID + ".ACO", "T." + sbxID + ".ACO"
sspID, iotaID, cecID, ngacoID, ckccID, kcfID, dcID, testID, sbxID = "A9999", "IOTA965", "E9999", "V999", "C9999", "K9999", "D9999", "TEST999", "SBXBD001"
sspProd, sspTest = "P.BCD." + sspID, "T.BCD." + sspID
iotaProd, iotaTest = "P." + iotaID + ".PRT", "T." + iotaID + ".PRT"
cecProd, cecTest = "P.CEC", "T.CEC"
ngacoProd, ngacoTest = "P." + ngacoID + ".ACO", "T." + ngacoID + ".ACO"
ckccProd, ckccTest = "P." + ckccID + ".ACO", "T." + ckccID + ".ACO"
kcfProd, kcfTest = "P." + kcfID + ".ACO", "T." + kcfID + ".ACO"
dcProd, dcTest = "P." + dcID + ".ACO", "T." + dcID + ".ACO"
testProd, testTest = "P." + testID + ".ACO", "T." + testID + ".ACO"
sbxProd, sbxTest = "P." + sbxID + ".ACO", "T." + sbxID + ".ACO"
)

start := time.Now()
Expand All @@ -228,6 +230,7 @@ func TestGetCCLFMetadata(t *testing.T) {
assert.NoError(t, err)
sspProdFile, sspTestFile, sspRunoutFile := gen(sspProd, validTime), gen(sspTest, validTime),
strings.Replace(gen(sspProd, validTime), "ZC8Y", "ZC8R", 1)
iotaProdFile, iotaTestFile, iotaRunoutFile := gen(iotaProd, validTime), gen(iotaTest, validTime), strings.Replace(gen(iotaProd, validTime), "ZC8Y", "ZC8R", 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Im misreading but IOTAs middle section should be ZC(Y|R), as opposed to some of the others which tracks the CCLF file number (eg ZC8Y). If so, then I would expect this to fail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, it looks like the naming convention doesn't support a performance year. It looks like it's missing?

P.BCD.IOTA***.ZC(Y|R).Dyymmdd.Thhmmsst

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I cant load jira right now but it looks like the example was P.BCD.IOTA123.ZCY26.D260206.T1125000. I might have missed that in the regex I put in the ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR and the ticket to match new requirements -- both zip archive name and contained files should track with other cclf file conventions, with an extra "PRT" section in the latter
zip archive: P.BCD.IOTA123.ZCY26.D260206.T1125000
contained file: P.IOTA123.PRT.ZC0Y26.D260201.T0737324

cecProdFile, cecTestFile := gen(cecProd, validTime), gen(cecTest, validTime)
ngacoProdFile, ngacoTestFile := gen(ngacoProd, validTime), gen(ngacoTest, validTime)
ckccProdFile, ckccTestFile := gen(ckccProd, validTime), gen(ckccTest, validTime)
Expand Down Expand Up @@ -285,6 +288,42 @@ func TestGetCCLFMetadata(t *testing.T) {
fileType: models.FileTypeRunout,
},
},
{
"Production IOTA file", iotaID, iotaProdFile, "",
cclfFileMetadata{
env: "production",
name: iotaProdFile,
cclfNum: 8,
acoID: iotaID,
timestamp: validTime,
perfYear: perfYear,
fileType: models.FileTypeDefault,
},
},
{
"Test IOTA file", iotaID, iotaTestFile, "",
cclfFileMetadata{
env: "test",
name: iotaTestFile,
cclfNum: 8,
acoID: iotaID,
timestamp: validTime,
perfYear: perfYear,
fileType: models.FileTypeDefault,
},
},
{
"Runout IOTA file", iotaID, iotaRunoutFile, "",
cclfFileMetadata{
env: "production",
name: iotaRunoutFile,
cclfNum: 8,
acoID: iotaID,
timestamp: validTime,
perfYear: perfYear,
fileType: models.FileTypeRunout,
},
},
{
"Production CEC file", cecID, cecProdFile, "",
cclfFileMetadata{
Expand Down
7 changes: 7 additions & 0 deletions bcda/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ func TestSupportedACOs(t *testing.T) {
{"GUIDE invalid characters", "GUIDE99999", false},
{"valid GUIDE", "GUIDE-99999", true},

{"Iota too short", "IOTA12", false},
{"Iota too long", "IOTA0123", false},
{"Iota invalid characters 1", "IOTA12Z", false},
{"Iota invalid characters 2", "IOTA1YZ", false},
{"Iota invalid characters 3", "IOTAXYZ", false},
{"valid Iota", "IOTA123", true},

{"SBX too short", "SBXB1", false},
{"SBX too long", "SBXPA0123", false},
{"SBX invalid characters 1", "SBX0A123", false},
Expand Down