Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle binaries and sourcecode data section parts at PDS and SecHub side #1316

Merged
merged 19 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5f9ff7a
Start implementing support for binaries on PDS side #1167
de-jcup May 6, 2022
4403785
Moved gradle sub parts to gradle folder #1321 + introduce archive
de-jcup May 9, 2022
e207666
Replaced PDSScanType with ScanType #1322,consolidate archive parts #1323
de-jcup May 9, 2022
32a60fc
Combined Tar and ZipSupport into one single codebase #1323
de-jcup May 9, 2022
e7f99c1
Implemented transformation while extracting ZIP and Tars #1167
de-jcup May 9, 2022
d9169a3
made integration tests faster #1340
de-jcup May 12, 2022
b57c749
Using now always growing scenarios to speed up execution time #1340
de-jcup May 16, 2022
0c1e4e8
Integration test enhancements #1340
de-jcup May 17, 2022
ab078f4
Created javadoc overview and details about profiles for testing #1167
de-jcup May 18, 2022
55b70f1
Implemented integration test for binary PDS handling #1167
de-jcup May 19, 2022
3b05a35
Merge branch 'develop' into feature-1167-handle-binaries-on-PDS-serve…
de-jcup May 19, 2022
c0f208d
Implementation changes for #1167
de-jcup May 19, 2022
ef49e51
Implementation changes for #1167
de-jcup May 20, 2022
9e82d60
Introduce environment variables + handle uploads different #1308
de-jcup May 24, 2022
3390eca
Use binary upload mechanism introduced in sechub for pds uploads #1351
de-jcup May 24, 2022
ce33e7a
Added integration tests + updated documentation #1167
de-jcup May 25, 2022
5386162
Merge branch 'develop' into feature-1167
de-jcup May 25, 2022
be41d9c
Added archive extraction documentation #1177
de-jcup May 25, 2022
ce0ac1f
Review changes for PR #1316
de-jcup Jun 1, 2022
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
Prev Previous commit
Next Next commit
Using now always growing scenarios to speed up execution time #1340
- some minor changes
- created new gradle task `cleanIntegrationTestData`
  and integrated in to `integrationtest` task so will be executed
  on every server build automaticaly and ensures growing ids
  are always reset
- Growing scenarios abstract implementation does now create
  main prefix automatically
- added test case
- every `CleanScenario` has been changed to `GrowingScenario` and
  inherits now AbstractGrowingSecHubServerTestScenario
  • Loading branch information
de-jcup committed May 16, 2022
commit b57c7495c20fd25a07b15592ceeb1b8ee2d9eae4
11 changes: 6 additions & 5 deletions sechub-integrationtest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ task startIntegrationTestPDS(dependsOn: stopOldIntegrationTestPDS){

}

