Skip to content

Commit

Permalink
BEE-43082 [DslDeploy] Microservice process formal parameters are not …
Browse files Browse the repository at this point in the history
…changed after run Import Dsl with overwrite true (#111)
  • Loading branch information
karakurty authored Mar 1, 2024
1 parent b320f9a commit 47618c3
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024-03.01 Valera Fessler <[email protected]>
* 4.3.1: BEE-43082 - Add child process entities support for the microservice container entity

2023-10.05 Valera Fessler <[email protected]>
* 4.3.0: BEE-38889 - Switched perl from old ec-perl (5.8.9) to new one cb-perl (5.32.1)

Expand Down
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<key>EC-DslDeploy</key>
<label>EC-DslDeploy</label>
<ecSupportLevel>10</ecSupportLevel>
<version>4.3.0</version>
<version>4.3.1</version>
<hasAdoc>true</hasAdoc>

<detailedDescription>CloudBees CD allows you to take a fully code-native approach to continuous delivery and release orchestration using the CloudBees CD Groovy-based DSL. The CloudBees CD model based approach means that every object in CloudBees CD, including release pipelines, deployment automation &amp; strategies, environments, configurations, application models, and more, are all backed by code.
Expand Down
2 changes: 1 addition & 1 deletion build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

my $epb="../ecpluginbuilder";

my $pluginVersion = "4.3.0";
my $pluginVersion = "4.3.1";
my $pluginKey = "EC-DslDeploy";

# Fix version in plugin.xml
Expand Down
3 changes: 2 additions & 1 deletion dsl/com/electriccloud/commander/dsl/util/BaseObject.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Author: L.Rochette
#
# Copyright 2017-2022 Electric-Cloud Inc.
# Copyright (c) 2024 CloudBees, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -361,6 +361,7 @@ abstract class BaseObject extends DslDelegatingScript {
dashboard : ['reportingFilter', 'widget'],
environment : ['cluster', 'environmentTier', 'reservation'],
gate : ['task'],
microservice : ['process'],
pipeline : ['stage', 'trigger'],
process : ['processStep'],
procedure : ['step', 'emailNotifier', 'trigger'],
Expand Down
4 changes: 4 additions & 0 deletions help/help.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ NOTE: If the commit ID cannot be found or if the procedure or steps cannot find,
[[releaseNotes]]
== Release notes

=== EC-DslDeploy 4.3.1

* Add child process entities support for the microservice container entity

=== EC-DslDeploy 4.3.0

* Updated Perl from legacy ec-perl (5.8.9) to cb-perl (5.32.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.electriccloud.plugin.spec
import spock.lang.Shared

class MicroserviceSpec
extends PluginTestHelper {
extends PluginTestHelper
{

static String pName='EC-DslDeploy'
@Shared String pVersion
@Shared String plugDir
static String projName="CEV-28776"


def doSetupSpec() {
pVersion = getP("/plugins/$pName/pluginVersion")
plugDir = getP("/server/settings/pluginsDirectory")
Expand Down Expand Up @@ -46,11 +46,122 @@ projectName: '$projName', applicationName: 'app1')"""
assert microservices?.microservice?.size == 1
}

/**
* BEE-43082
*/
def "BEE-43082: add process as children support in microservice" ()
{
def dslDir = '/tmp/' + randomize('dsl')

given: "Load microservice dsl code"
dslFile("BEE-43082.dsl")

when: "check that microservice process contains formal parameter p1"
def p1 = dsl """getFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p1'
)"""
then:
assert p1

when: "check that microservice process contains formal parameter p2"
def p2 = dsl """getFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p2'
)"""
then:
assert p2

when: "Generate DSL files"
def result1 = runProcedureDsl("""
runProcedure(
projectName: "/plugins/$pName/project",
procedureName: "generateDslToDirectory",
actualParameter: [
directory: "$dslDir",
pool: "$defaultPool",
includeAllChildren: '1',
suppressNulls: '1',
suppressEmpty: '1',
objectType: 'project',
objectName: 'BEE-43082',
httpIdleTimeout: '180'
]
)""")
then:
assert result1.jobId
def outcome1 = getJobProperty("outcome", result1.jobId)
assert outcome1 == "success"

when: "Remove formal parameter p1"
dsl """deleteFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p1'
)"""
then: "Add formal parameter p3"
def p3 = dsl """createFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p3'
)"""
assert p3

when: "Load DSL Code in overwrite mode with p1 and p2 formal parameters only"
def p= runProcedureDsl("""
runProcedure(
projectName: "/plugins/$pName/project",
procedureName: "installDslFromDirectory",
actualParameter: [
directory: "$dslDir",
pool: "$defaultPool",
overwrite: '1'
]
)""")
then: "job succeeds"
assert p.jobId
assert getJobProperty("outcome", p.jobId) == "success"

when: "check that microservice process contains formal parameter p1"
def updatedP1 = dsl """getFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p1'
)"""
then:
assert updatedP1

when: "check that microservice process contains formal parameter p2"
def updatedP2 = dsl """getFormalParameter(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process',
formalParameterName: 'p2'
)"""
then:
assert updatedP2

when: "check that microservice process contains just 2 formal parameters"
def formalParams = dsl """getFormalParameters(projectName: 'BEE-43082',
applicationName: 'BEE-43082',
microserviceName: 'BEE-43082',
processName: 'Deploy Microservice Process'
)"""
then:
assert formalParams?.formalParameter?.size() == 2
}

def doCleanupSpec() {
conditionallyDeleteProject(projName)
dsl """
deleteResource(resourceName: "k8s res")
"""
}

}
103 changes: 103 additions & 0 deletions specs/src/test/resources/BEE-43082.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
project 'BEE-43082', {
tracked = '1'

application 'BEE-43082', {
applicationType = 'microservice'

microservice 'BEE-43082', {
definitionSource = 'git'
definitionSourceParameter = [
'branch': 'test',
'config': 'test',
'repoUrl': 'test',
]
definitionType = 'helm'
deployParameter = [
'chart': 'test',
'releaseName': 'test',
]

process 'Deploy Microservice Process', {
description = 'System generated process for microservice deployment'
processType = 'DEPLOY'

formalParameter 'p1', {
type = 'entry'
orderIndex = '1'
}
formalParameter 'p2', {
type = 'entry'
orderIndex = '2'
}

processStep 'Retrieve Artifact', {
description = 'System generated step to retrieve microservice definition artifact'
processStepType = 'plugin'
subprocedure = 'Source Provider'
subproject = '/plugins/EC-Git/project'
}

processStep 'Deploy Microservice', {
description = 'System generated step to deploy microservice'
processStepType = 'plugin'
subprocedure = 'Deploy Service'
subproject = '/plugins/EC-Helm/project'
}

processDependency 'Retrieve Artifact', targetProcessStepName: 'Deploy Microservice'
}
}

process 'Deploy Application', {
description = 'System generated process for microservice application'
processType = 'DEPLOY'

formalParameter 'ec_BEE-43082-run', defaultValue: '1', {
expansionDeferred = '1'
type = 'checkbox'
}

formalParameter 'ec_rolloutApprovers', {
expansionDeferred = '1'
type = 'assigneeList'
}

formalParameter 'ec_rolloutNotificationEnabled', defaultValue: '0', {
expansionDeferred = '1'
type = 'checkbox'
}

processStep 'BEE-43082', {
description = 'System generated step to invoke microservice process'
processStepType = 'process'
submicroservice = 'BEE-43082'
submicroserviceProcess = 'Deploy Microservice Process'
useUtilityResource = '1'

// Custom properties

property 'ec_deploy', {

// Custom properties
ec_notifierStatus = '0'
}
}

// Custom properties

property 'ec_deploy', {

// Custom properties
ec_notifierStatus = '0'
}
}

// Custom properties

property 'ec_deploy', {

// Custom properties
ec_notifierStatus = '0'
}
}
}

0 comments on commit 47618c3

Please sign in to comment.