Skip to content

Commit

Permalink
[Lookout] Make jobs.annotations column not nullable (#3519)
Browse files Browse the repository at this point in the history
* [Lookout] Make jobs.annotations column not nullable

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

* Fix tests

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

* Use explicit constraint + newer postgres image

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

* Fix constraint validation

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

* Update constraint name

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

* Fix tests

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>

---------

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
  • Loading branch information
JamesMurkin committed Apr 16, 2024
1 parent a16dfd1 commit 380d59d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:

postgres:
container_name: postgres
image: postgres:12.13-alpine
image: postgres:15.6-alpine
environment:
- POSTGRES_PASSWORD=psw
ports:
Expand Down
4 changes: 3 additions & 1 deletion internal/armada/queryapi/query_api_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package queryapi

import (
"encoding/json"
"testing"
"time"

Expand Down Expand Up @@ -283,6 +284,7 @@ func TestGetJobStatus(t *testing.T) {
}

func newJob(jobId string, state int16) database.Job {
annotations, _ := json.Marshal(map[string]string{})
return database.Job{
JobID: jobId,
Queue: "testQueue",
Expand Down Expand Up @@ -310,7 +312,7 @@ func newJob(jobId string, state int16) database.Job {
LatestRunID: nil,
CancelReason: nil,
Namespace: pointer.String("testNamespace"),
Annotations: nil,
Annotations: annotations,
}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/lookoutingesterv2/lookoutdb/insertion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func TestUpdateJobsWithTerminal(t *testing.T) {
LastTransitionTimeSeconds: baseTime.Unix(),
JobProto: []byte(jobProto),
PriorityClass: pointer.String(priorityClass),
Annotations: map[string]string{},
},
{
JobId: "job2",
Expand All @@ -341,6 +342,7 @@ func TestUpdateJobsWithTerminal(t *testing.T) {
LastTransitionTimeSeconds: baseTime.Unix(),
JobProto: []byte(jobProto),
PriorityClass: pointer.String(priorityClass),
Annotations: map[string]string{},
},
{
JobId: "job3",
Expand All @@ -358,6 +360,7 @@ func TestUpdateJobsWithTerminal(t *testing.T) {
LastTransitionTimeSeconds: baseTime.Unix(),
JobProto: []byte(jobProto),
PriorityClass: pointer.String(priorityClass),
Annotations: map[string]string{},
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE job ADD CONSTRAINT job_annotations_not_null CHECK (annotations IS NOT NULL) NOT VALID;
ALTER TABLE job VALIDATE CONSTRAINT job_annotations_not_null;

0 comments on commit 380d59d

Please sign in to comment.