Skip to content

Commit 63835bb

Browse files
authored
Merge pull request #97 from arangodb/test/peristent-volumes
add persistent-volume tests
2 parents ca4e0d2 + f24b0f8 commit 63835bb

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

docs/design/testing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ The following test scenario's must be covered by automated tests:
2323
- Restart Node
2424
- API server unavailable
2525

26+
- Persistent Volumes:
27+
- hint: RBAC file might need to be changed
28+
- hint: get info via - client-go.CoreV1()
29+
- Number of volumes should stay in reasonable bounds
30+
- For some cases it might be possible to check that, the amount before and after the test stays the same
31+
- A Cluster start should need 6 Volumes (DBServer + Agents)
32+
- The release of a volume-claim should result in a release of the volume
33+
2634
## Test environments
2735

2836
- Kubernetes clusters

tests/persistent_volumes_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
// Author Jan Christoph Uhde <jan@uhdejc.com>
21+
//
22+
package tests
23+
24+
import (
25+
"fmt"
26+
"strings"
27+
"testing"
28+
29+
"github.com/dchest/uniuri"
30+
"github.com/stretchr/testify/assert"
31+
32+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33+
34+
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
35+
kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client"
36+
//"github.com/arangodb/kube-arangodb/pkg/util"
37+
)
38+
39+
// TODO - add description
40+
func TestPersistence(t *testing.T) {
41+
longOrSkip(t)
42+
43+
k8sNameSpace := getNamespace(t)
44+
k8sClient := mustNewKubeClient(t)
45+
46+
volumesList, err := k8sClient.CoreV1().PersistentVolumes().List(metav1.ListOptions{})
47+
assert.NoError(t, err, "error while listing volumes")
48+
claimsList, err := k8sClient.CoreV1().PersistentVolumeClaims(k8sNameSpace).List(metav1.ListOptions{})
49+
assert.NoError(t, err, "error while listing volume claims")
50+
51+
fmt.Printf("----------------------------------------")
52+
fmt.Printf("%v %v", volumesList, claimsList)
53+
fmt.Printf("----------------------------------------")
54+
fmt.Printf("%v %v", len(volumesList.Items), len(claimsList.Items))
55+
fmt.Printf("----------------------------------------")
56+
57+
mode := api.DeploymentModeCluster
58+
engine := api.StorageEngineRocksDB
59+
60+
deploymentClient := kubeArangoClient.MustNewInCluster()
61+
deploymentTemplate := newDeployment(strings.Replace(fmt.Sprintf("tpers-%s-%s-%s", mode[:2], engine[:2], uniuri.NewLen(4)), ".", "", -1))
62+
deploymentTemplate.Spec.Mode = api.NewMode(mode)
63+
deploymentTemplate.Spec.StorageEngine = api.NewStorageEngine(engine)
64+
deploymentTemplate.Spec.TLS = api.TLSSpec{}
65+
//deploymentTemplate.Spec.Environment = api.NewEnvironment(api.EnvironmentDevelopment)
66+
//deploymentTemplate.Spec.Image = util.NewString("arangodb/arangodb:3.3.4")
67+
//deploymentTemplate.Spec.DBServers.Count = util.NewInt(numNodes + 1)
68+
deploymentTemplate.Spec.SetDefaults(deploymentTemplate.GetName()) // this must be last
69+
assert.NoError(t, deploymentTemplate.Spec.Validate())
70+
71+
// Create deployment
72+
_, err = deploymentClient.DatabaseV1alpha().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate)
73+
assert.NoError(t, err, "failed to create deplyment: %s", err)
74+
75+
_, err = waitUntilDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace, deploymentIsReady())
76+
assert.NoError(t, err, fmt.Sprintf("Deployment not running in time: %s", err)) // <-- fails here at the moment
77+
78+
// TODO - add tests that check the number of volumes and claims
79+
80+
// Cleanup
81+
removeDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace)
82+
}

0 commit comments

Comments
 (0)