Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net 1176 client changes #449

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .github/workflows/dailytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
id: ping
run: |
chmod +x bin/test
sleep 3m
sleep 5m
bin/test ping
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DO_TOKEN }}
Expand Down Expand Up @@ -130,6 +130,7 @@ jobs:
run: |
chmod +x bin/test
bin/test peerUpdate -s ${{ inputs.server }}
bin/test clientChanges
bin/test ingress
bin/test egress
bin/test relay
Expand Down
4 changes: 4 additions & 0 deletions netmaker/host.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package netmaker

import (
"fmt"
"net/http"

"github.com/gravitl/netmaker/models"
Expand All @@ -21,6 +22,9 @@ func GetHostByName(name string) *models.ApiHost {
func GetHosts() *[]models.ApiHost {
return callapi[[]models.ApiHost](http.MethodGet, "/api/hosts", nil)
}
func UpdateHost(host *models.ApiHost) {
callapi[models.ApiHost](http.MethodPut, fmt.Sprintf("/api/hosts/%s", host.ID), host)
}

func GetHostByID(id string, hosts *[]models.ApiHost) *models.ApiHost {
for _, host := range *hosts {
Expand Down
56 changes: 56 additions & 0 deletions test/cmd/clientchanges.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package cmd

import (
"fmt"
"time"

"github.com/gravitl/devops/netmaker"
"github.com/spf13/cobra"
"golang.org/x/exp/rand"
"golang.org/x/exp/slog"
)

// ingessCmd represents the ingess command
var clientChangesCmd = &cobra.Command{
Use: "clientChanges",
Short: "run client changes test",
Long: `make changes to a client;
verify all nodes received update`,
Run: func(cmd *cobra.Command, args []string) {
setupLoging("clientChanges")
fmt.Println(clientchangestest(&config))
},
}

func init() {
rootCmd.AddCommand(clientChangesCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// ingessCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// ingessCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

func clientchangestest(config *netmaker.Config) bool {
pass := true
netclient := netmaker.GetNetclient(config.Network)
rand.Seed(uint64(time.Now().UnixNano()))
changer := netclient[rand.Intn(len(netclient))]

slog.Info("making changes to", changer.Host.Name)
mtu := rand.Intn(221) + 1280 // Generates a random MTU between 1280 and 1500
slog.Info("changing mtu to", mtu, "on", changer.Host.Name)
changer.Host.MTU = mtu

udpPort := rand.Intn(10) + 51821
slog.Info("changing udp port to", udpPort, "on", changer.Host.Name)
changer.Host.ListenPort = udpPort

netmaker.UpdateHost(&changer.Host)
return pass
}
Loading