Skip to content

Commit 9ea88f5

Browse files
committed
implement tests for IPFS Cluster follow
Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
1 parent e2f3c13 commit 9ea88f5

File tree

6 files changed

+43
-33
lines changed

6 files changed

+43
-33
lines changed

test-kuttl/e2e/cluster-follow/10-validate-contents.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ count_pins() {
2323

2424
# ensure that the corresponding IPFS container has pinned content
2525
pins=$(kubectl exec "${podName}" -n "${NAMESPACE}" -c "${followContainerName}" -- ipfs pin ls | grep -i "${pinTypeRecursive}")
26-
IFS=$'\n'
27-
for pin in "${pins}"; do
28-
numPins=$((numPins + 1))
29-
done
30-
echo "${numPins}"
26+
readarray -d $'\n' -t pinArray <<< "${pins}"
27+
echo "${#pinArray[*]}"
3128
}
3229

3330
main() {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IPFS Cluster Follow Test
2+
3+
This test verifies that the IPFS Cluster is capable of joining
4+
a collaborative cluster and replicating data.
5+
6+
### Test Steps:
7+
8+
- 00. Create an IPFSCluster resource
9+
- 05. Assert the CR is available
10+
- 10. Validate that the IPFS container is pinning the gutenurg_es CIDs

test-kuttl/e2e/cluster-follow/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
########################################
88
log() {
99
input="${*}"
10-
printf "[%s]: %s" $(date) "${input}\n"
10+
echo '['$(date)"]: ${input}\n"
1111
}
Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
#!/bin/bash
2-
current_shell() {
3-
currentShell=$(readlink /proc/"${$}"/exe)
4-
printf "using shell: %s\n" "${currentShell}"
5-
version=$("${currentShell}" --version)
6-
printf "shell version: %s\n" "${version}"
7-
}
8-
current_shell
9-
10-
# show all available shells
11-
cat /etc/shells
122
set -eo pipefail
133

144
# imports
155
source './utils.sh'
166

17-
# get the name of an IPFS Cluster pod
18-
crdName='ipfs-sample-1'
19-
labelValue="ipfs-cluster-${crdName}"
20-
labelName='app.kubernetes.io/name'
21-
ipfsClusterPodName=$(kubectl get pod -n "${NAMESPACE}" -l "${labelName}=${labelValue}" -o jsonpath='{.items[0].metadata.name}')
22-
23-
# write a file to the ipfs-cluster container in the pod
24-
log "writing a file to ${ipfsClusterPodName}"
25-
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'echo "hello from ${HOSTNAME} at $(date)" > /tmp/testfile.txt'
26-
myCID=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'ipfs-cluster-ctl add /tmp/testfile.txt' | awk '{print $2}')
27-
28-
# read the value
29-
ipfsClusterPodname2=$(kubectl get pod -n "${NAMESPACE}" -l "${labelName}=${labelValue}" -o jsonpath='{.items[1].metadata.name}')
30-
log "reading a file from ${ipfsClusterPodname2}"
31-
ipfsCommand="ipfs get --output /tmp/myfile.txt -- ${myCID}"
32-
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs -- sh -c "${ipfsCommand}"
7+
main() {
8+
# get the name of an IPFS Cluster pod
9+
crdName='ipfs-sample-1'
10+
labelValue="ipfs-cluster-${crdName}"
11+
labelName='app.kubernetes.io/name'
12+
ipfsClusterPodName=$(kubectl get pod -n "${NAMESPACE}" -l "${labelName}=${labelValue}" -o jsonpath='{.items[0].metadata.name}')
13+
14+
# write a file to the ipfs-cluster container in the pod
15+
log "writing a file to ${ipfsClusterPodName}"
16+
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'echo "hello from ${HOSTNAME} at $(date)" > /tmp/testfile.txt'
17+
myCID=$(kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodName}" -c ipfs-cluster -- sh -c 'ipfs-cluster-ctl add /tmp/testfile.txt' | awk '{print $2}')
18+
19+
# read the value
20+
ipfsClusterPodname2=$(kubectl get pod -n "${NAMESPACE}" -l "${labelName}=${labelValue}" -o jsonpath='{.items[1].metadata.name}')
21+
log "reading a file from ${ipfsClusterPodname2}"
22+
ipfsCommand="ipfs get --output /tmp/myfile.txt -- ${myCID}"
23+
kubectl exec -n "${NAMESPACE}" "${ipfsClusterPodname2}" -c ipfs -- sh -c "${ipfsCommand}"
24+
}

test-kuttl/e2e/ipfs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# IPFSCluster Test
2+
3+
This test validates that the operator is capable of creating the amount of required replicas,
4+
and that data can be made available and accessed through IPFS.
5+
6+
### Test Steps:
7+
8+
- 00. Assert the Operator is running
9+
- 05. Create an IPFSCluster resource
10+
- 10. Assert the desired amount of replicas were created
11+
- 15. Test creation on one replica and retrieval from another

test-kuttl/e2e/ipfs/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
########################################
88
log() {
99
input="${*}"
10-
printf "[%s]: %s" $(date) "${input}\n"
10+
echo '['$(date)"]: ${input}"
1111
}

0 commit comments

Comments
 (0)