Skip to content

Commit a52775a

Browse files
authored
Merge pull request #76 from RobotSail/RobotSail/issue40
End-to-end testing
2 parents 0d8ef54 + e2f3b5b commit a52775a

28 files changed

+492
-129
lines changed

.github/workflows/validate-ipfs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ jobs:
122122
ipfs-cluster ./helm/ipfs-operator
123123
124124
- name: run e2e tests
125+
shell: bash
125126
run: |
126127
mkdir bin
127128
make test-e2e

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ profile.json
2929
*~
3030

3131
# kubeconfig generated during test-e2e
32-
test-e2e/kubeconfig
32+
test-kuttl/kubeconfig
3333

3434
# don't include vendor/
3535
vendor/*

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# set binary versions
12
GOLANGCI_VERSION := v1.46.1
23
HELM_VERSION := v3.8.2
34
KUTTL_VERSION := 0.10.0
@@ -136,7 +137,7 @@ test: lint manifests generate fmt vet lint envtest ginkgo ## Run tests.
136137

137138
.PHONY: test-e2e
138139
test-e2e: kuttl ## Run e2e tests. Requires cluster w/ Scribe already installed
139-
cd test-kuttl && $(KUTTL) test --namespace test
140+
cd test-kuttl && $(KUTTL) test
140141
rm -f test-kuttl/kubeconfig
141142

142143
##@ Build

api/v1alpha1/groupversion_info.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ import (
2424
"sigs.k8s.io/controller-runtime/pkg/scheme"
2525
)
2626

27+
// Define the version information about this operator.
28+
const (
29+
Group = "cluster.ipfs.io"
30+
Version = "v1alpha1"
31+
)
32+
2733
var (
2834
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "cluster.ipfs.io", Version: "v1alpha1"}
35+
GroupVersion = schema.GroupVersion{Group: Group, Version: Version}
3036

3137
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3238
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

api/v1alpha1/ipfscluster_types.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
"k8s.io/apimachinery/pkg/api/resource"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223
)
@@ -59,20 +60,34 @@ type followParams struct {
5960
Template string `json:"template"`
6061
}
6162

63+
// networkConfig defines the configuration structure used for networking.
6264
type networkConfig struct {
6365
CircuitRelays int32 `json:"circuitRelays"`
6466
}
6567

68+
// IpfsClusterSpec defines the desired state of the IpfsCluster.
6669
type IpfsClusterSpec struct {
70+
// url defines the URL to be using as an ingress controller.
6771
// +kubebuilder:validation:Optional
68-
URL string `json:"url"`
69-
Public bool `json:"public"`
70-
IpfsStorage resource.Quantity `json:"ipfsStorage"`
71-
ClusterStorage string `json:"clusterStorage"`
72-
Replicas int32 `json:"replicas"`
73-
Networking networkConfig `json:"networking"`
74-
Follows []followParams `json:"follows"`
75-
// Reprovider Describes the settings that each IPFS node
72+
URL string `json:"url"`
73+
// public determines whether or not we should be exposing this IPFS Cluster to the public.
74+
Public bool `json:"public"`
75+
// ipfsStorage defines the total storage to be allocated by this resource.
76+
IpfsStorage resource.Quantity `json:"ipfsStorage"`
77+
// clusterStorage defines the amount of storage to be used by IPFS Cluster.
78+
ClusterStorage resource.Quantity `json:"clusterStorage"`
79+
// replicas sets the number of replicas of IPFS Cluster nodes we should be running.
80+
Replicas int32 `json:"replicas"`
81+
// networking defines network configuration settings.
82+
Networking networkConfig `json:"networking"`
83+
// follows defines the list of other IPFS Clusters this one should follow.
84+
Follows []followParams `json:"follows"`
85+
// ipfsResources specifies the resource requirements for each IPFS container. If this
86+
// value is omitted, then the operator will automatically determine these settings
87+
// based on the storage sizes used.
88+
// +optional
89+
IPFSResources *corev1.ResourceRequirements `json:"ipfsResources,omitempty"`
90+
// reprovider Describes the settings that each IPFS node
7691
// should use when reproviding content.
7792
// +optional
7893
Reprovider ReprovideSettings `json:"reprovider,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.ipfs.io_ipfsclusters.yaml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ spec:
3333
metadata:
3434
type: object
3535
spec:
36+
description: IpfsClusterSpec defines the desired state of the IpfsCluster.
3637
properties:
3738
clusterStorage:
38-
type: string
39+
anyOf:
40+
- type: integer
41+
- type: string
42+
description: clusterStorage defines the amount of storage to be used
43+
by IPFS Cluster.
44+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
45+
x-kubernetes-int-or-string: true
3946
follows:
47+
description: follows defines the list of other IPFS Clusters this
48+
one should follow.
4049
items:
4150
properties:
4251
name:
@@ -48,13 +57,45 @@ spec:
4857
- template
4958
type: object
5059
type: array
60+
ipfsResources:
61+
description: ipfsResources specifies the resource requirements for
62+
each IPFS container. If this value is omitted, then the operator
63+
will automatically determine these settings based on the storage
64+
sizes used.
65+
properties:
66+
limits:
67+
additionalProperties:
68+
anyOf:
69+
- type: integer
70+
- type: string
71+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
72+
x-kubernetes-int-or-string: true
73+
description: 'Limits describes the maximum amount of compute resources
74+
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
75+
type: object
76+
requests:
77+
additionalProperties:
78+
anyOf:
79+
- type: integer
80+
- type: string
81+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
82+
x-kubernetes-int-or-string: true
83+
description: 'Requests describes the minimum amount of compute
84+
resources required. If Requests is omitted for a container,
85+
it defaults to Limits if that is explicitly specified, otherwise
86+
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
87+
type: object
88+
type: object
5189
ipfsStorage:
5290
anyOf:
5391
- type: integer
5492
- type: string
93+
description: ipfsStorage defines the total storage to be allocated
94+
by this resource.
5595
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
5696
x-kubernetes-int-or-string: true
5797
networking:
98+
description: networking defines network configuration settings.
5899
properties:
59100
circuitRelays:
60101
format: int32
@@ -63,12 +104,16 @@ spec:
63104
- circuitRelays
64105
type: object
65106
public:
107+
description: public determines whether or not we should be exposing
108+
this IPFS Cluster to the public.
66109
type: boolean
67110
replicas:
111+
description: replicas sets the number of replicas of IPFS Cluster
112+
nodes we should be running.
68113
format: int32
69114
type: integer
70115
reprovider:
71-
description: Reprovider Describes the settings that each IPFS node
116+
description: reprovider Describes the settings that each IPFS node
72117
should use when reproviding content.
73118
properties:
74119
interval:
@@ -85,6 +130,7 @@ spec:
85130
type: string
86131
type: object
87132
url:
133+
description: url defines the URL to be using as an ingress controller.
88134
type: string
89135
required:
90136
- clusterStorage

controllers/circuitrelay_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *CircuitRelayReconciler) Reconcile(ctx context.Context, req ctrl.Request
9191
if len(rsvc.Status.LoadBalancer.Ingress) == 0 {
9292
log.Info("still waiting for service ingress addresses", "name", instance.Name)
9393
return ctrl.Result{
94-
RequeueAfter: time.Minute,
94+
RequeueAfter: time.Second * 15,
9595
}, err
9696
}
9797

@@ -111,7 +111,7 @@ func (r *CircuitRelayReconciler) Reconcile(ctx context.Context, req ctrl.Request
111111
if err != nil {
112112
log.Error(err, "error generating new identity")
113113
return ctrl.Result{
114-
RequeueAfter: time.Minute,
114+
RequeueAfter: time.Second * 15,
115115
}, err
116116
}
117117
sec := corev1.Secret{}

controllers/configmap.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

controllers/ipfscluster_controller.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (r *IpfsClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
113113
}
114114
if relay.Status.AddrInfo.ID == "" {
115115
log.Info("relay is not ready yet. Will continue waiting.", "relay", relayName)
116-
return ctrl.Result{RequeueAfter: time.Minute}, nil
116+
return ctrl.Result{RequeueAfter: time.Second * 15}, nil
117117
}
118118
}
119119
if err = r.Status().Update(ctx, instance); err != nil {
@@ -137,23 +137,27 @@ func (r *IpfsClusterReconciler) createTrackedObjects(
137137
sa := corev1.ServiceAccount{}
138138
svc := corev1.Service{}
139139
cmScripts := corev1.ConfigMap{}
140-
cmConfig := corev1.ConfigMap{}
141140
secConfig := corev1.Secret{}
142141
sts := appsv1.StatefulSet{}
143142

144143
mutsa := r.serviceAccount(instance, &sa)
145144
mutsvc, svcName := r.serviceCluster(instance, &svc)
146145

147146
mutCmScripts, cmScriptName := r.ConfigMapScripts(ctx, instance, &cmScripts)
148-
mutSecConfig, secConfigName := r.SecretConfig(ctx, instance, &secConfig, []byte(clusterSecret), []byte(privateString))
149-
mutCmConfig, cmConfigName := r.configMapConfig(instance, &cmConfig, peerID.String())
150-
mutSts := r.statefulSet(instance, &sts, svcName, secConfigName, cmConfigName, cmScriptName)
147+
mutSecConfig, secConfigName := r.SecretConfig(
148+
ctx,
149+
instance,
150+
&secConfig,
151+
[]byte(clusterSecret),
152+
[]byte(privateString),
153+
peerID.String(),
154+
)
155+
mutSts := r.StatefulSet(instance, &sts, svcName, secConfigName, cmScriptName)
151156

152157
trackedObjects := map[client.Object]controllerutil.MutateFn{
153158
&sa: mutsa,
154159
&svc: mutsvc,
155160
&cmScripts: mutCmScripts,
156-
&cmConfig: mutCmConfig,
157161
&secConfig: mutSecConfig,
158162
&sts: mutSts,
159163
}

0 commit comments

Comments
 (0)