parent
							
								
									e104a67260
								
							
						
					
					
						commit
						1540a2ba65
					
				|  | @ -430,7 +430,7 @@ func (c *Cluster) Update(newSpec *spec.Postgresql) error { | |||
| 					c.logger.Infof("%s service '%s' has been created", role, util.NameFromMeta(service.ObjectMeta)) | ||||
| 				} | ||||
| 			} | ||||
| 			// only proceeed further if both old and new load balancer were present
 | ||||
| 			// only proceed further if both old and new load balancer were present
 | ||||
| 			if !(newSpec.Spec.ReplicaLoadBalancer && c.Spec.ReplicaLoadBalancer) { | ||||
| 				continue | ||||
| 			} | ||||
|  |  | |||
|  | @ -39,7 +39,7 @@ func (c *Cluster) Sync() error { | |||
| 			if c.Service[role] != nil { | ||||
| 				// delete the left over replica service
 | ||||
| 				if err := c.deleteService(role); err != nil { | ||||
| 					return fmt.Errorf("could not delete obsolete %s service: %v", role) | ||||
| 					return fmt.Errorf("could not delete obsolete %s service: %v", role, err) | ||||
| 				} | ||||
| 			} | ||||
| 			continue | ||||
|  |  | |||
|  | @ -109,8 +109,8 @@ func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.Volume | |||
| 					return fmt.Errorf("could not connect to the volume provider: %v", err) | ||||
| 				} | ||||
| 				defer func() { | ||||
| 					err2 := resizer.DisconnectFromProvider(); if err2 != nil { | ||||
| 						c.logger.Errorf("%v", err2) | ||||
| 					if err := resizer.DisconnectFromProvider(); err != nil { | ||||
| 						c.logger.Errorf("%v", err) | ||||
| 					} | ||||
| 				}() | ||||
| 			} | ||||
|  | @ -127,7 +127,7 @@ func (c *Cluster) resizeVolumes(newVolume spec.Volume, resizers []volumes.Volume | |||
| 			if err := c.resizePostgresFilesystem(podName, []filesystems.FilesystemResizer{&filesystems.Ext234Resize{}}); err != nil { | ||||
| 				return fmt.Errorf("could not resize the filesystem on pod '%s': %v", podName, err) | ||||
| 			} | ||||
| 			c.logger.Debugf("filesystem resize successfull on volume %s", pv.Name) | ||||
| 			c.logger.Debugf("filesystem resize successful on volume %s", pv.Name) | ||||
| 			pv.Spec.Capacity[v1.ResourceStorage] = newQuantity | ||||
| 			c.logger.Debugf("updating persistent volume definition for volume %s", pv.Name) | ||||
| 			if _, err := c.KubeClient.PersistentVolumes().Update(pv); err != nil { | ||||
|  |  | |||
|  | @ -223,7 +223,7 @@ var unmarshalCluster = []struct { | |||
| 				TeamID:              "ACID", | ||||
| 				AllowedSourceRanges: []string{"127.0.0.1/32"}, | ||||
| 				NumberOfInstances:   2, | ||||
| 				Users:               map[string]UserFlags{"zalando": {"superuser", "createdb"}}, | ||||
| 				Users:               map[string]userFlags{"zalando": {"superuser", "createdb"}}, | ||||
| 				MaintenanceWindows: []MaintenanceWindow{{ | ||||
| 					Everyday:  false, | ||||
| 					Weekday:   time.Monday, | ||||
|  | @ -237,7 +237,7 @@ var unmarshalCluster = []struct { | |||
| 				}, | ||||
| 					{ | ||||
| 						Everyday:  true, | ||||
| 						Weekday: time.Sunday, | ||||
| 						Weekday:   time.Sunday, | ||||
| 						StartTime: mustParseTime("05:00"), | ||||
| 						EndTime:   mustParseTime("05:15"), | ||||
| 					}, | ||||
|  | @ -263,13 +263,13 @@ var unmarshalCluster = []struct { | |||
| 		}, | ||||
| 		[]byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"teapot-testcluster1","creationTimestamp":null},"spec":{"postgresql":{"version":"","parameters":null},"volume":{"size":"","storageClass":""},"patroni":{"initdb":null,"pg_hba":null,"ttl":0,"loop_wait":0,"retry_timeout":0,"maximum_lag_on_failover":0},"resources":{"requests":{"cpu":"","memory":""},"limits":{"cpu":"","memory":""}},"teamId":"acid","allowedSourceRanges":null,"numberOfInstances":0,"users":null},"status":"Invalid"}`), nil}, | ||||
| 	{[]byte(`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1"`), | ||||
| 	 Postgresql{}, | ||||
| 	 []byte{}, | ||||
| 	 errors.New("unexpected end of JSON input")}, | ||||
| 		Postgresql{}, | ||||
| 		[]byte{}, | ||||
| 		errors.New("unexpected end of JSON input")}, | ||||
| 	{[]byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"acid-testcluster","creationTimestamp":qaz},"spec":{"postgresql":{"version":"","parameters":null},"volume":{"size":"","storageClass":""},"patroni":{"initdb":null,"pg_hba":null,"ttl":0,"loop_wait":0,"retry_timeout":0,"maximum_lag_on_failover":0},"resources":{"requests":{"cpu":"","memory":""},"limits":{"cpu":"","memory":""}},"teamId":"acid","allowedSourceRanges":null,"numberOfInstances":0,"users":null},"status":"Invalid"}`), | ||||
| 	 Postgresql{}, | ||||
| 	 []byte{}, | ||||
| 	 errors.New("invalid character 'q' looking for beginning of value")}} | ||||
| 		Postgresql{}, | ||||
| 		[]byte{}, | ||||
| 		errors.New("invalid character 'q' looking for beginning of value")}} | ||||
| 
 | ||||
| var postgresqlList = []struct { | ||||
| 	in  []byte | ||||
|  | @ -282,7 +282,7 @@ var postgresqlList = []struct { | |||
| 				Kind:       "List", | ||||
| 				APIVersion: "v1", | ||||
| 			}, | ||||
| 			Items: []Postgresql{Postgresql{ | ||||
| 			Items: []Postgresql{{ | ||||
| 				TypeMeta: unversioned.TypeMeta{ | ||||
| 					Kind:       "Postgresql", | ||||
| 					APIVersion: "acid.zalan.do/v1", | ||||
|  | @ -309,8 +309,8 @@ var postgresqlList = []struct { | |||
| 		}, | ||||
| 		nil}, | ||||
| 	{[]byte(`{"apiVersion":"v1","items":[{"apiVersion":"acid.zalan.do/v1","kind":"Postgresql","metadata":{"labels":{"team":"acid"},"name":"acid-testcluster42","namespace"`), | ||||
| 	 PostgresqlList{}, | ||||
| 	 errors.New("unexpected end of JSON input")}} | ||||
| 		PostgresqlList{}, | ||||
| 		errors.New("unexpected end of JSON input")}} | ||||
| 
 | ||||
| func mustParseTime(s string) time.Time { | ||||
| 	v, err := time.Parse("15:04", s) | ||||
|  | @ -382,7 +382,7 @@ func TestUnmarshalMaintenanceWindow(t *testing.T) { | |||
| 		} | ||||
| 
 | ||||
| 		if !reflect.DeepEqual(m, tt.out) { | ||||
| 			t.Errorf("Expected maintenace window: %#v, got: %#v", tt.out, m) | ||||
| 			t.Errorf("Expected maintenance window: %#v, got: %#v", tt.out, m) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ func (t *API) TeamInfo(teamID, token string) (tm *team, er error) { | |||
| 		return nil, err | ||||
| 	} | ||||
| 	defer func() { | ||||
| 		if err:= resp.Body.Close(); err != nil { | ||||
| 		if err := resp.Body.Close(); err != nil { | ||||
| 			er = fmt.Errorf("error when closing response; %v", err) | ||||
| 			tm = nil | ||||
| 		} | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| package util | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
| 
 | ||||
|  | @ -26,13 +25,6 @@ var pgUsers = []struct { | |||
| 		MemberOf: []string{}}, | ||||
| 		"md592f413f3974bdf3799bb6fecb5f9f2c6"}} | ||||
| 
 | ||||
| var prettyTest = []struct { | ||||
| 	in  interface{} | ||||
| 	out string | ||||
| }{ | ||||
| 	{pgUsers, `[{{test password [] []} md587f77988ccb5aa917c93201ba314fcd4} {{test md592f413f3974bdf3799bb6fecb5f9f2c6 [] []} md592f413f3974bdf3799bb6fecb5f9f2c6}]`}, | ||||
| } | ||||
| 
 | ||||
| var prettyDiffTest = []struct { | ||||
| 	inA interface{} | ||||
| 	inB interface{} | ||||
|  | @ -86,14 +78,6 @@ func TestPGUserPassword(t *testing.T) { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestPretty(t *testing.T) { | ||||
| 	for _, tt := range prettyTest { | ||||
| 		if actual := Pretty(tt.in); fmt.Sprintf("%v", actual) != tt.out { | ||||
| 			t.Errorf("Pretty expected: %s, got: %s", tt.out, actual) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestPrettyDiff(t *testing.T) { | ||||
| 	for _, tt := range prettyDiffTest { | ||||
| 		if actual := PrettyDiff(tt.inA, tt.inB); actual != tt.out { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue