Skip to content

Commit

Permalink
use myceliumip in tests
Browse files Browse the repository at this point in the history
Signed-off-by: nabil salah <[email protected]>
  • Loading branch information
Nabil-Salah committed Oct 2, 2024
1 parent fc1fbdc commit 781df78
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion grid-client/integration_tests/batch_k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestBatchK8sDeployment(t *testing.T) {
require.NotEmpty(t, k1.Master.IP)
require.NotEqual(t, k1.Master.IP, k2.Workers[0].IP)

require.True(t, CheckConnection(k2.Workers[0].PlanetaryIP, "22"))
require.True(t, CheckConnection(k2.Workers[0].MyceliumIP, "22"))

// ssh to master node
require.NoError(t, requireNodesAreReady(len(k2.Workers)+1, k2.Master.PlanetaryIP, privateKey))
Expand Down
4 changes: 2 additions & 2 deletions grid-client/integration_tests/gateway_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestGatewayNameDeployment(t *testing.T) {
v, err := tfPluginClient.State.LoadVMFromGrid(context.Background(), nodeID, vm.Name, dl.Name)
require.NoError(t, err)

backend := fmt.Sprintf("http://[%s]:9000", v.PlanetaryIP)
backend := fmt.Sprintf("http://[%s]:9000", v.MyceliumIP)
gw := workloads.GatewayNameProxy{
NodeID: gwNodeID,
Name: generateRandString(10),
Expand All @@ -101,7 +101,7 @@ func TestGatewayNameDeployment(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, result.FQDN)

_, err = RemoteRun("root", v.PlanetaryIP, "apk add python3; python3 -m http.server 9000 --bind :: &> /dev/null &", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "apk add python3; python3 -m http.server 9000 --bind :: &> /dev/null &", privateKey)
require.NoError(t, err)

time.Sleep(3 * time.Second)
Expand Down
6 changes: 3 additions & 3 deletions grid-client/integration_tests/qsfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func TestQSFSDeployment(t *testing.T) {
metrics := resQSFS.MetricsEndpoint
require.NotEmpty(t, metrics)

planetaryIP := resVM.PlanetaryIP
require.NotEmpty(t, planetaryIP)
myceliimIP := resVM.MyceliumIP
require.NotEmpty(t, myceliimIP)

// get metrics
cmd := exec.Command("curl", metrics)
Expand All @@ -198,7 +198,7 @@ func TestQSFSDeployment(t *testing.T) {
require.Contains(t, string(output), "fs_syscalls{syscall=\"create\"} 0")

// try write to a file in mounted disk
_, err = RemoteRun("root", planetaryIP, "cd /qsfs && echo hamadatext >> hamadafile", privateKey)
_, err = RemoteRun("root", myceliimIP, "cd /qsfs && echo hamadatext >> hamadafile", privateKey)
require.NoError(t, err)

time.Sleep(5 * time.Second)
Expand Down
1 change: 0 additions & 1 deletion grid-client/integration_tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func generateBasicVM(vmName string, nodeID uint32, networkName string, publicKey
NetworkName: networkName,
CPU: minCPU,
MemoryMB: minMemory * 1024,
Planetary: true,
Flist: "https://hub.grid.tf/tf-official-apps/base:latest.flist",
Entrypoint: "/sbin/zinit init",
EnvVars: map[string]string{
Expand Down
28 changes: 14 additions & 14 deletions grid-client/integration_tests/two_vms_same_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,24 @@ func TestTwoVMsSameNetworkWithPublicIPV6(t *testing.T) {
v2, err := tfPluginClient.State.LoadVMFromGrid(context.Background(), nodeID, vm2.Name, dl.Name)
require.NoError(t, err)

yggIP1 := v1.PlanetaryIP
yggIP2 := v2.PlanetaryIP
myceliumIP1 := v1.MyceliumIP
myceliumIP2 := v2.MyceliumIP

require.NotEmpty(t, yggIP1)
require.NotEmpty(t, yggIP2)
require.NotEmpty(t, myceliumIP1)
require.NotEmpty(t, myceliumIP2)

_, err = RemoteRun("root", yggIP1, "apt install -y netcat", privateKey)
_, err = RemoteRun("root", myceliumIP1, "apt install -y netcat", privateKey)
require.NoError(t, err)

_, err = RemoteRun("root", yggIP2, "apt install -y netcat", privateKey)
_, err = RemoteRun("root", myceliumIP2, "apt install -y netcat", privateKey)
require.NoError(t, err)

// check yggIP2 from vm1
_, err = RemoteRun("root", yggIP1, fmt.Sprintf("nc -z %s 22", yggIP2), privateKey)
// check myceliumIP2 from vm1
_, err = RemoteRun("root", myceliumIP1, fmt.Sprintf("nc -z %s 22", myceliumIP2), privateKey)
require.NoError(t, err)

// check yggIP1 from vm2
_, err = RemoteRun("root", yggIP2, fmt.Sprintf("nc -z %s 22", yggIP1), privateKey)
// check myceliumIP1 from vm2
_, err = RemoteRun("root", myceliumIP2, fmt.Sprintf("nc -z %s 22", myceliumIP1), privateKey)
require.NoError(t, err)

privateIP1 := v1.IP
Expand All @@ -106,11 +106,11 @@ func TestTwoVMsSameNetworkWithPublicIPV6(t *testing.T) {
require.NotEqual(t, privateIP1, privateIP2)

// check privateIP2 from vm1
_, err = RemoteRun("root", yggIP1, fmt.Sprintf("nc -z %s 22", privateIP2), privateKey)
_, err = RemoteRun("root", myceliumIP1, fmt.Sprintf("nc -z %s 22", privateIP2), privateKey)
require.NoError(t, err)

// check privateIP1 from vm2
_, err = RemoteRun("root", yggIP2, fmt.Sprintf("nc -z %s 22", privateIP1), privateKey)
_, err = RemoteRun("root", myceliumIP2, fmt.Sprintf("nc -z %s 22", privateIP1), privateKey)
require.NoError(t, err)

publicIP6_1 := strings.Split(v1.ComputedIP6, "/")[0]
Expand All @@ -120,10 +120,10 @@ func TestTwoVMsSameNetworkWithPublicIPV6(t *testing.T) {
require.NotEmpty(t, publicIP6_2)

// check publicIP62 from vm1
_, err = RemoteRun("root", yggIP1, fmt.Sprintf("nc -z %s 22", publicIP6_2), privateKey)
_, err = RemoteRun("root", myceliumIP1, fmt.Sprintf("nc -z %s 22", publicIP6_2), privateKey)
require.NoError(t, err)

// check publicIP61 from vm2
_, err = RemoteRun("root", yggIP2, fmt.Sprintf("nc -z %s 22", publicIP6_1), privateKey)
_, err = RemoteRun("root", myceliumIP2, fmt.Sprintf("nc -z %s 22", publicIP6_1), privateKey)
require.NoError(t, err)
}
24 changes: 12 additions & 12 deletions grid-client/integration_tests/vm_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestVMWithTwoDisk(t *testing.T) {

v, err := tfPluginClient.State.LoadVMFromGrid(context.Background(), nodeID, vm.Name, dl.Name)
require.NoError(t, err)
require.NotEmpty(t, v.PlanetaryIP)
require.NotEmpty(t, v.MyceliumIP)

resDisk1, err := tfPluginClient.State.LoadDiskFromGrid(context.Background(), nodeID, disk1.Name, dl.Name)
require.NoError(t, err)
Expand All @@ -90,49 +90,49 @@ func TestVMWithTwoDisk(t *testing.T) {
require.Equal(t, disk2, resDisk2)

// Check that disk has been mounted successfully
output, err := RemoteRun("root", v.PlanetaryIP, "df -h | grep -w /disk1", privateKey)
output, err := RemoteRun("root", v.MyceliumIP, "df -h | grep -w /disk1", privateKey)
require.NoError(t, err)
require.Contains(t, output, fmt.Sprintf("%d.0G", disk1.SizeGB))

output, err = RemoteRun("root", v.PlanetaryIP, "df -h | grep -w /disk2", privateKey)
output, err = RemoteRun("root", v.MyceliumIP, "df -h | grep -w /disk2", privateKey)
require.NoError(t, err)
require.Contains(t, output, fmt.Sprintf("%d.0G", disk2.SizeGB))

// create file -> d1, check file size, move file -> d2, check file size

_, err = RemoteRun("root", v.PlanetaryIP, "dd if=/dev/vda bs=1M count=512 of=/disk1/test.txt", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "dd if=/dev/vda bs=1M count=512 of=/disk1/test.txt", privateKey)
require.NoError(t, err)

res, err := RemoteRun("root", v.PlanetaryIP, "du /disk1/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
res, err := RemoteRun("root", v.MyceliumIP, "du /disk1/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
require.NoError(t, err)
require.Equal(t, res, strconv.Itoa(512*1024))

_, err = RemoteRun("root", v.PlanetaryIP, "mv /disk1/test.txt /disk2/", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "mv /disk1/test.txt /disk2/", privateKey)
require.NoError(t, err)

res, err = RemoteRun("root", v.PlanetaryIP, "du /disk2/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
res, err = RemoteRun("root", v.MyceliumIP, "du /disk2/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
require.NoError(t, err)
require.Equal(t, res, strconv.Itoa(512*1024))

// create file -> d2, check file size, copy file -> d1, check file size

_, err = RemoteRun("root", v.PlanetaryIP, "dd if=/dev/vdb bs=1M count=512 of=/disk2/test.txt", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "dd if=/dev/vdb bs=1M count=512 of=/disk2/test.txt", privateKey)
require.NoError(t, err)

res, err = RemoteRun("root", v.PlanetaryIP, "du /disk2/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
res, err = RemoteRun("root", v.MyceliumIP, "du /disk2/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
require.NoError(t, err)
require.Equal(t, res, strconv.Itoa(512*1024))

_, err = RemoteRun("root", v.PlanetaryIP, "cp /disk2/test.txt /disk1/", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "cp /disk2/test.txt /disk1/", privateKey)
require.NoError(t, err)

res, err = RemoteRun("root", v.PlanetaryIP, "du /disk1/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
res, err = RemoteRun("root", v.MyceliumIP, "du /disk1/test.txt | head -n1 | awk '{print $1;}' | tr -d -c 0-9", privateKey)
require.NoError(t, err)
require.Equal(t, res, strconv.Itoa(512*1024))

// copy same file -> d1 (not enough space)

_, err = RemoteRun("root", v.PlanetaryIP, "cp /disk2/test.txt /disk1/test2.txt", privateKey)
_, err = RemoteRun("root", v.MyceliumIP, "cp /disk2/test.txt /disk1/test2.txt", privateKey)
require.Error(t, err)
require.Contains(t, err.Error(), "No space left on device")
}

0 comments on commit 781df78

Please sign in to comment.