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

When there is only one open repository but lots of closed ones, WrongNumberOfRepositories exception is thrown #36

Closed
strelok1 opened this issue Mar 16, 2017 · 9 comments
Milestone

Comments

@strelok1
Copy link
Contributor

strelok1 commented Mar 16, 2017

Or am I doing something wrong?

io.codearte.gradle.nexus.logic.RepositoryFetcher#getOpenRepositoryIdForStagingProfileId method is called with ("open", stagingProfileId) and following the call stack it eventually reaches the

io.codearte.gradle.nexus.logic.RepositoryFetcher#verifyThatOneRepositoryAndReturnIt method which takes the response map and the repositoryState parameter. This parameter is never used. I have hundreds of "closed" repositories in a staging profile, but only one "open" one. This method of course throws a WrongNumberOfRepositories exception as it checks the response size only.

Shouldn't it be:

    private Map verifyThatOneRepositoryAndReturnIt(Map responseAsMap, String repositoryState) {
        int numberOfRespositories = responseAsMap.data.count { it.type == repositoryState }
        if (numberOfRespositories != 1) {
            throw new WrongNumberOfRepositories(numberOfRespositories, repositoryState)
        }
        Map repository = responseAsMap.data.find { it.type == repositoryState } as Map
        return repository
    }

People using this plugin, do you ever only have ONE repository in your staging profile and it's always open?

@szpak
Copy link
Member

szpak commented Mar 16, 2017

It sounds sensible to filter repositories by state in that method. Would you like to provide a PR with a fix (and an automatic test for that)?

Btw, are those "hundreds" of closed repositories generated by the plugin or you have some other releasing activity causing that? In the first case #37 would be beneficial.

@strelok1
Copy link
Contributor Author

@szpak it's other deployment activity, not the plugin. I will provide a PR. I am having a hard time getting the tests to pass though. Just running ./gradlew test after cloning the repo causes 14 failed tests. Things like:

io.codearte.gradle.nexus.functional.MockedFunctionalSpec > should call close and promote in closeAndPromoteRepository task FAILED
    org.gradle.api.GradleException at MockedFunctionalSpec.groovy:174
        Caused by: org.gradle.internal.exceptions.LocationAwareException
            Caused by: org.gradle.api.GradleScriptException
                Caused by: org.gradle.api.plugins.UnknownPluginException

Am I doing something wrong?

@szpak
Copy link
Member

szpak commented Mar 16, 2017

There was one small issue with functional tests - #31, but it was fixed. Travis builds current master without any problem.

  1. Could you re-run tests with --info --stacktrace to see if there is anything more meaningful?
  2. What OS do you use?

@strelok1
Copy link
Contributor Author

@szpak Sample stack trace;

Running test from C:\code\gradle-nexus-staging-plugin\build\test\io.codearte.gradle.nexus.functional.MockedFunctionalSpec\should-not-do-request-for-staging-profile-when-provided-in-configuration-on-testedTaskName-task_8

org.gradle.api.GradleException: Build aborted because of an internal error.

	at nebula.test.functional.internal.DefaultExecutionResult.rethrowFailure(DefaultExecutionResult.groovy:97)
	at nebula.test.IntegrationSpec.runTasksSuccessfully(IntegrationSpec.groovy:265)
	at io.codearte.gradle.nexus.functional.MockedFunctionalSpec.should not do request for staging profile when provided in configuration on #testedTaskName task(MockedFunctionalSpec.groovy:36)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Build file 'C:\code\gradle-nexus-staging-plugin\build\test\io.codearte.gradle.nexus.functional.MockedFunctionalSpec\should-not-do-request-for-staging-profile-when-provided-in-configuration-on-testedTaskName-task_8\build.gradle' line: 4
A problem occurred evaluating root project 'should-not-do-request-for-staging-profile-when-provided-in-configuration-on-testedTaskName-task'.
	at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
	at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
	at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:101)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
	at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'should-not-do-request-for-staging-profile-when-provided-in-configuration-on-testedTaskName-task'.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:157)
	at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:162)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
	at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:529)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:90)
	at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
	at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
	at org.gradle.internal.Factories$1.create(Factories.java:22)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
	at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
	... 42 more
**Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'io.codearte.nexus-staging' not found.**
	at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:110)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
	at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
	at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:35)
	at build_cw6cuz34b890se4thjgcstlxv.run(C:\code\gradle-nexus-staging-plugin\build\test\io.codearte.gradle.nexus.functional.MockedFunctionalSpec\should-not-do-request-for-staging-profile-when-provided-in-configuration-on-testedTaskName-task_8\build.gradle:4)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	... 60 more

Root cause is always the same "Plugin with id 'io.codearte.nexus-staging' not found."

Windows 7 SP1 64-bit, Oracle JDK.

@strelok1
Copy link
Contributor Author

strelok1 commented Mar 16, 2017

Doesn't matter, travis worked for me too. I will just use that, rather then running locally. 👍 Cloud CI.

@szpak
Copy link
Member

szpak commented Mar 16, 2017

The problem could be related to nebula-plugins/nebula-test#77. I created a separate branch for you - tech/windowsCompatibility - with new nebula-test (which is not a simple nebula bump as could be expected). You can give it a try.

@strelok1
Copy link
Contributor Author

strelok1 commented Mar 17, 2017 via email

@strelok1
Copy link
Contributor Author

@szpak take a look at #38

It didn't mention this issue by accident :)

@szpak
Copy link
Member

szpak commented Mar 19, 2017

Available in 0.6.0. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants