Skip to content

Commit 47e92ed

Browse files
committed
fix unit tests
Signed-off-by: trafalgarzzz <trafalgarz@outlook.com>
1 parent 9bce272 commit 47e92ed

17 files changed

Lines changed: 36 additions & 0 deletions

pkg/ddc/alluxio/create_volume_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
// and one PVC are created after the function execution
4040
func TestCreateVolume(t *testing.T) {
4141
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", "alluxio")
42+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
4243
if err != nil {
4344
t.Errorf("fail to create the runtimeInfo with error %v", err)
4445
}
@@ -134,6 +135,7 @@ func TestCreateVolume(t *testing.T) {
134135
// is created in the fake client.
135136
func TestCreateFusePersistentVolume(t *testing.T) {
136137
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", "alluxio")
138+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
137139
if err != nil {
138140
t.Errorf("fail to create the runtimeInfo with error %v", err)
139141
}
@@ -186,6 +188,7 @@ func TestCreateFusePersistentVolume(t *testing.T) {
186188
func TestCreateFusePersistentVolumeClaim(t *testing.T) {
187189
// Prepare runtime information for the AlluxioEngine.
188190
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", "alluxio")
191+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
189192
if err != nil {
190193
t.Errorf("fail to create the runtimeInfo with error %v", err)
191194
}

pkg/ddc/alluxio/delete_volume_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type TestCase struct {
5454
func newTestAlluxioEngine(client client.Client, name string, namespace string, withRunTime bool) *AlluxioEngine {
5555
runTime := &datav1alpha1.AlluxioRuntime{}
5656
runTimeInfo, _ := base.BuildRuntimeInfo(name, namespace, "alluxio")
57+
runTimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
5758
if !withRunTime {
5859
runTimeInfo = nil
5960
runTime = nil

pkg/ddc/alluxio/runtime_info.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (e *AlluxioEngine) getRuntimeInfo() (base.RuntimeInfoInterface, error) {
6565
}
6666
}
6767

68+
if e.UnitTest {
69+
return e.runtimeInfo, nil
70+
}
71+
6872
// Handling information of bound dataset. XXXEngine.getRuntimeInfo() might be called before the runtime is bound to a dataset,
6973
// so here we must lazily set dataset-related information once we found there's one bound dataset.
7074
if len(e.runtimeInfo.GetOwnerDatasetUID()) == 0 {

pkg/ddc/goosefs/create_volume_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
func TestCreateVolume(t *testing.T) {
3535
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.GooseFSRuntime)
36+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
3637
if err != nil {
3738
t.Errorf("fail to create the runtimeInfo with error %v", err)
3839
}
@@ -120,6 +121,7 @@ func TestCreateVolume(t *testing.T) {
120121

121122
func TestCreateFusePersistentVolume(t *testing.T) {
122123
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.GooseFSRuntime)
124+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
123125
if err != nil {
124126
t.Errorf("fail to create the runtimeInfo with error %v", err)
125127
}
@@ -166,6 +168,7 @@ func TestCreateFusePersistentVolume(t *testing.T) {
166168

167169
func TestCreateFusePersistentVolumeClaim(t *testing.T) {
168170
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.GooseFSRuntime)
171+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
169172
if err != nil {
170173
t.Errorf("fail to create the runtimeInfo with error %v", err)
171174
}

pkg/ddc/goosefs/delete_volume_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type TestCase struct {
4141
func newTestGooseFSEngine(client client.Client, name string, namespace string, withRunTime bool) *GooseFSEngine {
4242
runTime := &datav1alpha1.GooseFSRuntime{}
4343
runTimeInfo, _ := base.BuildRuntimeInfo(name, namespace, common.GooseFSRuntime)
44+
runTimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
4445
if !withRunTime {
4546
runTimeInfo = nil
4647
runTime = nil

pkg/ddc/jindo/create_volume_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
// 4. Proper setting of the fuse generation label on the created PVC.
4242
func TestCreateVolume(t *testing.T) {
4343
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
44+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
4445
if err != nil {
4546
t.Errorf("fail to create the runtimeInfo with error %v", err)
4647
}
@@ -134,6 +135,7 @@ func TestCreateVolume(t *testing.T) {
134135
// - Checking that exactly one PersistentVolume has been created
135136
func TestCreateFusePersistentVolume(t *testing.T) {
136137
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
138+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
137139
if err != nil {
138140
t.Errorf("fail to create the runtimeInfo with error %v", err)
139141
}
@@ -179,6 +181,7 @@ func TestCreateFusePersistentVolume(t *testing.T) {
179181

180182
func TestCreateFusePersistentVolumeClaim(t *testing.T) {
181183
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
184+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
182185
if err != nil {
183186
t.Errorf("fail to create the runtimeInfo with error %v", err)
184187
}

pkg/ddc/jindo/delete_volume_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type TestCase struct {
4141
func newTestJindoEngine(client client.Client, name string, namespace string, withRunTime bool) *JindoEngine {
4242
runTime := &datav1alpha1.JindoRuntime{}
4343
runTimeInfo, _ := base.BuildRuntimeInfo(name, namespace, common.JindoRuntime)
44+
runTimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
4445
if !withRunTime {
4546
runTimeInfo = nil
4647
runTime = nil

pkg/ddc/jindocache/create_volume_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
func TestCreateVolume(t *testing.T) {
3535
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
36+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
3637
if err != nil {
3738
t.Errorf("fail to create the runtimeInfo with error %v", err)
3839
}
@@ -119,6 +120,7 @@ func TestCreateVolume(t *testing.T) {
119120

120121
func TestCreateFusePersistentVolume(t *testing.T) {
121122
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
123+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
122124
if err != nil {
123125
t.Errorf("fail to create the runtimeInfo with error %v", err)
124126
}
@@ -165,6 +167,7 @@ func TestCreateFusePersistentVolume(t *testing.T) {
165167

166168
func TestCreateFusePersistentVolumeClaim(t *testing.T) {
167169
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
170+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
168171
if err != nil {
169172
t.Errorf("fail to create the runtimeInfo with error %v", err)
170173
}

pkg/ddc/jindocache/delete_volume_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type TestCase struct {
4141
func newTestJindoCacheEngine(client client.Client, name string, namespace string, withRunTime bool) *JindoCacheEngine {
4242
runTime := &datav1alpha1.JindoRuntime{}
4343
runTimeInfo, _ := base.BuildRuntimeInfo(name, namespace, common.JindoRuntime)
44+
runTimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
4445
if !withRunTime {
4546
runTimeInfo = nil
4647
runTime = nil

pkg/ddc/jindofsx/create_volume_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
func TestCreateVolume(t *testing.T) {
3535
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
36+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
3637
if err != nil {
3738
t.Errorf("fail to create the runtimeInfo with error %v", err)
3839
}
@@ -119,6 +120,7 @@ func TestCreateVolume(t *testing.T) {
119120

120121
func TestCreateFusePersistentVolume(t *testing.T) {
121122
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
123+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
122124
if err != nil {
123125
t.Errorf("fail to create the runtimeInfo with error %v", err)
124126
}
@@ -165,6 +167,7 @@ func TestCreateFusePersistentVolume(t *testing.T) {
165167

166168
func TestCreateFusePersistentVolumeClaim(t *testing.T) {
167169
runtimeInfo, err := base.BuildRuntimeInfo("hbase", "fluid", common.JindoRuntime)
170+
runtimeInfo.SetOwnerDatasetUID("dummy-dataset-uid")
168171
if err != nil {
169172
t.Errorf("fail to create the runtimeInfo with error %v", err)
170173
}

0 commit comments

Comments
 (0)