Skip to content

Commit

Permalink
changed migate download path
Browse files Browse the repository at this point in the history
  • Loading branch information
shokakucarrier committed Mar 14, 2024
1 parent ac5017a commit a27509f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
49 changes: 21 additions & 28 deletions pkg/buildtest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ func DoRun(originalIndy, targetIndy, indyProxyUrl, migrateTargetIndy, packageTyp
common.ValidateTargetIndyOrExit(originalIndy)
targetIndyHost, _ := common.ValidateTargetIndyOrExit(targetIndy)

// Prepare the indy repos for the whole testing
buildMeta := decideMeta(packageType)
if !prepareIndyRepos("http://"+targetIndyHost, newBuildName, *buildMeta, additionalRepos, dryRun) {
os.Exit(1)
}

migrateEnabled := (migrateTargetIndy != "")
if migrateEnabled {
migrateTargetIndyHost, _ := common.ValidateTargetIndyOrExit(migrateTargetIndy)
fmt.Printf("Migrate to host %s", migrateTargetIndyHost)
} else {
// Prepare the indy repos for the whole testing
buildMeta := decideMeta(packageType)
if !prepareIndyRepos("http://"+targetIndyHost, newBuildName, *buildMeta, additionalRepos, dryRun) {
os.Exit(1)
}
}

trackingId := foloTrackContent.TrackingKey.Id
Expand Down Expand Up @@ -97,7 +97,7 @@ func DoRun(originalIndy, targetIndy, indyProxyUrl, migrateTargetIndy, packageTyp

if migrateEnabled {
migrateTargetIndyHost, _ := common.ValidateTargetIndyOrExit(migrateTargetIndy)
migrateArtifacts := prepareMigrateEntriesByFolo(targetIndy, newBuildName, packageType, foloTrackContent, additionalRepos, proxyEnabled)
migrateArtifacts := prepareMigrateEntriesByFolo(targetIndy, newBuildName, packageType, foloTrackContent)
for _, down := range migrateArtifacts {
migratePath := setHostname(down[3], migrateTargetIndyHost)
fmt.Printf("[%s] Deleting %s\n", time.Now().Format(DATA_TIME), migratePath)
Expand All @@ -109,17 +109,18 @@ func DoRun(originalIndy, targetIndy, indyProxyUrl, migrateTargetIndy, packageTyp
broken = !delRequest(extra)
}

if down[1] == "npm:remote:npmjs" {
migratePath := strings.Replace(migratePath, "/npm/remote/npmjs", "/npm/hosted/shared-imports", 1)
if down[1] == "npm:remote:npmjs" || down[1] == "maven:remote:central" {
migratePath := url.JoinPath("http://"+migrateTargetIndyHost, "/api/content", packageType, "/hosted/shared-imports", down[4])

Check failure on line 113 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.16.15)

undefined: url.JoinPath

Check failure on line 113 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.17.13)

undefined: url.JoinPath

Check failure on line 113 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.18.8)

undefined: url.JoinPath
fmt.Printf("[%s] Deleting %s\n", time.Now().Format(DATA_TIME), migratePath)
broken = !delRequest(migratePath)

} else if down[1] == "maven:remote:central" {
migratePath := strings.Replace(migratePath, "/maven/remote/central", "/maven/hosted/shared-imports", 1)
} else if down[1] == "maven:remote:mrrc-ga-rh" {
migratePath := url.JoinPath("http://"+migrateTargetIndyHost, "/api/content", packageType, "/hosted/pnc-builds", down[4])

Check failure on line 118 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.16.15)

undefined: url.JoinPath

Check failure on line 118 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.17.13)

undefined: url.JoinPath

Check failure on line 118 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.18.8)

undefined: url.JoinPath
fmt.Printf("[%s] Deleting %s\n", time.Now().Format(DATA_TIME), migratePath)
broken = !delRequest(migratePath)

} else if down[1] == "maven:remote:mrrc-ga-rh" {
migratePath := strings.Replace(migratePath, "/maven/remote/mrrc-ga-rh", "/maven/hosted/pnc-builds", 1)
} else if stings.HasPrefix(down[1], "maven:hosted:build-") {

Check failure on line 122 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.16.15)

