func TestGetServiceNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } service, err := balance.GetService(testService2.Id) if err == nil { t.Errorf("Failed to fail GETTING service - %v", err) t.FailNow() } if err := balance.SetServices([]core.Service{testService2}); err != nil { t.Errorf("Failed to SET services - %v", err) t.FailNow() } service, err = balance.GetService(testService2.Id) if err != nil { t.Errorf("Failed to GET service - %v", err) t.FailNow() } if service.Id != testService2.Id { t.Errorf("Read service differs from written service") } }
func TestSetServicesNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } if err := balance.SetService(&testService1); err != nil { t.Errorf("Failed to SET services - %v", err) t.FailNow() } if err := balance.SetServices([]core.Service{testService2}); err != nil { t.Errorf("Failed to SET services - %v", err) t.FailNow() } _, err := balance.GetService(testService1.Id) if err == nil { t.Errorf("Failed to clear old services on PUT - %v", err) t.FailNow() } service, err := balance.GetService(testService2.Id) if err != nil { t.Error(err) t.FailNow() } if service.Host != testService2.Host { t.Errorf("Read service differs from written service") } }
func TestDeleteServerNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } err := balance.DeleteServer("not-real-thing", testServer2.Id) if err == nil { t.Errorf("Failed to DELETE nonexistant server - %v", err) } balance.SetService(&testService1) err = balance.DeleteServer(testService1.Id, testServer2.Id) if err != nil { t.Errorf("Failed to DELETE nonexistant server - %v", err) } balance.SetServer(testService1.Id, &testServer2) err = balance.DeleteServer(testService1.Id, testServer2.Id) if err != nil { t.Errorf("Failed to DELETE server - %v", err) } // todo: read from ipvsadm service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) t.FailNow() } if service.Id != testService1.Id { t.Errorf("Read service differs from written service") } }
func TestSetServersNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } servers := []core.Server{testServer2} if err := balance.SetServers(testService1.Id, servers); err == nil { t.Errorf("Failed to fail SETTING servers - %v", err) t.FailNow() } balance.SetService(&testService1) if err := balance.SetServers(testService1.Id, servers); err != nil { t.Errorf("Failed to SET servers - %v", err) t.FailNow() } service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) } svc := testService1 svc.Servers = append(svc.Servers, testServer2) if service.Servers[0].Host != svc.Servers[0].Host { t.Errorf("Failed to clear old servers on PUT") } }
func TestSetServerNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } balance.SetService(&testService1) if err := balance.SetServer(testService1.Id, &testServer1); err != nil { t.Errorf("Failed to SET server - %v", err) t.FailNow() } if err := balance.SetServer(testService1.Id, &testServer1); err != nil { t.Errorf("Failed to SET server - %v", err) t.FailNow() } service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) } svc := testService1 svc.Servers = append(svc.Servers, testServer1) if service.Servers[0].Host != svc.Servers[0].Host { t.Errorf("Read service differs from written service") } }
func TestSetServices(t *testing.T) { if skip { t.SkipNow() } services := []core.Service{} services = append(services, testService2) if err := balance.SetServices(services); err != nil { t.Errorf("Failed to SET services - %v", err) t.FailNow() } if _, err := os.Stat("/tmp/scribbleTest/services/tcp-192_168_0_15-80.json"); !os.IsNotExist(err) { t.Errorf("Failed to clear old services on PUT - %v", err) } // todo: read from ipvsadm service, err := balance.GetService(testService2.Id) if err != nil { t.Error(err) } if service.Host != testService2.Host { t.Errorf("Read service differs from written service") } }
func TestGetServers(t *testing.T) { if skip { t.SkipNow() } service, err := balance.GetService(testService1.Id) if err != nil { t.Errorf("Failed to GET service - %v", err) t.FailNow() } if service.Servers[0].Id != testServer2.Id { t.Errorf("Read server differs from written server") } }
func TestDeleteService(t *testing.T) { if skip { t.SkipNow() } if err := balance.DeleteService(testService2.Id); err != nil { t.Errorf("Failed to GET service - %v", err) } // todo: read from ipvsadm _, err := balance.GetService(testService2.Id) if !strings.Contains(err.Error(), "No Service Found") { t.Error(err) } }
func TestGetServersNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } svc := testService1 svc.Servers = append(svc.Servers, testServer2) balance.SetService(&svc) service, err := balance.GetService(testService1.Id) if err != nil { t.Errorf("Failed to GET servers - %v", err) t.FailNow() } if service.Servers[0].Id != testServer2.Id { t.Errorf("Read server differs from written server") } }
func TestDeleteServiceNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } if err := balance.DeleteService(testService2.Id); err != nil { t.Errorf("Failed to DELETE nonexistant service - %v", err) } balance.SetService(&testService2) if err := balance.DeleteService(testService2.Id); err != nil { t.Errorf("Failed to DELETE service - %v", err) } _, err := balance.GetService(testService2.Id) if err == nil { t.Error(err) } }
//////////////////////////////////////////////////////////////////////////////// // SERVICES //////////////////////////////////////////////////////////////////////////////// func TestSetService(t *testing.T) { if skip { t.SkipNow() } if err := balance.SetService(&testService1); err != nil { t.Errorf("Failed to SET service - %v", err) t.FailNow() } // todo: read from ipvsadm service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) } if service.Host != testService1.Host { t.Errorf("Read service differs from written service") } }
func TestDeleteServer(t *testing.T) { if skip { t.SkipNow() } err := balance.DeleteServer(testService1.Id, testServer2.Id) if err != nil { t.Errorf("Failed to DELETE server - %v", err) } // todo: read from ipvsadm service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) t.FailNow() } if service.Id != testService1.Id { t.Errorf("Read service differs from written service") } }
//////////////////////////////////////////////////////////////////////////////// // SERVICES //////////////////////////////////////////////////////////////////////////////// func TestSetServiceNginx(t *testing.T) { if !nginxPrep() { t.SkipNow() } if err := balance.SetService(&testService1); err != nil { t.Errorf("Failed to SET service - %v", err) t.FailNow() } if err := balance.SetService(&testService1); err != nil { t.Errorf("Failed to SET service - %v", err) t.FailNow() } service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) t.FailNow() } if service.Host != testService1.Host { t.Errorf("Read service differs from written service") } }
func TestSetServers(t *testing.T) { if skip { t.SkipNow() } servers := []core.Server{} servers = append(servers, testServer2) if err := balance.SetServers(testService1.Id, servers); err != nil { t.Errorf("Failed to SET servers - %v", err) t.FailNow() } // todo: read from ipvsadm service, err := balance.GetService(testService1.Id) if err != nil { t.Error(err) } svc := testService1 svc.Servers = append(svc.Servers, testServer2) if service.Servers[0].Host != svc.Servers[0].Host { t.Errorf("Failed to clear old servers on PUT") } }