Skip to content

Commit

Permalink
SONARGO-58 Clean up integration tests to only include Go (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
petertrr committed Dec 10, 2024
1 parent 1c8ea6c commit 7e4becb
Show file tree
Hide file tree
Showing 112 changed files with 25,160 additions and 27,776 deletions.
7 changes: 1 addition & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
ORG_GRADLE_PROJECT_signingPassword: VAULT[development/kv/data/sign data.passphrase]
ORG_GRADLE_PROJECT_signingKeyId: VAULT[development/kv/data/sign data.key_id]

GIT_SUB_MODULE: ""
GRADLE_USER_HOME: ${CIRRUS_WORKING_DIR}/.gradle

linux_image_template: &LINUX_IMAGE
Expand Down Expand Up @@ -92,10 +91,7 @@ qa_task_filter_template: &QA_TASK_FILTER
gradle_its_template: &GRADLE_ITS_TEMPLATE
<<: *SETUP_GRADLE_CACHE
run_its_script:
- |
if [ -n "${GIT_SUB_MODULE}" ]; then
git submodule update --init --depth 1 "${GIT_SUB_MODULE}"
fi
- git submodule update --init --depth 1
- source cirrus-env QA
- ./gradlew "${GRADLE_TASK}" "-P${ITS_PROJECT}"
"-Dsonar.runtimeVersion=${SQ_VERSION}"
Expand All @@ -122,7 +118,6 @@ qa_ruling_task:
SQ_VERSION: "LATEST_RELEASE"
GRADLE_TASK: ":its:ruling:test"
ITS_PROJECT: "ruling"
GIT_SUB_MODULE: "its/sources"
<<: *LINUX_4_CPU_6G_JAVA_17
<<: *GRADLE_ITS_TEMPLATE

Expand Down
15 changes: 12 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "its/sources"]
path = its/sources
url = https://github.com/SonarSource/slang-test-sources.git
[submodule "its/sources/traefik"]
path = its/sources/traefik
url = https://github.com/traefik/traefik
[submodule "its/sources/minio"]
path = its/sources/minio
url = https://github.com/minio/minio
[submodule "its/sources/prometheus"]
path = its/sources/prometheus
url = https://github.com/prometheus/prometheus
[submodule "its/sources/kubernetes-client-go"]
path = its/sources/kubernetes-client-go
url = https://github.com/kubernetes/client-go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -39,7 +40,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class SlangRulingTest {
public class GoRulingTest {

private static final String SQ_VERSION_PROPERTY = "sonar.runtimeVersion";
private static final String DEFAULT_SQ_VERSION = "LATEST_RELEASE";
Expand All @@ -64,7 +65,7 @@ public static void setUp() {
goRulesConfiguration.add("S1451", "headerFormat", "^(?i).*copyright");
goRulesConfiguration.add("S1451", "isRegularExpression", "true");

File goProfile = ProfileGenerator.generateProfile(SlangRulingTest.orchestrator.getServer().getUrl(), "go", "go", goRulesConfiguration, Collections.emptySet());
File goProfile = ProfileGenerator.generateProfile(GoRulingTest.orchestrator.getServer().getUrl(), "go", "go", goRulesConfiguration, Collections.emptySet());

orchestrator.getServer().restoreProfile(FileLocation.of(goProfile));
}
Expand All @@ -86,18 +87,16 @@ static void addGoPlugin(OrchestratorBuilder builder) {
}

@Test
// @Ignore because it should only be run manually
@Ignore
@Ignore("This test should only be run manually")
public void go_manual_keep_sonarqube_server_up() throws IOException {
keepSonarqubeRunning = true;
test_go();
}


@Test
public void test_go() throws IOException {
Map<String, String> properties = new HashMap<>();
properties.put("sonar.inclusions", "sources/go/**/*.go, ruling/src/test/resources/sources/go/**/*.go");
properties.put("sonar.inclusions", "sources/**/*.go, ruling/src/test/resources/sources/**/*.go");
properties.put("sonar.exclusions", "**/*generated*.go, **/*.pb.go");
properties.put("sonar.tests", ".");
properties.put("sonar.test.inclusions", "**/*_test.go");
Expand All @@ -109,22 +108,22 @@ private void run_ruling_test(Map<String, String> projectProperties) throws IOExc
properties.put("sonar.slang.converter.validation", "log");
properties.put("sonar.slang.duration.statistics", "true");

String projectKey = "go".replace("/", "-") + "-project";
var projectKey = "go-project";
orchestrator.getServer().provisionProject(projectKey, projectKey);
orchestrator.getServer().associateProjectToQualityProfile(projectKey, "go", "rules");

File actualDirectory = FileLocation.of("build/tmp/actual/" + "go").getFile();
var actualDirectory = new File("build/reports/lits");
actualDirectory.mkdirs();

File litsDifferencesFile = FileLocation.of("build/" + projectKey + "-differences").getFile();
var litsDifferencesFile = new File("build/" + projectKey + "-differences");
SonarScanner build = SonarScanner.create(FileLocation.of("../").getFile())
.setProjectKey(projectKey)
.setProjectName(projectKey)
.setProjectVersion("1")
.setSourceDirs("./")
.setSourceEncoding("utf-8")
.setProperties(properties)
.setProperty("sonar.lits.dump.old", FileLocation.of("src/test/resources/expected/" + "go").getFile().getAbsolutePath())
.setProperty("sonar.lits.dump.old", Path.of("src/test/resources/expected").toAbsolutePath().toString())
.setProperty("sonar.lits.dump.new", actualDirectory.getAbsolutePath())
.setProperty("sonar.lits.differences", litsDifferencesFile.getAbsolutePath())
.setProperty("sonar.cpd.exclusions", "**/*")
Expand Down
5 changes: 5 additions & 0 deletions its/ruling/src/test/resources/expected/go-ParsingError.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
'go-project:ruling/src/test/resources/sources/ParsingError.go':[
0,
],
}
40 changes: 40 additions & 0 deletions its/ruling/src/test/resources/expected/go-S100.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
'go-project:sources/kubernetes-client-go/scale/scheme/appsv1beta1/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/scale/scheme/appsv1beta2/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/scale/scheme/autoscalingv1/conversion.go':[
28,
42,
],
'go-project:sources/kubernetes-client-go/scale/scheme/extensionsv1beta1/conversion.go':[
28,
47,
],
'go-project:sources/kubernetes-client-go/tools/cache/delta_fifo.go':[
303,
],
'go-project:sources/kubernetes-client-go/tools/cache/fifo.go':[
158,
],
'go-project:sources/kubernetes-client-go/tools/clientcmd/api/v1/conversion.go':[
28,
46,
65,
83,
102,
120,
139,
157,
],
'go-project:sources/kubernetes-client-go/tools/clientcmd/api/v1/defaults.go':[
27,
],
'go-project:sources/prometheus/promql/query_logger.go':[
176,
],
}
Loading

0 comments on commit 7e4becb

Please sign in to comment.