Skip to content
Permalink
Browse files

Adding pipeline count information to the about page

  • Loading branch information...
jyotisingh committed Oct 27, 2017
1 parent 9f6909e commit 979fa507d3527927919a730bf421e92c2090a972
@@ -527,7 +527,7 @@ public CommentRenderer getCommentRendererFor(String pipelineName) {
}

public List<PipelineConfig> getAllPipelineConfigs() {
return getCurrentConfig().getAllPipelineConfigs();
return cruiseConfig().getAllPipelineConfigs();
}

/* NOTE: this is called from rails environments controller to build a list of pipelines which user can assign in environment.
@@ -190,4 +190,8 @@ private void validatePluggableTasks(PipelineConfig config) {
}
return tasks;
}

public int totalPipelinesCount() {
return goConfigService.getAllPipelineConfigs().size();
}
}
@@ -16,13 +16,14 @@

package com.thoughtworks.go.server.service;

import com.rits.cloning.Cloner;
import com.thoughtworks.go.config.*;
import com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig;
import com.thoughtworks.go.config.pluggabletask.PluggableTask;
import com.thoughtworks.go.domain.PipelineGroups;
import com.thoughtworks.go.config.materials.git.GitMaterialConfig;
import com.thoughtworks.go.config.pluggabletask.PluggableTask;
import com.thoughtworks.go.config.remote.ConfigRepoConfig;
import com.thoughtworks.go.config.remote.RepoConfigOrigin;
import com.thoughtworks.go.domain.PipelineGroups;
import com.thoughtworks.go.helper.JobConfigMother;
import com.thoughtworks.go.helper.PipelineConfigMother;
import com.thoughtworks.go.i18n.LocalizedMessage;
@@ -34,6 +35,7 @@

import java.util.List;
import java.util.Map;
import java.util.UUID;

import static com.thoughtworks.go.helper.EnvironmentConfigMother.environment;
import static com.thoughtworks.go.helper.PipelineConfigMother.createGroup;
@@ -63,6 +65,7 @@ public void setUp() throws Exception {
securityService = mock(SecurityService.class);
pluggableTaskService = mock(PluggableTaskService.class);
when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
when(goConfigService.getMergedConfigForEditing()).thenReturn(cruiseConfig);
pipelineConfigService = new PipelineConfigService(goConfigService, securityService, pluggableTaskService, null);
@@ -180,4 +183,19 @@ public void createPipelineConfigShouldValidateAllPluggableTasks() {
verify(pluggableTaskService).isValid(xUnit);
verify(pluggableTaskService).isValid(docker);
}

@Test
public void shouldGetPipelinesCount() {
assertThat(pipelineConfigService.totalPipelinesCount(), is(this.cruiseConfig.allPipelines().size()));
}

@Test
public void pipelineCountShouldIncludeConfigRepoPipelinesAsWell() {
CruiseConfig mergedCruiseConfig = new Cloner().deepClone(cruiseConfig);
mergedCruiseConfig.addPipeline("default", PipelineConfigMother.pipelineConfig(UUID.randomUUID().toString()));
when(goConfigService.cruiseConfig()).thenReturn(mergedCruiseConfig);
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);

assertThat(pipelineConfigService.totalPipelinesCount(), is(mergedCruiseConfig.allPipelines().size()));
}
}
@@ -1,5 +1,5 @@
##########################################################################
# Copyright 2015 ThoughtWorks, Inc.
# Copyright 2017 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -35,4 +35,8 @@ def available_space
def schema_version
system_service.getSchemaVersion()
end

def total_pipelines_count
pipeline_config_service.totalPipelinesCount()
end
end
@@ -24,6 +24,10 @@
<td>Database schema version:</td>
<td><%= schema_version %></td>
</tr>
<tr>
<td>Pipelines Count:</td>
<td><%= total_pipelines_count %></td>
</tr>
</tbody>
</table>
</div>
@@ -0,0 +1,28 @@
##########################################################################
# Copyright 2017 ThoughtWorks, 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.
##########################################################################

require 'spec_helper'

describe AboutHelper do
include AboutHelper

it "should get the pipelines count" do
should_receive(:pipeline_config_service).and_return(pipeline_config_service = double('pipeline_config_service'))
expect(pipeline_config_service).to receive(:totalPipelinesCount).and_return(10)

expect(total_pipelines_count).to eq(10)
end
end

0 comments on commit 979fa50

Please sign in to comment.
You can’t perform that action at this time.