Search in sources :

Example 21 with Result

use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.

the class VolumeServiceTest method testRemoveVolume.

@Test
public void testRemoveVolume() throws Exception {
    VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
    new Expectations() {

        {
            docker.createVolume((VolumeCreateConfig) any);
            result = "testVolume";
            docker.removeVolume("testVolume");
        }
    };
    VolumeService volumeService = new VolumeService(docker);
    String name = volumeService.createVolume(vc);
    volumeService.removeVolume(name);
}
Also used : Expectations(mockit.Expectations) VolumeConfiguration(io.fabric8.maven.docker.config.VolumeConfiguration) Test(org.junit.Test)

Example 22 with Result

use of io.fabric8.insight.metrics.model.Result in project docker-maven-plugin by fabric8io.

the class VolumeServiceTest method testCreateVolume.

@Test
public void testCreateVolume() throws Exception {
    VolumeConfiguration vc = new VolumeConfiguration.Builder().name("testVolume").driver("test").opts(withMap("opts")).labels(withMap("labels")).build();
    new Expectations() {

        {
            docker.createVolume((VolumeCreateConfig) any);
            result = "testVolume";
        }
    };
    assertThat(vc.getName(), is("testVolume"));
    String name = new VolumeService(docker).createVolume(vc);
    assertThat(name, is("testVolume"));
}
Also used : Expectations(mockit.Expectations) VolumeConfiguration(io.fabric8.maven.docker.config.VolumeConfiguration) Test(org.junit.Test)

Example 23 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class DeploymentUpdater method updateDeployment.

public void updateDeployment(Git git, File baseDir, CredentialsProvider credentials) throws Exception {
    Set<String> bundles = new LinkedHashSet<String>();
    Set<Feature> features = new LinkedHashSet<Feature>();
    Profile overlayProfile = container.getOverlayProfile();
    Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
    bundles.addAll(effectiveProfile.getBundles());
    AgentUtils.addFeatures(features, fabricService, downloadManager, effectiveProfile);
    if (copyFilesIntoGit) {
        copyDeploymentsIntoGit(git, baseDir, bundles, features);
    } else {
        addDeploymentsIntoPom(git, baseDir, effectiveProfile, bundles, features);
    }
    // now lets do a commit
    String message = "updating deployment";
    git.commit().setMessage(message).call();
    enableDeployDirectory(git, baseDir);
    String branch = GitHelpers.currentBranch(git);
    LOG.info("Pushing deployment changes to branch " + branch + " credentials " + credentials + " for container " + container.getId());
    try {
        Iterable<PushResult> results = git.push().setCredentialsProvider(credentials).setRefSpecs(new RefSpec(branch)).setOutputStream(new LoggingOutputStream(LOG)).call();
        /*
            for (PushResult result : results) {
                LOG.info(result.getMessages());
            }
*/
        LOG.info("Pushed deployment changes to branch " + branch + " for container " + container.getId());
    } catch (GitAPIException e) {
        LOG.error("Failed to push deployment changes to branch " + branch + " for container " + container.getId() + ". Reason: " + e, e);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RefSpec(org.eclipse.jgit.transport.RefSpec) LoggingOutputStream(io.fabric8.common.util.LoggingOutputStream) PushResult(org.eclipse.jgit.transport.PushResult) Feature(io.fabric8.agent.model.Feature) Profile(io.fabric8.api.Profile)

Example 24 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class ApmAgentContext method buildDeltaList.

public List<ClassInfo> buildDeltaList() {
    List<ClassInfo> result = new ArrayList<>();
    for (ClassInfo classInfo : allMethods.values()) {
        if (classInfo.isTransformed()) {
            // check to see its still should be audited
            if (configuration.isAudit(classInfo.getClassName())) {
                boolean retransform = false;
                // check to see if there's a change to methods that should be transformed
                Set<String> transformedMethodNames = classInfo.getAllTransformedMethodNames();
                for (String methodName : transformedMethodNames) {
                    if (!configuration.isAudit(classInfo.getClassName(), methodName)) {
                        retransform = true;
                        break;
                    }
                }
                if (!retransform) {
                    // check to see if there are methods that should now be audited but weren't
                    Set<String> allMethodNames = classInfo.getAllMethodNames();
                    for (String methodName : allMethodNames) {
                        if (!transformedMethodNames.contains(methodName) && configuration.isAudit(classInfo.getClassName(), methodName)) {
                            retransform = true;
                            break;
                        }
                    }
                }
                if (retransform) {
                    result.add(classInfo);
                }
            } else {
                // we were once audited - but now need to be removed
                result.add(classInfo);
            }
        } else if (configuration.isAudit(classInfo.getClassName())) {
            if (classInfo.isCanTransform()) {
                result.add(classInfo);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ClassInfo(io.fabric8.apmagent.ClassInfo)

Example 25 with Result

use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.

the class MavenUploadProxyServlet method handleDeploy.

private void handleDeploy(HttpServletRequest req, UploadContext result) throws Exception {
    String profile = req.getParameter("profile");
    String version = req.getParameter("version");
    if (profile != null && version != null) {
        ProjectRequirements requirements = toProjectRequirements(result);
        requirements.setProfileId(profile);
        requirements.setVersion(version);
        DeployResults deployResults = addToProfile(requirements);
        LOGGER.info(String.format("Deployed artifact %s to profile: %s", result.toArtifact(), deployResults));
    }
}
Also used : DeployResults(io.fabric8.deployer.dto.DeployResults) ProjectRequirements(io.fabric8.deployer.dto.ProjectRequirements)

Aggregations

Test (org.junit.Test)104 Expectations (mockit.Expectations)49 HashMap (java.util.HashMap)32 Map (java.util.Map)24 ArrayList (java.util.ArrayList)23 File (java.io.File)21 GitContext (io.fabric8.api.GitContext)20 IOException (java.io.IOException)20 Exchange (org.apache.camel.Exchange)20 Processor (org.apache.camel.Processor)20 DefaultPullPushPolicy (io.fabric8.git.internal.DefaultPullPushPolicy)18 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)17 Probe (io.fabric8.kubernetes.api.model.Probe)16 PatchResult (io.fabric8.patch.management.PatchResult)13 Properties (java.util.Properties)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)11 Patch (io.fabric8.patch.management.Patch)11 PatchException (io.fabric8.patch.management.PatchException)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 TreeMap (java.util.TreeMap)10