diff --git a/it/common/src/main/java/com/walmartlabs/concord/it/common/GitUtils.java b/it/common/src/main/java/com/walmartlabs/concord/it/common/GitUtils.java index 4f57f237eb..c521254388 100644 --- a/it/common/src/main/java/com/walmartlabs/concord/it/common/GitUtils.java +++ b/it/common/src/main/java/com/walmartlabs/concord/it/common/GitUtils.java @@ -22,28 +22,38 @@ import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.transport.RefSpec; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.nio.file.attribute.PosixFilePermissions; public final class GitUtils { public static Path createBareRepository(Path data) throws Exception { - return createBareRepository(data, "initial message"); + return createBareRepository(data, (Path)null); + } + + public static Path createBareRepository(Path data, Path baseTmpDir) throws Exception { + return createBareRepository(data, "initial message", baseTmpDir); } public static Path createBareRepository(Path data, String commitMessage) throws Exception { + return createBareRepository(data, commitMessage, null); + } + + public static Path createBareRepository(Path data, String commitMessage, Path baseTmpDir) throws Exception { // init bare repository - Path tmp = createTempDir(); + Path tmp = createTempDir(baseTmpDir); Path repo = tmp.resolve("test"); Files.createDirectories(repo); Git.init().setBare(true).setDirectory(repo.toFile()).call(); // clone the repository into a new directory - Path workdir = createTempDir(); + Path workdir = createTempDir(baseTmpDir); Git git = Git.cloneRepository() .setDirectory(workdir.toFile()) .setURI("file://" + repo.toString()) @@ -60,8 +70,45 @@ public static Path createBareRepository(Path data, String commitMessage) throws return repo; } - protected static Path createTempDir() throws IOException { - Path tmpDir = Files.createTempDirectory("test"); + public static void createNewBranch(Path bareRepo, String branch, Path src) throws Exception { + createNewBranch(bareRepo, branch, src, null); + } + + public static void createNewBranch(Path bareRepo, String branch, Path src, Path baseTmpDir) throws Exception { + Path dir = createTempDir(baseTmpDir); + + Git git = Git.cloneRepository() + .setDirectory(dir.toFile()) + .setURI(bareRepo.toAbsolutePath().toString()) + .call(); + + git.checkout() + .setCreateBranch(true) + .setName(branch) + .call(); + + IOUtils.copy(src, dir, StandardCopyOption.REPLACE_EXISTING); + + git.add() + .addFilepattern(".") + .call(); + + git.commit() + .setMessage("adding files from " + src.getFileName()) + .call(); + + git.push() + .setRefSpecs(new RefSpec(branch + ":" + branch)) + .call(); + } + + protected static Path createTempDir(Path base) throws IOException { + Path tmpDir ; + if (base != null) { + tmpDir = Files.createTempDirectory(base, "test"); + } else { + tmpDir = Files.createTempDirectory("test"); + } Files.setPosixFilePermissions(tmpDir, PosixFilePermissions.fromString("rwxr-xr-x")); return tmpDir; } diff --git a/it/common/src/main/java/com/walmartlabs/concord/it/common/ITUtils.java b/it/common/src/main/java/com/walmartlabs/concord/it/common/ITUtils.java index c9e0a2458f..1a6bc1c220 100644 --- a/it/common/src/main/java/com/walmartlabs/concord/it/common/ITUtils.java +++ b/it/common/src/main/java/com/walmartlabs/concord/it/common/ITUtils.java @@ -28,12 +28,16 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermissions; +import java.time.format.DateTimeFormatter; +import java.util.Locale; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; @@ -56,6 +60,17 @@ public static byte[] archive(URI uri, String depsDir) throws IOException { return out.toByteArray(); } + public static String resourceToString(Class klass, String resource) throws Exception { + URL url = klass.getResource(resource); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try (InputStream in = url.openStream()) { + IOUtils.copy(in, out); + } + + return new String(out.toByteArray()); + } + public static Path createTempDir() throws IOException { Path dir = IOUtils.createTempDir("test"); Files.setPosixFilePermissions(dir, PosixFilePermissions.fromString("rwxr-xr-x")); diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordConfiguration.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordConfiguration.java index 372b3887d7..bae5630b32 100644 --- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordConfiguration.java +++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordConfiguration.java @@ -23,8 +23,25 @@ import ca.ibodrov.concord.testcontainers.junit4.ConcordRule; import org.testcontainers.images.PullPolicy; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + public final class ConcordConfiguration { + private static final Path sharedDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("concord-it"); + + static { + if (Files.notExists(sharedDir)) { + try { + Files.createDirectories(sharedDir); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + public static ConcordRule configure() { ConcordRule concord = new ConcordRule() .pathToRunnerV1(null) @@ -35,6 +52,7 @@ public static ConcordRule configure() { .pullPolicy(PullPolicy.defaultPolicy()) .streamServerLogs(true) .streamAgentLogs(true) + .sharedContainerDir(sharedDir) .useLocalMavenRepository(true); boolean localMode = Boolean.parseBoolean(System.getProperty("it.local.mode")); diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java new file mode 100644 index 0000000000..7a65a3d411 --- /dev/null +++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java @@ -0,0 +1,234 @@ +package com.walmartlabs.concord.it.runtime.v2; + +/*- + * ***** + * Concord + * ----- + * Copyright (C) 2017 - 2019 Walmart Inc. + * ----- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ===== + */ + +import ca.ibodrov.concord.testcontainers.ProcessListQuery; +import ca.ibodrov.concord.testcontainers.junit4.ConcordRule; +import com.google.common.collect.ImmutableMap; +import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.it.common.GitHubUtils; +import com.walmartlabs.concord.it.common.GitUtils; +import com.walmartlabs.concord.it.common.ITUtils; +import org.junit.ClassRule; +import org.junit.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import static com.walmartlabs.concord.it.common.ITUtils.randomString; +import static com.walmartlabs.concord.it.runtime.v2.ITConstants.DEFAULT_TEST_TIMEOUT; +import static org.junit.Assert.assertEquals; + +public class GitHubTriggersV2IT { + + @ClassRule + public static final ConcordRule concord = ConcordConfiguration.configure(); + + /** + * Test subscription to unknown repositories only: + *
+     * # project A
+     * # a default onPush trigger for the default branch
+     * triggers:
+     *   - github:
+     *       entryPoint: onPush
+     *
+     * # project G
+     * # accepts only specific commit authors
+     * triggers:
+     *   - github:
+     *       author: ".*xyz.*"
+     *       entryPoint: onPush
+     * 
+ */ + @Test(timeout = DEFAULT_TEST_TIMEOUT) + public void testFilterBySender() throws Exception { + String orgXName = "orgX_" + randomString(); + concord.organizations().create(orgXName); + + Path repo = initRepo("triggers/github/repos/v2/defaultTrigger"); + String branch = "branch_" + randomString(); + createNewBranch(repo, branch, "triggers/github/repos/v2/defaultTriggerWithSender"); + + // Project A + // master branch + a default trigger + String projectAName = "projectA_" + randomString(); + String repoAName = "repoA_" + randomString(); + Path projectARepo = initProjectAndRepo(orgXName, projectAName, repoAName, null, initRepo("triggers/github/repos/v2/defaultTrigger")); + refreshRepo(orgXName, projectAName, repoAName); + + // Project G + // accepts only specific commit authors + String projectGName = "projectG_" + randomString(); + String repoGName = "repoG_" + randomString(); + Path projectBRepo = initProjectAndRepo(orgXName, projectGName, repoGName, null, initRepo("triggers/github/repos/v2/defaultTriggerWithSender")); + refreshRepo(orgXName, projectGName, repoGName); + + // --- + + sendEvent("triggers/github/events/direct_branch_push.json", "push", + "_FULL_REPO_NAME", toRepoName(projectARepo), + "_REF", "refs/heads/master", + "_USER_NAME", "aknowndude", + "_USER_LDAP_DN", ""); + + // A's triggers should be activated + ProcessEntry procA = waitForAProcess(orgXName, projectAName, "github"); + expectNoProcesses(orgXName, projectGName, null); + + // --- + + sendEvent("triggers/github/events/direct_branch_push.json", "push", + "_FULL_REPO_NAME", toRepoName(projectBRepo), + "_REF", "refs/heads/master", + "_USER_NAME", "somecooldude", + "_USER_LDAP_DN", ""); + + // G's triggers should be activated + waitForAProcess(orgXName, projectGName, "github"); + + // no A's are expected + expectNoProcesses(orgXName, projectAName, procA); + } + + @Test(timeout = DEFAULT_TEST_TIMEOUT) + public void testOnPushWithFullTriggerParams() throws Exception { + String orgXName = "orgX_" + randomString(); + concord.organizations().create(orgXName); + + // Project A + // master branch + a default trigger + String projectAName = "projectA_" + randomString(); + String repoAName = "repoA_" + randomString(); + initProjectAndRepo(orgXName, projectAName, repoAName, null, initRepo("triggers/github/repos/v2/allParamsTrigger")); + refreshRepo(orgXName, projectAName, repoAName); + + // --- + + sendEvent("triggers/github/events/direct_branch_push.json", "push", + "_FULL_REPO_NAME", "devtools/concord", + "_REF", "refs/heads/master", + "_USER_NAME", "vasia", + "_USER_LDAP_DN", ""); + + // A's trigger should be activated + waitForAProcess(orgXName, projectAName, "github"); + } + + private static Path initRepo(String resource) throws Exception { + Path src = Paths.get(GitHubTriggersV2IT.class.getResource(resource).toURI()); + return GitUtils.createBareRepository(src, concord.sharedContainerDir()); + } + + private static void createNewBranch(Path bareRepo, String branch, String resource) throws Exception { + Path src = Paths.get(GitHubTriggersV2IT.class.getResource(resource).toURI()); + GitUtils.createNewBranch(bareRepo, branch, src); + } + + private static Path initProjectAndRepo(String orgName, String projectName, String repoName, String repoBranch, Path bareRepo) throws Exception { + // TODO: up concord test rule for projects with repository + ProjectsApi projectsApi = new ProjectsApi(apiClient()); + + RepositoryEntry repo = new RepositoryEntry() + .setBranch(repoBranch) + .setUrl(bareRepo.toAbsolutePath().toString()); + + projectsApi.createOrUpdate(orgName, new ProjectEntry() + .setName(projectName) + .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE) + .setRepositories(ImmutableMap.of(repoName, repo))); + + return bareRepo; + } + + private static void refreshRepo(String orgName, String projectName, String repoName) throws Exception { + RepositoriesApi repoApi = new RepositoriesApi(apiClient()); + repoApi.refreshRepository(orgName, projectName, repoName, true); + } + + private static void sendEvent(String resource, String event, String... params) throws Exception { + String payload = resourceToString(resource); + if (params != null) { + for (int i = 0; i < params.length; i += 2) { + String k = params[i]; + String v = params[i + 1]; + payload = payload.replaceAll(k, v); + } + } + + ApiClient client = apiClient(); + client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload)); + + GitHubEventsApi eventsApi = new GitHubEventsApi(client); + eventsApi.onEvent(payload, "abc", event); + } + + private static String resourceToString(String resource) throws Exception { + return ITUtils.resourceToString(GitHubTriggersV2IT.class, resource); + } + + private static String toRepoName(Path p) { + return p.getParent() .getFileName()+ "/" + p.getFileName(); + } + + private static ProcessEntry waitForAProcess(String orgName, String projectName, String initiator) throws Exception { + ProcessListQuery q = ProcessListQuery.builder() + .orgName(orgName) + .projectName(projectName) + .initiator(initiator) + .build(); + + while (!Thread.currentThread().isInterrupted()) { + List l = concord.processes().list(q); + if (l.size() == 1 && isFinished(l.get(0).getStatus())) { + return l.get(0); + } + + Thread.sleep(1000); + } + + throw new RuntimeException("Process wait interrupted"); + } + + private static boolean isFinished(ProcessEntry.StatusEnum status) { + return status == ProcessEntry.StatusEnum.CANCELLED || + status == ProcessEntry.StatusEnum.FAILED || + status == ProcessEntry.StatusEnum.FINISHED || + status == ProcessEntry.StatusEnum.TIMED_OUT; + } + + private static void expectNoProcesses(String orgName, String projectName, ProcessEntry after) throws Exception { + ProcessListQuery q = ProcessListQuery.builder() + .orgName(orgName) + .projectName(projectName) + .afterCreatedAt(after != null ? after.getCreatedAt() : null) + .build(); + + List l = concord.processes().list(q); + assertEquals(0, l.size()); + } + + private static ApiClient apiClient() { + return concord.apiClient(); + } +} diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/direct_branch_push.json b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/direct_branch_push.json similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/direct_branch_push.json rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/direct_branch_push.json diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/pr_close.json b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/pr_close.json similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/pr_close.json rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/pr_close.json diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/pr_open.json b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/pr_open.json similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/events/pr_open.json rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/events/pr_open.json diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/allParamsTrigger/concord.yml b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/allParamsTrigger/concord.yml similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/allParamsTrigger/concord.yml rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/allParamsTrigger/concord.yml diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/defaultTrigger/concord.yml b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/defaultTrigger/concord.yml similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/defaultTrigger/concord.yml rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/defaultTrigger/concord.yml diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/defaultTriggerWithSender/concord.yml b/it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/defaultTriggerWithSender/concord.yml similarity index 100% rename from it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/triggers/github/repos/v2/defaultTriggerWithSender/concord.yml rename to it/runtime-v2/src/test/resources/com/walmartlabs/concord/it/runtime/v2/triggers/github/repos/v2/defaultTriggerWithSender/concord.yml diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java index de11016bd7..b3ebe6352b 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java @@ -27,6 +27,7 @@ import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.GitHubUtils; import com.walmartlabs.concord.it.common.GitUtils; +import com.walmartlabs.concord.it.common.ITUtils; import com.walmartlabs.concord.it.common.ServerClient; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.transport.RefSpec; @@ -71,32 +72,8 @@ protected Path initProjectAndRepo(String orgName, String projectName, String rep } protected void createNewBranch(Path bareRepo, String branch, String resource) throws Exception { - Path dir = IOUtils.createTempDir("git"); - - Git git = Git.cloneRepository() - .setDirectory(dir.toFile()) - .setURI(bareRepo.toAbsolutePath().toString()) - .call(); - - git.checkout() - .setCreateBranch(true) - .setName(branch) - .call(); - Path src = Paths.get(AbstractGitHubTriggersIT.class.getResource(resource).toURI()); - IOUtils.copy(src, dir, StandardCopyOption.REPLACE_EXISTING); - - git.add() - .addFilepattern(".") - .call(); - - git.commit() - .setMessage("adding files from " + resource) - .call(); - - git.push() - .setRefSpecs(new RefSpec(branch + ":" + branch)) - .call(); + GitUtils.createNewBranch(bareRepo, branch, src); } protected void updateConcordYml(Path bareRepo, Map values) throws Exception { @@ -212,14 +189,7 @@ protected void deleteOrg(String orgName) throws Exception { } protected static String resourceToString(String resource) throws Exception { - URL url = AbstractGitHubTriggersIT.class.getResource(resource); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - try (InputStream in = url.openStream()) { - IOUtils.copy(in, out); - } - - return new String(out.toByteArray()); + return ITUtils.resourceToString(AbstractGitHubTriggersIT.class, resource); } protected boolean isFinished(StatusEnum status) { diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubNonOrgEventIt.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java similarity index 93% rename from it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubNonOrgEventIt.java rename to it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java index b18676b9b2..054f2ca961 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubNonOrgEventIt.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java @@ -1,4 +1,4 @@ -package com.walmartlabs.concord.it.server.v2; +package com.walmartlabs.concord.it.server; /*- * ***** @@ -24,8 +24,6 @@ import com.walmartlabs.concord.client.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.GitHubUtils; -import com.walmartlabs.concord.it.server.AbstractServerIT; -import com.walmartlabs.concord.it.server.TriggersRefreshIT; import org.eclipse.jgit.api.Git; import org.junit.Test; @@ -45,7 +43,7 @@ public class GitHubNonOrgEventIt extends AbstractServerIT { public void test() throws Exception { Path tmpDir = createTempDir(); - File src = new File(TriggersRefreshIT.class.getResource("githubNonRepoEvent").toURI()); + File src = new File(GitHubNonOrgEventIt.class.getResource("githubNonRepoEvent").toURI()); IOUtils.copy(src.toPath(), tmpDir); Git repo = Git.init().setDirectory(tmpDir.toFile()).call(); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubTriggersV2IT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubTriggersV2IT.java deleted file mode 100644 index f8944e8e55..0000000000 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/v2/GitHubTriggersV2IT.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.walmartlabs.concord.it.server.v2; - -/*- - * ***** - * Concord - * ----- - * Copyright (C) 2017 - 2019 Walmart Inc. - * ----- - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ===== - */ - -import com.walmartlabs.concord.client.OrganizationEntry; -import com.walmartlabs.concord.client.OrganizationsApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.it.server.AbstractGitHubTriggersIT; -import org.junit.After; -import org.junit.Test; - -import java.nio.file.Path; - -public class GitHubTriggersV2IT extends AbstractGitHubTriggersIT { - - @After - public void tearDown() throws Exception { - waitForProcessesToFinish(); - } - - /** - * Test subscription to unknown repositories only: - *
-     * # project A
-     * # a default onPush trigger for the default branch
-     * triggers:
-     *   - github:
-     *       entryPoint: onPush
-     *
-     * # project G
-     * # accepts only specific commit authors
-     * triggers:
-     *   - github:
-     *       author: ".*xyz.*"
-     *       entryPoint: onPush
-     * 
- */ - @Test(timeout = DEFAULT_TEST_TIMEOUT) - public void testFilterBySender() throws Exception { - OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - - String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); - - Path repo = initRepo("v2/triggers/github/repos/v2/defaultTrigger"); - String branch = "branch_" + randomString(); - createNewBranch(repo, branch, "v2/triggers/github/repos/v2/defaultTriggerWithSender"); - - // Project A - // master branch + a default trigger - String projectAName = "projectA_" + randomString(); - String repoAName = "repoA_" + randomString(); - Path projectARepo = initProjectAndRepo(orgXName, projectAName, repoAName, null, initRepo("githubTests/repos/v2/defaultTrigger")); - refreshRepo(orgXName, projectAName, repoAName); - - // Project G - // accepts only specific commit authors - String projectGName = "projectG_" + randomString(); - String repoGName = "repoG_" + randomString(); - Path projectBRepo = initProjectAndRepo(orgXName, projectGName, repoGName, null, initRepo("githubTests/repos/v2/defaultTriggerWithSender")); - refreshRepo(orgXName, projectGName, repoGName); - - // --- - - sendEvent("v2/triggers/github/events/direct_branch_push.json", "push", - "_FULL_REPO_NAME", toRepoName(projectARepo), - "_REF", "refs/heads/master", - "_USER_NAME", "aknowndude", - "_USER_LDAP_DN", ""); - - // A's triggers should be activated - ProcessEntry procA = waitForAProcess(orgXName, projectAName, "github", null); - expectNoProceses(orgXName, projectGName, null); - - // --- - - sendEvent("v2/triggers/github/events/direct_branch_push.json", "push", - "_FULL_REPO_NAME", toRepoName(projectBRepo), - "_REF", "refs/heads/master", - "_USER_NAME", "somecooldude", - "_USER_LDAP_DN", ""); - - // G's triggers should be activated - waitForAProcess(orgXName, projectGName, "github", null); - - // no A's are expected - expectNoProceses(orgXName, projectAName, procA); - - // --- - - deleteOrg(orgXName); - } - - /** - * Tests the default branch behaviour: - *
-     * # project A
-     * # a default onPush trigger for the default branch
-     * triggers:
-     *   - github:
-     *       entryPoint: onPush
-     * 
- */ - @Test(timeout = DEFAULT_TEST_TIMEOUT) - public void testDefaultBranch() throws Exception { - OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - - String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); - - // Project A - // master branch + a default trigger - String projectAName = "projectA_" + randomString(); - String repoAName = "repoA_" + randomString(); - Path projectARepo = initProjectAndRepo(orgXName, projectAName, repoAName, null, initRepo("v2/triggers/github/repos/v2/defaultTrigger")); - refreshRepo(orgXName, projectAName, repoAName); - - // --- - - sendEvent("v2/triggers/github/events/direct_branch_push.json", "push", - "_FULL_REPO_NAME", toRepoName(projectARepo), - "_REF", "refs/heads/master", - "_USER_LDAP_DN", ""); - - // A's trigger should be activated - waitForAProcess(orgXName, projectAName, "github", null); - - // --- - - deleteOrg(orgXName); - } - - @Test(timeout = DEFAULT_TEST_TIMEOUT) - public void testOnPushWithFullTriggerParams() throws Exception { - OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - - String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); - - // Project A - // master branch + a default trigger - String projectAName = "projectA_" + randomString(); - String repoAName = "repoA_" + randomString(); - initProjectAndRepo(orgXName, projectAName, repoAName, null, initRepo("v2/triggers/github/repos/v2/allParamsTrigger")); - refreshRepo(orgXName, projectAName, repoAName); - - // --- - - sendEvent("v2/triggers/github/events/direct_branch_push.json", "push", - "_FULL_REPO_NAME", "devtools/concord", - "_REF", "refs/heads/master", - "_USER_NAME", "vasia", - "_USER_LDAP_DN", ""); - - // A's trigger should be activated - waitForAProcess(orgXName, projectAName, "github", null); - - // --- - - deleteOrg(orgXName); - } -} diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/_agent.json b/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/_agent.json deleted file mode 100644 index 36e260511c..0000000000 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/_agent.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "_jvmArgs": ["-Xdebug", "-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y"] -} diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/concord.yml b/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/concord.yml deleted file mode 100644 index fa8abcb605..0000000000 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/args/concord.yml +++ /dev/null @@ -1,6 +0,0 @@ -configuration: - runtime: "concord-v2" - -flows: - default: - - log: "Hello, ${name}!" \ No newline at end of file diff --git a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/form/concord.yml b/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/form/concord.yml deleted file mode 100644 index b83fddca25..0000000000 --- a/it/server/src/test/resources/com/walmartlabs/concord/it/server/v2/form/concord.yml +++ /dev/null @@ -1,12 +0,0 @@ -configuration: - runtime: "concord-v2" - -flows: - default: - - form: myForm - fields: - - firstName: { type: "string" } - - lastName: { type: "string" } - - age: { type: "int" } - - - log: "myForm: ${myForm}" \ No newline at end of file diff --git a/targetplatform/pom.xml b/targetplatform/pom.xml index 7bfd5a4a6d..1300975aac 100644 --- a/targetplatform/pom.xml +++ b/targetplatform/pom.xml @@ -99,7 +99,7 @@ 1.6.0 1.5.20 1.0.2 - 0.0.22 + 0.0.25 1.13.0 1.3.5 2.26.1