Skip to content

Commit 9c284fa

Browse files
authored
Skip tests with no fix for X days (jfrog#533)
1 parent 209fa57 commit 9c284fa

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

artifactory_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/jfrog/jfrog-cli-security/jas"
2424
securityTests "github.com/jfrog/jfrog-cli-security/tests"
2525
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
26-
"github.com/jfrog/jfrog-cli-security/tests/utils/integration"
2726
securityIntegrationTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils/integration"
2827
"github.com/jfrog/jfrog-cli-security/utils"
2928
"github.com/jfrog/jfrog-cli-security/utils/artifactory"
@@ -49,6 +48,7 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
4948
resolveRepoName string
5049
cacheRepoName string
5150
projectType project.ProjectType
51+
skipMsg string
5252
}{
5353
{
5454
testProjectPath: []string{"npm", "npm-no-lock"},
@@ -61,6 +61,7 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
6161
resolveRepoName: securityTests.NugetRemoteRepo,
6262
cacheRepoName: securityTests.NugetRemoteRepo,
6363
projectType: project.Dotnet,
64+
skipMsg: "Dotnet restore fails, pending fix XRAY-128186",
6465
},
6566
{
6667
testProjectPath: []string{"yarn", "yarn-v2"},
@@ -85,6 +86,7 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
8586
resolveRepoName: securityTests.MvnVirtualRepo,
8687
cacheRepoName: securityTests.MvnRemoteRepo,
8788
projectType: project.Maven,
89+
skipMsg: "Snapshot repository is blocked by JPD, pending fix XRAY-124910",
8890
},
8991
{
9092
testProjectPath: []string{"go", "simple-project"},
@@ -116,6 +118,9 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
116118

117119
for _, testCase := range testCases {
118120
t.Run(testCase.projectType.String(), func(t *testing.T) {
121+
if testCase.skipMsg != "" {
122+
securityTestUtils.SkipTestIfDurationNotPassed(t, "22-10-2025", 30, testCase.skipMsg)
123+
}
119124
testSingleTechDependencyResolution(t, testCase.testProjectPath, testCase.resolveRepoName, testCase.cacheRepoName, testCase.projectType)
120125
})
121126
}
@@ -289,7 +294,7 @@ func TestUploadCdxCmdCommand(t *testing.T) {
289294
}
290295
defer securityIntegrationTestUtils.ExecDeleteRepo(repoPath)
291296
// Run the upload command
292-
assert.NoError(t, integration.GetArtifactoryCli(cli.GetJfrogCliSecurityApp()).Exec("upload-cdx", "--rt-repo-path", repoPath, cdxFileToUpload))
297+
assert.NoError(t, securityIntegrationTestUtils.GetArtifactoryCli(cli.GetJfrogCliSecurityApp()).Exec("upload-cdx", "--rt-repo-path", repoPath, cdxFileToUpload))
293298

294299
// Validate the file was uploaded successfully
295300
searchResults, err := artifactory.SearchArtifactsInRepo(securityTests.RtDetails, filepath.Base(cdxFileToUpload), repoPath)

sca/bom/buildinfo/technologies/nuget/nuget_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"github.com/jfrog/build-info-go/entities"
1717
"github.com/jfrog/jfrog-cli-core/v2/utils/tests"
1818
"github.com/stretchr/testify/assert"
19+
20+
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
1921
)
2022

2123
var testDataDir = filepath.Join("..", "..", "..", "..", "..", "tests", "testdata", "projects", "package-managers")
@@ -154,6 +156,7 @@ func TestSkipBuildDepTreeWhenInstallForbidden(t *testing.T) {
154156
testDir string
155157
installCommand string
156158
successfulTreeBuiltExpected bool
159+
skipMsg string
157160
}{
158161
{
159162
name: "nuget single 4.0 - installed | install not required",
@@ -164,6 +167,7 @@ func TestSkipBuildDepTreeWhenInstallForbidden(t *testing.T) {
164167
name: "nuget single 5.0 - not installed | install required - install command",
165168
testDir: filepath.Join("projects", "package-managers", "nuget", "single5.0"),
166169
installCommand: "nuget restore", // todo test in ci with nuget restore
170+
skipMsg: "CI fails on 'dotnet restore' - MSBuild auto-detection: using msbuild version '' from '/opt/homebrew/bin', pending fix XRAY-128186",
167171
successfulTreeBuiltExpected: true,
168172
},
169173
{
@@ -175,6 +179,7 @@ func TestSkipBuildDepTreeWhenInstallForbidden(t *testing.T) {
175179
name: "nuget multi - not installed | install required - install command",
176180
testDir: filepath.Join("projects", "package-managers", "nuget", "multi"),
177181
installCommand: "nuget restore", // todo test in ci with nuget restore
182+
skipMsg: "CI fails on 'dotnet restore' - MSBuild auto-detection: using msbuild version '' from '/opt/homebrew/bin', pending fix XRAY-128186",
178183
successfulTreeBuiltExpected: true,
179184
},
180185
{
@@ -196,6 +201,9 @@ func TestSkipBuildDepTreeWhenInstallForbidden(t *testing.T) {
196201

197202
for _, test := range testCases {
198203
t.Run(test.name, func(t *testing.T) {
204+
if test.skipMsg != "" {
205+
securityTestUtils.SkipTestIfDurationNotPassed(t, "22-10-2025", 30, test.skipMsg)
206+
}
199207
// Create and change directory to test workspace
200208
_, cleanUp := technologies.CreateTestWorkspace(t, test.testDir)
201209
defer cleanUp()

tests/consts.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,18 @@ func getTestResourcesPath(basePath string) string {
115115
// Return local and remote repositories for the test suites, respectfully
116116
func GetNonVirtualRepositories() map[*string]string {
117117
nonVirtualReposMap := map[*bool][]*string{
118-
TestDockerScan: {&DockerLocalRepo, &DockerRemoteRepo},
119-
TestArtifactory: {&NpmRemoteRepo, &NugetRemoteRepo, &YarnRemoteRepo, &GradleRemoteRepo, &MvnRemoteRepo, &MvnRemoteSnapshotsRepo, &GoRepo, &GoRemoteRepo, &PypiRemoteRepo},
118+
TestDockerScan: {&DockerLocalRepo, &DockerRemoteRepo},
119+
TestArtifactory: {
120+
&NpmRemoteRepo,
121+
&NugetRemoteRepo,
122+
&YarnRemoteRepo,
123+
&GradleRemoteRepo,
124+
&MvnRemoteRepo,
125+
&MvnRemoteSnapshotsRepo,
126+
&GoRepo,
127+
&GoRemoteRepo,
128+
&PypiRemoteRepo,
129+
},
120130
}
121131
return getNeededRepositories(nonVirtualReposMap)
122132
}
@@ -149,7 +159,9 @@ func getNeededRepositories(reposMap map[*bool][]*string) map[*string]string {
149159
for needed, testRepos := range reposMap {
150160
if *needed {
151161
for _, repo := range testRepos {
152-
reposToCreate[repo] = reposConfigMap[repo]
162+
if reposConfigMap[repo] != "" {
163+
reposToCreate[repo] = reposConfigMap[repo]
164+
}
153165
}
154166
}
155167
}

tests/testdata/artifactory-repo-configs/maven_remote_snapshots_repository_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"key": "${MAVEN_REMOTE_SNAPSHOTS_REPO}",
33
"rclass": "remote",
44
"packageType": "maven",
5-
"url": "https://repo.spring.io/snapshot"
5+
"url": "https://repository.apache.org/snapshots"
66
}

tests/utils/integration/test_integrationutils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func InitAuditNewScaTests(t *testing.T, minVersion string) {
104104
if !*configTests.TestAuditNewSca {
105105
t.Skip(getSkipTestMsg("Audit command new SCA integration", "--test.audit.NewSca"))
106106
}
107+
testUtils.SkipTestIfDurationNotPassed(t, "22-10-2025", 14, "Catalog API not available yet in test platform.")
107108
testUtils.GetAndValidateXrayVersion(t, minVersion)
108109
}
109110

tests/utils/test_utils.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@ import (
3232
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"
3333
)
3434

35+
// SkipTestIfDurationNotPassed skips the test if the specified duration in days hasn't passed since the given date.
36+
// dateStr should be in the format "02-01-2006" (DD-MM-YYYY).
37+
// durationDays is the number of days that should have passed.
38+
func SkipTestIfDurationNotPassed(t *testing.T, dateStr string, durationDays int, msg string) {
39+
givenDate, err := time.Parse("02-01-2006", dateStr)
40+
if err != nil {
41+
t.Fatalf("Invalid date format '%s'. Expected format: DD-MM-YYYY", dateStr)
42+
}
43+
44+
daysSinceDate := int(time.Since(givenDate).Hours() / 24)
45+
if daysSinceDate < durationDays {
46+
if msg == "" {
47+
t.Skipf("Skipping test. Only %d days have passed since %s, but %d days are required.", daysSinceDate, dateStr, durationDays)
48+
} else {
49+
t.Skipf("Skipping test (%d/%d days have passed since %s, but %d days are required.) Reason: %s", daysSinceDate, durationDays, dateStr, durationDays, msg)
50+
}
51+
}
52+
}
53+
3554
func UnmarshalJson(t *testing.T, output string) formats.EnrichJson {
3655
var jsonMap formats.EnrichJson
3756
err := json.Unmarshal([]byte(output), &jsonMap)

0 commit comments

Comments
 (0)