Skip to content

Commit

Permalink
feat: Add name attribute to ServicePort (argoproj#2572)
Browse files Browse the repository at this point in the history
* Add name attribute to ServicePort

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Format with gofmt

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Update experiment test by adding port name

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Include port name only when given

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Implement separate e2e tests for single unnamed port and two named ports

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Remove port name in experiment_test.go

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Replace Sleep in new multiport service experiment

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

---------

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
Signed-off-by: kaldorn <nate.kaldor@outreach.io>
  • Loading branch information
daniddelrio authored and kaldorn committed Feb 9, 2023
1 parent 24c9621 commit cb2caaa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions experiments/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ func (ec *experimentContext) createTemplateService(template *v1alpha1.TemplateSp
Port: port.ContainerPort,
TargetPort: intstr.FromInt(int(port.ContainerPort)),
}
if port.Name != "" {
servicePort.Name = port.Name
}
ports = append(ports, servicePort)
}
}
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,27 @@ func (s *ExperimentSuite) TestExperimentWithServiceAndScaleDownDelay() {
ExpectExperimentServiceCount("experiment-with-service", 0)
}

func (s *ExperimentSuite) TestExperimentWithMultiportServiceAndScaleDownDelay() {
g := s.Given()
g.ApplyManifests("@functional/experiment-with-multiport-service.yaml")
g.When().
WaitForExperimentPhase("experiment-with-multiport-service", "Running").
WaitForExperimentCondition("experiment-with-multiport-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 1
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).
Then().
ExpectExperimentTemplateReplicaSetNumReplicas("experiment-with-multiport-service", "test", 1).
ExpectExperimentServiceCount("experiment-with-multiport-service", 1).
When().
WaitForExperimentPhase("experiment-with-multiport-service", "Successful").
WaitForExperimentCondition("experiment-with-multiport-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 0
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).
Then().
ExpectExperimentTemplateReplicaSetNumReplicas("experiment-with-multiport-service", "test", 0).
ExpectExperimentServiceCount("experiment-with-multiport-service", 0)
}

func (s *ExperimentSuite) TestExperimentWithDryRunMetrics() {
g := s.Given()
g.ApplyManifests("@functional/experiment-dry-run-analysis.yaml")
Expand Down
37 changes: 37 additions & 0 deletions test/e2e/functional/experiment-with-multiport-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: argoproj.io/v1alpha1
kind: Experiment
metadata:
name: experiment-with-multiport-service
spec:
duration: 10s
scaleDownDelaySeconds: 5
# List of pod template specs to run in the experiment as ReplicaSets
templates:
- name: test
replicas: 1
service: {}
selector:
matchLabels:
app: experiment-with-multiport-service
template:
metadata:
labels:
app: experiment-with-multiport-service
spec:
containers:
- name: experiment-with-multiport-service
image: nginx:1.19-alpine
resources:
requests:
memory: 16Mi
cpu: 1m
ports:
- name: testport1
protocol: TCP
containerPort: 8080
- name: testport2
protocol: TCP
containerPort: 8081
- name: testport3
protocol: TCP
containerPort: 8082

0 comments on commit cb2caaa

Please sign in to comment.