task startIntegrationTestInstances(dependsOn: [startIntegrationTestServer, startIntegrationTestPDS]){

task cleanIntegrationTestData(type: Delete) {
group 'sechub'
delete "${project.buildDir}/sechub/integrationtest"
}


task startIntegrationTestInstances(dependsOn: [startIntegrationTestServer, startIntegrationTestPDS, cleanIntegrationTestData]){

}

task stopIntegrationTestServer(dependsOn: configureIntegrationTestServer){
doLast{
Expand Down Expand Up @@ -193,8 +196,6 @@ task integrationtest(type: Test, dependsOn: startIntegrationTestInstances) {

}



/**
* Special groovy class for executing external script. This is because exec task of groovy does ALWAYS wait until process has executed.
* Unfortunately this has blocked always when using exec in combination (server runs) - even when using "&" option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,73 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.integrationtest.internal;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class AbstractGrowingSecHubServerTestScenario extends AbstractSecHubServerTestScenario implements GrowingScenario {

private static final Logger LOG = LoggerFactory.getLogger(AbstractGrowingSecHubServerTestScenario.class);

private PersistentScenarioTestDataProvider scenarioTestDataProvider = new PersistentScenarioTestDataProvider(this);
private String generatedPrefixMainId;
private static List<String> generatedPrefixMainIds = new ArrayList<>();

@Override
protected void waitForTestDataAvailable() {
/* we do NOT wait */
/* we do NEVER wait */

}

@Override
public void grow() {
public final void grow() {
scenarioTestDataProvider.increaseGrowId();

/* recalculate test data... */

}

@Override
public String getGrowId() {
public final String getGrowId() {
return scenarioTestDataProvider.getGrowId();
}

@Override
public final String getPrefixMainId() {
if (generatedPrefixMainId == null) {
generatePrefixMainId();
}
return generatedPrefixMainId;
}

private void generatePrefixMainId() {
String className = getClass().getSimpleName();
char firstChar = className.charAt(0);
String numberAsString = className.substring(className.length() - 2);

if (!Character.isDigit(numberAsString.charAt(0))) {
numberAsString = numberAsString.substring(1);
}
try {
String id = ("" + firstChar).toLowerCase();
int number = Integer.decode(numberAsString);
if (number < 10) {
id = id + 0;
}
id = id + number;

/* check uniqueness of id inside JVM */
if (generatedPrefixMainIds.contains(id)) {
throw new IllegalStateException("The generated prefix main id:" + id + " is already generated before:" + generatedPrefixMainIds);
}
/* register */
generatedPrefixMainIds.add(id);
generatedPrefixMainId = id;

} catch (NumberFormatException e) {
throw new IllegalStateException("Test scenarios class names must end with a number! But found class name:" + className);
}

LOG.debug("Prefix main id calculated:", generatedPrefixMainId);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.integrationtest.internal;

/**
* Those scenarios will reuse the same project names and old data will be
* automatically deleted. Every new test inside such a scenario will first check
* if the user, the project etc. exists and if so, drop the old data. This can
* take some time, so using a {@link GrowingScenario} (or a
* {@link StaticTestScenario}) is the better choice in most cases!
*
* @author Albert Tregnaghi
*
*/
public interface CleanScenario extends TestScenario {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,25 @@ public PersistentScenarioTestDataProvider(GrowingScenario scenario) {
}

/**
* Only for PersistentScenarioTestDataProviderTest and internal call from other
* constructor. Do not use directly.
*
* @param file
*/
public PersistentScenarioTestDataProvider(File file) {
PersistentScenarioTestDataProvider(File file) {
if (file == null) {
throw new IllegalStateException("Wrong usage: file may not be null!");
}
this.file = file;
this.file.getParentFile().mkdirs();
ensurePropertyFileExists();

}

private void ensurePropertyFileExists() {
file.getParentFile().mkdirs();

properties = new Properties();
if (this.file.exists()) {
if (file.exists()) {

try (FileInputStream fis = new FileInputStream(file)) {
properties.load(fis);
Expand All @@ -57,7 +68,6 @@ public PersistentScenarioTestDataProvider(File file) {
throw new IllegalStateException("cannot create growid file:" + file.getAbsolutePath(), e);
}
}

}

/**
Expand All @@ -70,7 +80,8 @@ public PersistentScenarioTestDataProvider(File file) {
public void increaseGrowId() {
grow++;
if (grow > 9999) {
throw new IllegalStateException("Grow ID >9999 - not valid");
throw new IllegalStateException(
"Grow ID >9999 - not valid. This should only happen on local development.\nHow to handle this? Please call `gradlew cleanIntegrationTestData` to have a clean counter again and restart tests.");
}
properties.put(SECHUB_INTEGRATIONTEST_DATA_GROWINGID, "" + grow);
store();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,4 @@ protected void waitForTestDataAvailable() {
initializer().waitUntilUserCanLogin(OWNER_1);
}

@Override
public String getPrefixMainId() {
return "s01";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;

/**
Expand All @@ -33,7 +32,7 @@
* @author Albert Tregnaghi
*
*/
public class Scenario10 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario10 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down Expand Up @@ -70,4 +69,5 @@ protected void waitForTestDataAvailable() {
;
/* @formatter:on */
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.IntegrationTestDefaultProfiles;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;
import com.mercedesbenz.sechub.integrationtest.scenario5.Scenario5;
Expand Down Expand Up @@ -38,7 +37,7 @@
* @author Albert Tregnaghi
*
*/
public class Scenario11 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario11 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down Expand Up @@ -75,4 +74,5 @@ protected void waitForTestDataAvailable() {
;
/* @formatter:on */
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;

/**
Expand All @@ -32,7 +31,7 @@
* @author Albert Tregnaghi
*
*/
public class Scenario12 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario12 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down Expand Up @@ -69,4 +68,5 @@ protected void waitForTestDataAvailable() {
;
/* @formatter:on */
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
package com.mercedesbenz.sechub.integrationtest.scenario13;

import static com.mercedesbenz.sechub.integrationtest.internal.IntegrationTestDefaultProfiles.PROFILE_9_PDS_LICENSESCAN_SPDX;
import static com.mercedesbenz.sechub.integrationtest.internal.IntegrationTestDefaultProfiles.*;

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;

/**
Expand All @@ -32,7 +31,7 @@
* </pre>
*
*/
public class Scenario13 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario13 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,4 @@ protected void waitForTestDataAvailable() {
/* @formatter:on */
}

@Override
public String getPrefixMainId() {
return "s02";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,4 @@ protected void waitForTestDataAvailable() {
/* @formatter:on */
}

@Override
public String getPrefixMainId() {
return PREFIX_MAIN_ID;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;

/**
Expand All @@ -33,7 +32,7 @@
* @author Albert Tregnaghi
*
*/
public class Scenario5 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario5 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,4 @@ protected void waitForTestDataAvailable() {
/* @formatter:on */
}

@Override
public String getPrefixMainId() {
return "s07";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
*/
public class Scenario8 extends AbstractGrowingSecHubServerTestScenario {

public static final String PREFIX_MAIN_ID = "s08";

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
*/
Expand Down Expand Up @@ -67,9 +65,4 @@ protected void waitForTestDataAvailable() {
/* @formatter:on */
}

@Override
public String getPrefixMainId() {
return PREFIX_MAIN_ID;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import com.mercedesbenz.sechub.integrationtest.api.TestProject;
import com.mercedesbenz.sechub.integrationtest.api.TestUser;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.CleanScenario;
import com.mercedesbenz.sechub.integrationtest.internal.AbstractGrowingSecHubServerTestScenario;
import com.mercedesbenz.sechub.integrationtest.internal.IntegrationTestDefaultProfiles;
import com.mercedesbenz.sechub.integrationtest.internal.PDSTestScenario;

Expand Down Expand Up @@ -39,7 +38,7 @@
* @author Albert Tregnaghi
*
*/
public class Scenario9 extends AbstractSecHubServerTestScenario implements PDSTestScenario, CleanScenario {
public class Scenario9 extends AbstractGrowingSecHubServerTestScenario implements PDSTestScenario {

/**
* User 1 is registered on startup, also owner and user of {@link #PROJECT_1}
Expand Down
Loading