undefined: stings

Check failure on line 122 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.17.13)

undefined: stings

Check failure on line 122 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.18.8)

undefined: stings
migratePath := url.JoinPath("http://"+migrateTargetIndyHost, "/api/content", packageType, "/hosted/pnc-builds", down[4])

Check failure on line 123 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.16.15)

undefined: url.JoinPath

Check failure on line 123 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.17.13)

undefined: url.JoinPath

Check failure on line 123 in pkg/buildtest/run.go

View workflow job for this annotation

GitHub Actions / build (1.18.8)

undefined: url.JoinPath
fmt.Printf("[%s] Deleting %s\n", time.Now().Format(DATA_TIME), migratePath)
broken = !delRequest(migratePath)

Expand Down Expand Up @@ -278,30 +279,22 @@ func prepareDownloadEntriesByFolo(targetIndyURL, newBuildId, packageType string,
}

func prepareMigrateEntriesByFolo(targetIndyURL, newBuildId, packageType string,
foloRecord common.TrackedContent, additionalRepos []string, proxyEnabled bool) map[string][]string {
foloRecord common.TrackedContent) map[string][]string {
targetIndy := normIndyURL(targetIndyURL)
result := make(map[string][]string)
for _, down := range foloRecord.Downloads {
var p string
downUrl := ""
repoPath := strings.ReplaceAll(down.StoreKey, ":", "/")
if down.AccessChannel == "GENERIC_PROXY" {
if proxyEnabled {
downUrl = fmt.Sprintf("%s%s", PROXY_, down.OriginUrl)
} else {
// Generic remote repo may not be available when we replay the build. PNC has promoted the files to "h-" repo,
// so we replace "generic-http/remote/r-xxxx" to "generic-http:hosted:h-xxxx"
repoPath = strings.Replace(repoPath, "generic-http/remote/r-", "generic-http/hosted/h-", 1)
p = path.Join("api/content", repoPath, down.Path)
downUrl = fmt.Sprintf("%s%s", targetIndy, p)
}
repoPath = strings.Replace(repoPath, "generic-http/remote/r-", "generic-http/hosted/h-", 1)
p = path.Join("api/content", repoPath, down.Path)
downUrl = fmt.Sprintf("%s%s", targetIndy, p)
} else {
// To explain the 'HasPrefix': NPM build can have downloads from maven repos (or vice verse). We use the original repo
// if the storeKey is not compliant with packageType
if common.Contains(additionalRepos, down.StoreKey) || !strings.HasPrefix(down.StoreKey, packageType) {
p = path.Join("api/folo/track", newBuildId, repoPath, down.Path)
if !strings.HasPrefix(down.StoreKey, packageType) {
p = path.Join("api/content", repoPath, down.Path)
} else {
p = path.Join("api/folo/track", newBuildId, packageType, "group", newBuildId, down.Path)
p = path.Join("api/content", packageType, "group/builds-untested+shared-imports+public", down.Path)
}
downUrl = fmt.Sprintf("%s%s", targetIndy, p)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/integrationtest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ func Run(indyBaseUrl, datasetRepoUrl, buildId, promoteTargetStore, metaCheckRepo
//k. Delete the temp group and the hosted repo, and folo record
defer cleanUp(indyBaseUrl, packageType, buildName, dryRun)

// Advanced checks
if buildSuccess && !dryRun {
if !verifyFoloRecord(indyBaseUrl, buildName, foloTrackContent) {
return
}
}

migrateEnabled := (migrateTargetIndy != "")
if !migrateEnabled {
// Advanced checks
if buildSuccess && !dryRun {
if !verifyFoloRecord(indyBaseUrl, buildName, foloTrackContent) {
return
}
}

//f. Retrieve the metadata files which will be affected by promotion
metaFiles := calculateMetadataFiles(foloTrackContent)
metaFilesLoc := path.Join(TMP_METADATA_DIR, "before-promote")
Expand Down

0 comments on commit a27509f

Please sign in to comment.