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
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,13 @@ protected Map<String, Validator> select(Map<String, Validator> validators) throw
return validators;
}

protected List<NamedResult> execute(Collection<Validator> validators) throws Exception {
protected Iterable<RpmPackage> findRpms() throws Exception {
var rpms = new ArrayList<RpmPackage>();
Iterators.addAll(rpms, ArgFileIterator.create(parameters.argPaths));
return rpms;
}

protected List<NamedResult> execute(Collection<Validator> validators) throws Exception {
/*
parameters.argUrls.parallelStream().forEach(path -> {
RpmPackage rpm;
Expand All @@ -541,7 +546,7 @@ protected List<NamedResult> execute(Collection<Validator> validators) throws Exc
}
});
*/
Iterators.addAll(rpms, ArgFileIterator.create(parameters.argPaths));
var rpms = findRpms();
var resultList = new ArrayList<>(validators).parallelStream().map(validator -> {
var oldClassLoader = Thread.currentThread().getContextClassLoader();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -31,11 +32,16 @@
import org.fedoraproject.javapackages.validator.spi.Validator;
import org.yaml.snakeyaml.Yaml;

import io.kojan.javadeptools.rpm.RpmPackage;

public class MainTmt extends Main {
private Path TMT_TEST_DATA = null;
private Path TMT_TREE = null;
private Optional<URI> TESTING_FARM_GIT_URL = Optional.empty();
private Map<String, List<LogEntry>> additionalLogs = new TreeMap<>();

private static final Pattern URL_PACKAGE_NAME_PATTERN = Pattern.compile(".*/rpms/(.*)");

private static String getenv(String key) {
var result = System.getenv(key);
if (result == null) {
Expand All @@ -47,13 +53,19 @@ private static String getenv(String key) {
public static Main create() {
var tmtTestData = Path.of(getenv("TMT_TEST_DATA"));
var tmtTree = Path.of(getenv("TMT_TREE"));
return create(tmtTestData, tmtTree);
var testingFarmGitUrl = Optional.ofNullable(System.getenv("TESTING_FARM_GIT_URL")).map(URI::create);
return create(tmtTestData, tmtTree, testingFarmGitUrl);
}

public static Main create(Path tmtTestData, Path tmtTree) {
return create(tmtTestData, tmtTree, Optional.empty());
}

public static Main create(Path tmtTestData, Path tmtTree, Optional<URI> testingFarmGitUrl) {
var result = new MainTmt();
result.TMT_TEST_DATA = tmtTestData;
result.TMT_TREE = tmtTree;
result.TESTING_FARM_GIT_URL = testingFarmGitUrl;
return result;
}

Expand Down Expand Up @@ -210,6 +222,24 @@ protected Map<String, Validator> select(Map<String, Validator> validators) throw
return validators;
}

@Override
protected Iterable<RpmPackage> findRpms() throws Exception {
logger.debug("TESTING_FARM_GIT_URL: {0}", Decorated.plain(TESTING_FARM_GIT_URL.map(String::valueOf).orElse("")));
var rpms = new ArrayList<RpmPackage>();
var it = ArgFileIterator.create(parameters.argPaths);
while (it.hasNext()) {
var rpm = it.next();
if (TESTING_FARM_GIT_URL.isPresent()) {
var matcher = URL_PACKAGE_NAME_PATTERN.matcher(TESTING_FARM_GIT_URL.get().getPath());
if (matcher.matches() && !matcher.group(1).equals(rpm.getInfo().getSourceName())) {
continue;
}
}
rpms.add(rpm);
}
return rpms;
}

private static String getFormattedDuration(Instant startTime, Instant endTime) {
var duration = Duration.between(startTime, endTime);
// TODO Wait for resolution within TF
Expand Down