uncommenting testing code
This commit is contained in:
@@ -1,267 +1,267 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
|
|
||||||
// // Testing out if a new group is getting created
|
// Testing out if a new group is getting created
|
||||||
// func TestCreateGroup(t *testing.T) {
|
func TestCreateGroup(t *testing.T) {
|
||||||
// group, err := CreateGroup()
|
group, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// PrettyPrint(group)
|
PrettyPrint(group)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing if the group gets removed when a
|
// Testing if the group gets removed when a
|
||||||
// // group ID is provided
|
// group ID is provided
|
||||||
// func TestRemoveGroup(t *testing.T) {
|
func TestRemoveGroup(t *testing.T) {
|
||||||
// // Creates a new group
|
// Creates a new group
|
||||||
// group, err := CreateGroup()
|
group, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Removes the new group
|
// Removes the new group
|
||||||
// // it created
|
// it created
|
||||||
// err = RemoveGroup(group.ID)
|
err = RemoveGroup(group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing if container information is added
|
// Testing if container information is added
|
||||||
// // to the created group
|
// to the created group
|
||||||
// func TestAddContainerToGroup(t *testing.T) {
|
func TestAddContainerToGroup(t *testing.T) {
|
||||||
// // Creates a new group
|
// Creates a new group
|
||||||
// group, err := CreateGroup()
|
group, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Creating and adding the container to the
|
// Creating and adding the container to the
|
||||||
// // tracked list
|
// tracked list
|
||||||
// container1, err := docker.BuildRunContainer(0, "false", "")
|
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the AddTrackContainer Function and adding the first container created
|
// Testing the AddTrackContainer Function and adding the first container created
|
||||||
// err = AddTrackContainer(container1, "0.0.0.0")
|
err = AddTrackContainer(container1, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Adds container information to the group
|
// Adds container information to the group
|
||||||
// Group, err := AddContainerToGroup(container1.ID, group.ID)
|
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// PrettyPrint(Group)
|
PrettyPrint(Group)
|
||||||
//
|
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removing container 1 from the tracked list
|
// Removing container 1 from the tracked list
|
||||||
// err = RemoveTrackedContainer(container1.ID)
|
err = RemoveTrackedContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removes the new group
|
// Removes the new group
|
||||||
// // it created
|
// it created
|
||||||
// err = RemoveGroup(group.ID)
|
err = RemoveGroup(group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing if the container information is removed from the group
|
// Testing if the container information is removed from the group
|
||||||
// func TestGroup_RemoveContainerGroup(t *testing.T) {
|
func TestGroup_RemoveContainerGroup(t *testing.T) {
|
||||||
// // Creates a new group
|
// Creates a new group
|
||||||
// group, err := CreateGroup()
|
group, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Creating and adding the container to the
|
// Creating and adding the container to the
|
||||||
// // tracked list
|
// tracked list
|
||||||
// container1, err := docker.BuildRunContainer(0, "false", "")
|
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the AddTrackContainer Function and adding the first container created
|
// Testing the AddTrackContainer Function and adding the first container created
|
||||||
// err = AddTrackContainer(container1, "0.0.0.0")
|
err = AddTrackContainer(container1, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Adds container information to the group
|
// Adds container information to the group
|
||||||
// Group, err := AddContainerToGroup(container1.ID, group.ID)
|
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println("Container added")
|
fmt.Println("Container added")
|
||||||
// PrettyPrint(Group)
|
PrettyPrint(Group)
|
||||||
//
|
|
||||||
// // Removing docker container from the group
|
// Removing docker container from the group
|
||||||
// Group, err = RemoveContainerGroup(container1.ID, group.ID)
|
Group, err = RemoveContainerGroup(container1.ID, group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println("Container removed")
|
fmt.Println("Container removed")
|
||||||
// PrettyPrint(Group)
|
PrettyPrint(Group)
|
||||||
//
|
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removing container 1 from the tracked list
|
// Removing container 1 from the tracked list
|
||||||
// err = RemoveTrackedContainer(container1.ID)
|
err = RemoveTrackedContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removes the new group
|
// Removes the new group
|
||||||
// // it created
|
// it created
|
||||||
// err = RemoveGroup(group.ID)
|
err = RemoveGroup(group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing that container are removed from all
|
// Testing that container are removed from all
|
||||||
// // created groups
|
// created groups
|
||||||
// // Scenario:
|
// Scenario:
|
||||||
// // - Create 2 groups
|
// - Create 2 groups
|
||||||
// // - Add Container information to each group
|
// - Add Container information to each group
|
||||||
// // - Remove Container information from each group
|
// - Remove Container information from each group
|
||||||
// func TestGroups_RemoveContainerGroups(t *testing.T) {
|
func TestGroups_RemoveContainerGroups(t *testing.T) {
|
||||||
// // Creates a new group
|
// Creates a new group
|
||||||
// group, err := CreateGroup()
|
group, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Created another group assigned to variable group 1
|
// Created another group assigned to variable group 1
|
||||||
// group1, err := CreateGroup()
|
group1, err := CreateGroup()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Creating and adding the container to the
|
// Creating and adding the container to the
|
||||||
// // tracked list
|
// tracked list
|
||||||
// container1, err := docker.BuildRunContainer(0, "false", "")
|
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the AddTrackContainer Function and adding the first container created
|
// Testing the AddTrackContainer Function and adding the first container created
|
||||||
// err = AddTrackContainer(container1, "0.0.0.0")
|
err = AddTrackContainer(container1, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Adds container information to the group
|
// Adds container information to the group
|
||||||
// Group, err := AddContainerToGroup(container1.ID, group.ID)
|
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println("Container added")
|
fmt.Println("Container added")
|
||||||
// PrettyPrint(Group)
|
PrettyPrint(Group)
|
||||||
//
|
|
||||||
// // Adds container information to the group
|
// Adds container information to the group
|
||||||
// Group1, err := AddContainerToGroup(container1.ID, group1.ID)
|
Group1, err := AddContainerToGroup(container1.ID, group1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println("Container added")
|
fmt.Println("Container added")
|
||||||
// PrettyPrint(Group1)
|
PrettyPrint(Group1)
|
||||||
//
|
|
||||||
// // Removing docker container from the group
|
// Removing docker container from the group
|
||||||
// err = RemoveContainerGroups(container1.ID)
|
err = RemoveContainerGroups(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removing container 1 from the tracked list
|
// Removing container 1 from the tracked list
|
||||||
// err = RemoveTrackedContainer(container1.ID)
|
err = RemoveTrackedContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removes the new group
|
// Removes the new group
|
||||||
// // it created
|
// it created
|
||||||
// err = RemoveGroup(group.ID)
|
err = RemoveGroup(group.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removes the new group
|
// Removes the new group
|
||||||
// // it created
|
// it created
|
||||||
// err = RemoveGroup(group1.ID)
|
err = RemoveGroup(group1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,120 +1,120 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
|
|
||||||
// // Tests a scenario where the container are getting tracked
|
// Tests a scenario where the container are getting tracked
|
||||||
// func TestAddTrackContainer(t *testing.T) {
|
func TestAddTrackContainer(t *testing.T) {
|
||||||
// // Create docker container and get SSH port
|
// Create docker container and get SSH port
|
||||||
// container1, err := docker.BuildRunContainer(0, "false", "")
|
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Testing the AddTrackContainer Function
|
// Testing the AddTrackContainer Function
|
||||||
// err = AddTrackContainer(container1, "0.0.0.0")
|
err = AddTrackContainer(container1, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the remove container function
|
// Testing the remove container function
|
||||||
// // NOTE: This test can also be considered as a whole flow on the process of
|
// NOTE: This test can also be considered as a whole flow on the process of
|
||||||
// // tracked containers
|
// tracked containers
|
||||||
// func TestRemoveTrackedContainer(t *testing.T) {
|
func TestRemoveTrackedContainer(t *testing.T) {
|
||||||
// container1, err := docker.BuildRunContainer(0, "false", "")
|
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// container2, err := docker.BuildRunContainer(0, "false", "")
|
container2, err := docker.BuildRunContainer(0, "false", "")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the AddTrackContainer Function and adding the first container created
|
// Testing the AddTrackContainer Function and adding the first container created
|
||||||
// err = AddTrackContainer(container1, "0.0.0.0")
|
err = AddTrackContainer(container1, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container1.ID)
|
err = docker.StopAndRemoveContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing the AddTrackContainer Function and the adding the second container created
|
// Testing the AddTrackContainer Function and the adding the second container created
|
||||||
// err = AddTrackContainer(container2, "0.0.0.0")
|
err = AddTrackContainer(container2, "0.0.0.0")
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container2.ID)
|
err = docker.StopAndRemoveContainer(container2.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// // Killing docker container created
|
// Killing docker container created
|
||||||
// err = docker.StopAndRemoveContainer(container2.ID)
|
err = docker.StopAndRemoveContainer(container2.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removing container 1 from the tracked list
|
// Removing container 1 from the tracked list
|
||||||
// err = RemoveTrackedContainer(container1.ID)
|
err = RemoveTrackedContainer(container1.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Removing container 2 from the tracked list
|
// Removing container 2 from the tracked list
|
||||||
// err = RemoveTrackedContainer(container2.ID)
|
err = RemoveTrackedContainer(container2.ID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Test function that checks if the ID belongs to
|
// Test function that checks if the ID belongs to
|
||||||
// // a group or container running
|
// a group or container running
|
||||||
// func TestCheckID(t *testing.T) {
|
func TestCheckID(t *testing.T) {
|
||||||
// id := "grp123"
|
id := "grp123"
|
||||||
// checkID, err := CheckID(id)
|
checkID, err := CheckID(id)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// if checkID == "group" {
|
if checkID == "group" {
|
||||||
// fmt.Println("pass")
|
fmt.Println("pass")
|
||||||
// } else {
|
} else {
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package clientIPTable
|
package clientIPTable
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// func TestUpdateIpTableListClient(t *testing.T) {
|
func TestUpdateIpTableListClient(t *testing.T) {
|
||||||
// err := UpdateIpTableListClient()
|
err := UpdateIpTableListClient()
|
||||||
//
|
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,64 +1,64 @@
|
|||||||
package generate
|
package generate
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "github.com/Akilan1999/p2p-rendering-computation/config"
|
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||||
// "os"
|
"os"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// // func TestConfigInit(t *testing.T) {
|
// func TestConfigInit(t *testing.T) {
|
||||||
// // _, err := config.ConfigInit(nil)
|
// _, err := config.ConfigInit(nil)
|
||||||
// // if err != nil {
|
|
||||||
// // t.Error(err)
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// // func TestSetDefaults(t *testing.T) {
|
|
||||||
// // _, err := SetDefaults("", false)
|
|
||||||
// // if err != nil {
|
|
||||||
// // t.Error(err)
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// func TestGetCurrentPath(t *testing.T) {
|
|
||||||
// path, err := GetCurrentPath()
|
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Println(err)
|
|
||||||
// t.Error(err)
|
// t.Error(err)
|
||||||
// }
|
// }
|
||||||
// fmt.Println(path)
|
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// func TestGetPathP2PRC(t *testing.T) {
|
// func TestSetDefaults(t *testing.T) {
|
||||||
// path, err := config.GetPathP2PRC("")
|
// _, err := SetDefaults("", false)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Println(err)
|
|
||||||
// t.Error(err)
|
// t.Error(err)
|
||||||
// }
|
// }
|
||||||
// fmt.Println(path)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func TestSetEnvName(t *testing.T) {
|
|
||||||
// // Create an Env variable TEST with the value "lol"
|
|
||||||
// err := os.Setenv("TEST", "lol")
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
// // Sets the environment variable as the default to read
|
|
||||||
// // for P2PRC
|
|
||||||
// err = config.SetEnvName("TEST")
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Checks if the output for the default read is "lol"
|
|
||||||
// path, err := config.GetPathP2PRC("")
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
// fmt.Println(path)
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
func TestGetCurrentPath(t *testing.T) {
|
||||||
|
path, err := GetCurrentPath()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
fmt.Println(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPathP2PRC(t *testing.T) {
|
||||||
|
path, err := config.GetPathP2PRC("")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
fmt.Println(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSetEnvName(t *testing.T) {
|
||||||
|
// Create an Env variable TEST with the value "lol"
|
||||||
|
err := os.Setenv("TEST", "lol")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
// Sets the environment variable as the default to read
|
||||||
|
// for P2PRC
|
||||||
|
err = config.SetEnvName("TEST")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if the output for the default read is "lol"
|
||||||
|
path, err := config.GetPathP2PRC("")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
fmt.Println(path)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
package generate
|
package generate
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "github.com/Akilan1999/p2p-rendering-computation/config"
|
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// type CustomConfig struct {
|
type CustomConfig struct {
|
||||||
// Test string
|
Test string
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Test case to generate defaults with custom data-structure
|
// Test case to generate defaults with custom data-structure
|
||||||
// func TestSetDefaults(t *testing.T) {
|
func TestSetDefaults(t *testing.T) {
|
||||||
// setDefaults, err := SetDefaults("", true, &CustomConfig{Test: "lol"}, true)
|
setDefaults, err := SetDefaults("", true, &CustomConfig{Test: "lol"}, true)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fmt.Println(setDefaults)
|
fmt.Println(setDefaults)
|
||||||
//
|
|
||||||
// var c CustomConfig
|
var c CustomConfig
|
||||||
//
|
|
||||||
// _, err = config.ConfigInit(nil, &c)
|
_, err = config.ConfigInit(nil, &c)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fmt.Println(c)
|
fmt.Println(c)
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Test case to generate public and private keys
|
// Test case to generate public and private keys
|
||||||
// func TestGeneratePublicAndPrivateKeys(t *testing.T) {
|
func TestGeneratePublicAndPrivateKeys(t *testing.T) {
|
||||||
// MakeSSHKeyPair("test.pub", "test.prv")
|
MakeSSHKeyPair("test.pub", "test.prv")
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
package frp
|
package frp
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "testing"
|
"testing"
|
||||||
// "time"
|
"time"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// // Testing scenario FRPServer
|
// Testing scenario FRPServer
|
||||||
// func TestStartFRPServer(t *testing.T) {
|
func TestStartFRPServer(t *testing.T) {
|
||||||
// var s Server
|
var s Server
|
||||||
// s.address = "127.0.0.1"
|
s.address = "127.0.0.1"
|
||||||
// s.port = 8808
|
s.port = 8808
|
||||||
// err := s.StartFRPServer()
|
err := s.StartFRPServer()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Testing scenario FRPServer and FRPClient connection
|
// Testing scenario FRPServer and FRPClient connection
|
||||||
// func TestStartFRPClient(t *testing.T) {
|
func TestStartFRPClient(t *testing.T) {
|
||||||
// var s Server
|
var s Server
|
||||||
// s.address = "127.0.0.1"
|
s.address = "127.0.0.1"
|
||||||
// s.port = 8808
|
s.port = 8808
|
||||||
// go s.StartFRPServer()
|
go s.StartFRPServer()
|
||||||
//
|
|
||||||
// time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
//
|
|
||||||
// // Sample test client
|
// Sample test client
|
||||||
// var c Client
|
var c Client
|
||||||
// c.Server = &s
|
c.Server = &s
|
||||||
// c.ClientMappings = []ClientMapping{
|
c.ClientMappings = []ClientMapping{
|
||||||
// {
|
{
|
||||||
// LocalIP: "127.0.0.1",
|
LocalIP: "127.0.0.1",
|
||||||
// LocalPort: 22,
|
LocalPort: 22,
|
||||||
// RemotePort: 3301,
|
RemotePort: 3301,
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// err := c.StartFRPClient()
|
err := c.StartFRPClient()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,76 +1,77 @@
|
|||||||
package p2p
|
package p2p
|
||||||
// import (
|
|
||||||
// "fmt"
|
import (
|
||||||
// "testing"
|
"fmt"
|
||||||
// )
|
"testing"
|
||||||
//
|
)
|
||||||
// func TestReadIpTable(t *testing.T) {
|
|
||||||
// json, err := ReadIpTable()
|
func TestReadIpTable(t *testing.T) {
|
||||||
// if err != nil {
|
json, err := ReadIpTable()
|
||||||
// t.Fatal(err)
|
if err != nil {
|
||||||
// }
|
t.Fatal(err)
|
||||||
//
|
}
|
||||||
// err = json.WriteIpTable()
|
|
||||||
// if err != nil {
|
err = json.WriteIpTable()
|
||||||
// t.Fatal(err)
|
if err != nil {
|
||||||
// }
|
t.Fatal(err)
|
||||||
//
|
}
|
||||||
// err = PrintIpTable()
|
|
||||||
// if err != nil {
|
err = PrintIpTable()
|
||||||
// t.Fatal(err)
|
if err != nil {
|
||||||
// }
|
t.Fatal(err)
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// // Testing is a IPV6 address is returned
|
|
||||||
// func TestGetCurrentIPV6(t *testing.T) {
|
// Testing is a IPV6 address is returned
|
||||||
// res, err := GetCurrentIPV6()
|
func TestGetCurrentIPV6(t *testing.T) {
|
||||||
//
|
res, err := GetCurrentIPV6()
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
if err != nil {
|
||||||
// }
|
t.Error(err)
|
||||||
//
|
}
|
||||||
// fmt.Println(res)
|
|
||||||
// }
|
fmt.Println(res)
|
||||||
//
|
}
|
||||||
// // This test ensures that the duplicate function works as intended
|
|
||||||
// func TestIpAddresses_RemoveDuplicates(t *testing.T) {
|
// This test ensures that the duplicate function works as intended
|
||||||
// var testduplicates IpAddresses
|
func TestIpAddresses_RemoveDuplicates(t *testing.T) {
|
||||||
// var duplicateaddress1 IpAddress
|
var testduplicates IpAddresses
|
||||||
// var duplicateaddress2 IpAddress
|
var duplicateaddress1 IpAddress
|
||||||
//
|
var duplicateaddress2 IpAddress
|
||||||
// duplicateaddress1.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
|
||||||
// duplicateaddress1.Ipv4="0.0.0.0"
|
duplicateaddress1.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
||||||
//
|
duplicateaddress1.Ipv4="0.0.0.0"
|
||||||
// duplicateaddress2.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
|
||||||
// duplicateaddress2.Ipv4="0.0.0.0"
|
duplicateaddress2.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
||||||
//
|
duplicateaddress2.Ipv4="0.0.0.0"
|
||||||
// testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress1)
|
|
||||||
// testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress2)
|
testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress1)
|
||||||
//
|
testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress2)
|
||||||
// err := testduplicates.RemoveDuplicates()
|
|
||||||
// if err != nil {
|
err := testduplicates.RemoveDuplicates()
|
||||||
// t.Error(err)
|
if err != nil {
|
||||||
// }
|
t.Error(err)
|
||||||
//
|
}
|
||||||
// if len(testduplicates.IpAddress) == 2 {
|
|
||||||
// t.Fail()
|
if len(testduplicates.IpAddress) == 2 {
|
||||||
// }
|
t.Fail()
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
//
|
}
|
||||||
// func TestViewNetworkInterface(t *testing.T) {
|
|
||||||
// err := ViewNetworkInterface()
|
func TestViewNetworkInterface(t *testing.T) {
|
||||||
// if err != nil {
|
err := ViewNetworkInterface()
|
||||||
// t.Error()
|
if err != nil {
|
||||||
// }
|
t.Error()
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// func TestIp4or6(t *testing.T) {
|
|
||||||
// // This test ensures that the ipv6 address gets detected
|
func TestIp4or6(t *testing.T) {
|
||||||
// test := "2001:8f8:172d:7e27:4f23:ae4:bce5:e037"
|
// This test ensures that the ipv6 address gets detected
|
||||||
// res := Ip4or6(test)
|
test := "2001:8f8:172d:7e27:4f23:ae4:bce5:e037"
|
||||||
// if res != "version 6" {
|
res := Ip4or6(test)
|
||||||
// t.Fail()
|
if res != "version 6" {
|
||||||
// }
|
t.Fail()
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// // To run this test ip_table.json must be populated
|
// To run this test ip_table.json must be populated
|
||||||
// func TestServer_SpeedTest(t *testing.T) {
|
func TestServer_SpeedTest(t *testing.T) {
|
||||||
// err := LocalSpeedTestIpTable()
|
err := LocalSpeedTestIpTable()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Fatal(err)
|
t.Fatal(err)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //HumaidTest("http://localhost:8088/50")
|
//HumaidTest("http://localhost:8088/50")
|
||||||
// //HumaidTest("http://ipv4.download.thinkbroadband.com/50MB.zip")
|
//HumaidTest("http://ipv4.download.thinkbroadband.com/50MB.zip")
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// // Tests if the current has UPNP support
|
// Tests if the current has UPNP support
|
||||||
// func TestForwardUPNPPort(t *testing.T) {
|
func TestForwardUPNPPort(t *testing.T) {
|
||||||
// err := ForwardPort(6586)
|
err := ForwardPort(6586)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// t.Fail()
|
t.Fail()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
// import (
|
import (
|
||||||
// "fmt"
|
"fmt"
|
||||||
// "testing"
|
"testing"
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// func TestGpuOutput(t *testing.T) {
|
func TestGpuOutput(t *testing.T) {
|
||||||
// gpu, err := GPUInfo()
|
gpu, err := GPUInfo()
|
||||||
//
|
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Error(err)
|
t.Error(err)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fmt.Print(gpu.Gpu.GpuName)
|
fmt.Print(gpu.Gpu.GpuName)
|
||||||
// }
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user