Example #1
0
func TestSetServices(t *testing.T) {
	if skip {
		t.SkipNow()
	}
	services := []core.Service{}
	services = append(services, testService2)

	if err := cluster.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)
	}

	service, err := cluster.GetService(testService2.Id)
	if err != nil {
		t.Error(err)
	}

	if service.Host != testService2.Host {
		t.Errorf("Read service differs from written service")
	}
}
Example #2
0
func TestNoneDeleteService(t *testing.T) {
	if err := cluster.DeleteService(testService2.Id); err != nil {
		t.Errorf("Failed to DELETE service - %v", err)
		t.FailNow()
	}

	_, err := cluster.GetService(testService2.Id)
	if !strings.Contains(err.Error(), "No Service Found") {
		t.Error(err)
	}
}
Example #3
0
func TestNoneGetService(t *testing.T) {
	service, err := cluster.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")
	}
}
Example #4
0
func TestNoneDeleteServer(t *testing.T) {
	err := cluster.DeleteServer(testService1.Id, testServer2.Id)
	if err != nil {
		t.Errorf("Failed to DELETE server - %v", err)
	}

	service, err := cluster.GetService(testService1.Id)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}

	if service.Id != testService1.Id {
		t.Errorf("Read service differs from written service")
	}
}
Example #5
0
func TestNoneGetServers(t *testing.T) {
	service, err := cluster.GetService(testService1.Id)
	if err != nil {
		t.Errorf("Failed to GET service - %v", err)
		t.FailNow()
	}

	if service.Host == "" || len(service.Servers) == 0 {
		t.Errorf("GOT empty service")
		t.FailNow()
	}

	if service.Servers[0].Id != testServer2.Id {
		t.Errorf("Read server differs from written server")
	}
}
Example #6
0
////////////////////////////////////////////////////////////////////////////////
// SERVICES
////////////////////////////////////////////////////////////////////////////////
func TestSetService(t *testing.T) {
	if skip {
		t.SkipNow()
	}
	if err := cluster.SetService(&testService1); err != nil {
		t.Errorf("Failed to SET service - %v", err)
		t.FailNow()
	}

	service, err := cluster.GetService(testService1.Id)
	if err != nil {
		t.Error(err)
	}

	if service.Host != testService1.Host {
		t.Errorf("Read service differs from written service")
	}
}
Example #7
0
func TestNoneSetService(t *testing.T) {
	config.ClusterConnection = "none://"
	cluster.Init()

	if err := cluster.SetService(&testService1); err != nil {
		t.Errorf("Failed to SET service - %v", err)
		t.FailNow()
	}

	service, err := cluster.GetService(testService1.Id)
	if err != nil {
		t.Error(err)
	}

	if service.Host != testService1.Host {
		t.Errorf("Read service differs from written service")
	}
}
Example #8
0
////////////////////////////////////////////////////////////////////////////////
// SERVERS
////////////////////////////////////////////////////////////////////////////////
func TestNoneSetServer(t *testing.T) {
	cluster.SetService(&testService1)
	if err := cluster.SetServer(testService1.Id, &testServer1); err != nil {
		t.Errorf("Failed to SET server - %v", err)
		t.FailNow()
	}

	service, err := cluster.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")
	}
}
Example #9
0
func TestNoneSetServers(t *testing.T) {
	servers := []core.Server{}
	servers = append(servers, testServer2)
	if err := cluster.SetServers(testService1.Id, servers); err != nil {
		t.Errorf("Failed to SET servers - %v", err)
		t.FailNow()
	}

	service, err := cluster.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")
	}
}