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

Fix/clabverter bad apiversion, possible empty image, clabverter basic e2e #86

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clabverter/assets/topology.yaml.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: topologies.containerlab.dev/v1alpha1
apiVersion: clabernetes.containerlab.dev/v1alpha1
kind: Topology
metadata:
name: {{ .Name }}
Expand Down
2 changes: 1 addition & 1 deletion clabverter/test-fixtures/golden/srl02.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: topologies.containerlab.dev/v1alpha1
apiVersion: clabernetes.containerlab.dev/v1alpha1
kind: Topology
metadata:
creationTimestamp: null
Expand Down
8 changes: 7 additions & 1 deletion config/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ func bootstrapFromConfigMap( //nolint:gocyclo,funlen
}

launcherImage, launcherImageOk := inMap["launcherImage"]
if launcherImageOk {
if launcherImageOk && launcherImage != "" {
// check for empty string too -- the config map by default (w/ default values) will always
// have just "" for launcher image, config bootstrapping will use the value set in the
// LAUNCHER_IMAGE env which will be the same kind of resolution we have for manager image
// where user provided value takes precedent, then if unset and "0.0.0" chart version it
// results in dev-latest image tag, finally, resulting in just the image w/ the tag the same
// as the chart version.
bc.launcherImage = launcherImage
}

Expand Down
2 changes: 1 addition & 1 deletion config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (m *manager) Start() error {

found = false
} else {
m.logger.Criticalf("encountered error fetching global config, err: ", err)
m.logger.Criticalf("encountered error fetching global config, err: %s", err)

return err
}
Expand Down
4 changes: 0 additions & 4 deletions constants/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ const (
// (launcher) pods.
LauncherImageEnv = "LAUNCHER_IMAGE"

// LauncherPullPolicyEnv env var that tells the controllers what pull policy to use for
// clabernetes (launcher) pods.
LauncherPullPolicyEnv = "LAUNCHER_PULL_POLICY"

// LauncherPrivilegedEnv is an envar that indicates if the launcher is launched with
// privileged mode or our "not so privileged mode".
LauncherPrivilegedEnv = "LAUNCHER_PRIVILEGED"
Expand Down
80 changes: 80 additions & 0 deletions e2e/clabverter/clabverter_basic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package clabverter_test

import (
"fmt"
"os"
"testing"

clabernetesclabverter "github.com/srl-labs/clabernetes/clabverter"
clabernetestesthelper "github.com/srl-labs/clabernetes/testhelper"
clabernetestesthelpersuite "github.com/srl-labs/clabernetes/testhelper/suite"
)

func TestMain(m *testing.M) {
clabernetestesthelper.Flags()

os.Exit(m.Run())
}

func TestClabverterBasic(t *testing.T) {
t.Parallel()

testName := "clabverter-basic"

namespace := clabernetestesthelper.NewTestNamespace(testName)

c := clabernetesclabverter.MustNewClabverter(
"test-fixtures/basic_clab.yaml",
"test-fixtures",
namespace,
"",
false,
false,
false,
)

err := c.Clabvert()
if err != nil {
t.Fatalf("failed running clabversion, err: %s", err)
}

// rename the generated topo so we can use the e2e runner thingy
err = os.Rename("test-fixtures/clabverter-basic.yaml", "test-fixtures/10-apply.yaml")
if err != nil {
t.Fatalf("failed renaming clabverted topology, err: %s", err)
}

defer func() {
err = os.Remove("test-fixtures/10-apply.yaml")
if err != nil {
t.Errorf("failed cleaning up clabverted topology file, err: %s", err)
}
}()

steps := clabernetestesthelpersuite.Steps{
{
Index: 10,
Description: "Create a simple containerlab topology from clabverted output",
AssertObjects: map[string][]clabernetestesthelpersuite.AssertObject{
"topology": {
{
Name: testName,
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
clabernetestesthelper.NormalizeTopology,
},
},
},
"service": {
{
Name: fmt.Sprintf("%s-srl1", testName),
NormalizeFuncs: []func(t *testing.T, objectData []byte) []byte{
clabernetestesthelper.NormalizeExposeService,
},
},
},
},
},
}

clabernetestesthelpersuite.Run(t, steps, namespace)
}
14 changes: 14 additions & 0 deletions e2e/clabverter/test-fixtures/basic_clab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: clabverter-basic

topology:
nodes:
srl1:
kind: srl
image: ghcr.io/nokia/srlinux
srl2:
kind: srl
image: ghcr.io/nokia/srlinux

links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: v1
kind: Service
metadata:
labels:
clabernetes/app: clabernetes
clabernetes/name: clabverter-basic-srl1
clabernetes/topologyKind: containerlab
clabernetes/topologyNode: srl1
clabernetes/topologyOwner: clabverter-basic
clabernetes/topologyServiceType: expose
name: clabverter-basic-srl1
namespace: NAMESPACE
ownerReferences:
- apiVersion: clabernetes.containerlab.dev/v1alpha1
kind: Topology
name: clabverter-basic
spec:
allocateLoadBalancerNodePorts: true
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: port-161-udp
port: 161
protocol: UDP
targetPort: 60000
- name: port-21-tcp
port: 21
protocol: TCP
targetPort: 60000
- name: port-22-tcp
port: 22
protocol: TCP
targetPort: 60001
- name: port-23-tcp
port: 23
protocol: TCP
targetPort: 60002
- name: port-80-tcp
port: 80
protocol: TCP
targetPort: 60003
- name: port-443-tcp
port: 443
protocol: TCP
targetPort: 60004
- name: port-830-tcp
port: 830
protocol: TCP
targetPort: 60005
- name: port-5000-tcp
port: 5000
protocol: TCP
targetPort: 60006
- name: port-5900-tcp
port: 5900
protocol: TCP
targetPort: 60007
- name: port-6030-tcp
port: 6030
protocol: TCP
targetPort: 60008
- name: port-9339-tcp
port: 9339
protocol: TCP
targetPort: 60009
- name: port-9340-tcp
port: 9340
protocol: TCP
targetPort: 60010
- name: port-9559-tcp
port: 9559
protocol: TCP
targetPort: 60011
- name: port-57400-tcp
port: 57400
protocol: TCP
targetPort: 60012
selector:
clabernetes/app: clabernetes
clabernetes/name: clabverter-basic-srl1
clabernetes/topologyNode: srl1
clabernetes/topologyOwner: clabverter-basic
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
134 changes: 134 additions & 0 deletions e2e/clabverter/test-fixtures/golden/10-topology.clabverter-basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
apiVersion: clabernetes.containerlab.dev/v1alpha1
kind: Topology
metadata:
annotations: {}
name: clabverter-basic
namespace: NAMESPACE
spec:
definition:
containerlab: |-
---
name: clabverter-basic

topology:
nodes:
srl1:
kind: srl
image: ghcr.io/nokia/srlinux
srl2:
kind: srl
image: ghcr.io/nokia/srlinux

links:
- endpoints: ["srl1:e1-1", "srl2:e1-1"]
deployment:
persistence:
enabled: false
expose:
disableAutoExpose: false
disableExpose: false
disableNodeAliasService: false
imagePull: {}
status:
configs:
srl1: |
name: clabernetes-srl1
prefix: ""
topology:
defaults:
ports:
- 60000:21/tcp
- 60001:22/tcp
- 60002:23/tcp
- 60003:80/tcp
- 60000:161/udp
- 60004:443/tcp
- 60005:830/tcp
- 60006:5000/tcp
- 60007:5900/tcp
- 60008:6030/tcp
- 60009:9339/tcp
- 60010:9340/tcp
- 60011:9559/tcp
- 60012:57400/tcp
nodes:
srl1:
kind: srl
image: ghcr.io/nokia/srlinux
ports: []
links:
- endpoints:
- srl1:e1-1
- host:srl1-e1-1
debug: false
srl2: |
name: clabernetes-srl2
prefix: ""
topology:
defaults:
ports:
- 60000:21/tcp
- 60001:22/tcp
- 60002:23/tcp
- 60003:80/tcp
- 60000:161/udp
- 60004:443/tcp
- 60005:830/tcp
- 60006:5000/tcp
- 60007:5900/tcp
- 60008:6030/tcp
- 60009:9339/tcp
- 60010:9340/tcp
- 60011:9559/tcp
- 60012:57400/tcp
nodes:
srl2:
kind: srl
image: ghcr.io/nokia/srlinux
ports: []
links:
- endpoints:
- srl2:e1-1
- host:srl2-e1-1
debug: false
exposedPorts:
srl1:
tcpPorts:
- 21
- 22
- 23
- 80
- 443
- 830
- 5000
- 5900
- 6030
- 9339
- 9340
- 9559
- 57400
udpPorts:
- 161
srl2:
tcpPorts:
- 21
- 22
- 23
- 80
- 443
- 830
- 5000
- 5900
- 6030
- 9339
- 9340
- 9559
- 57400
udpPorts:
- 161
kind: containerlab
reconcileHashes:
config: 25ea403243c3741d3013049756aa02db0ad8dc3d0d9bf803dc1576f9dda33649
filesFromURL: {}
imagePullSecrets: 37517e5f3dc66819f61f5a7bb8ace1921282415f10551d2defa5c3eb0985b570
tunnels: 25ea403243c3741d3013049756aa02db0ad8dc3d0d9bf803dc1576f9dda33649
Loading