Skip to content

Commit 9029d5f

Browse files
authored
Add Notation to TestAlluxioEngine_allocateSinglePort in pkg\ddc\alluxio\transform_test.go (#4588)
Signed-off-by: 221220047 <221220047@smail.nju.edu.cn>
1 parent 2e87273 commit 9029d5f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

pkg/ddc/alluxio/transform_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,22 @@ func TestGetMediumTypeFromVolumeSource(t *testing.T) {
588588
}
589589
}
590590

591+
// TestAlluxioEngine_allocateSinglePort is a unit test function that tests
592+
// the `allocateSinglePort` method of the `AlluxioEngine` struct.
593+
// The function verifies the behavior of port allocation for Alluxio master
594+
// and worker components under different scenarios,
595+
// including when properties are set, unset, or when runtime specifications
596+
// are provided.
597+
//
598+
// Parameters:
599+
// - t: A testing.T object provided by the Go testing framework, used to
600+
// manage test state and support formatted test logs.
601+
//
602+
// Returns:
603+
// - None. The function is a test function and does not return any value.
604+
// It reports test failures using the `t.Errorf` method.
591605
func TestAlluxioEngine_allocateSinglePort(t *testing.T) {
606+
// Define the fields required for the AlluxioEngine struct.
592607
type fields struct {
593608
runtime *datav1alpha1.AlluxioRuntime
594609
name string
@@ -600,11 +615,13 @@ func TestAlluxioEngine_allocateSinglePort(t *testing.T) {
600615
initImage string
601616
MetadataSyncDoneCh chan base.MetadataSyncResult
602617
}
618+
// Define the arguments required for the test cases.
603619
type args struct {
604620
allocatedPorts []int
605621
alluxioValue *Alluxio
606622
}
607623

624+
// Define a slice of test cases, each with a name, fields, arguments, and expected results.
608625
tests := []struct {
609626
name string
610627
fields fields
@@ -671,8 +688,10 @@ func TestAlluxioEngine_allocateSinglePort(t *testing.T) {
671688
wantPorts: []int{20005},
672689
},
673690
}
691+
// Iterate over each test case and run the test.
674692
for _, tt := range tests {
675693
t.Run(tt.name, func(t *testing.T) {
694+
// Initialize the AlluxioEngine with the fields from the test case.
676695
e := &AlluxioEngine{
677696
runtime: tt.fields.runtime,
678697
name: tt.fields.name,
@@ -685,6 +704,7 @@ func TestAlluxioEngine_allocateSinglePort(t *testing.T) {
685704
MetadataSyncDoneCh: tt.fields.MetadataSyncDoneCh,
686705
}
687706

707+
// Initialize index and preIndex to track the position in the allocated ports slice.
688708
index := 0
689709
preIndex := 0
690710

0 commit comments

Comments
 (0)