@@ -25,77 +25,121 @@ func TestStableToUnstable(t *testing.T) {
2525 buildDebVersion(t, majorTag, *arch)
2626 // fmt.Printf("Check folder structure and deb downloaded\n")
2727 // ls(t)
28- fmt.Println("**** BUILD docker image *****")
29- buildDockerImage(t, "test.Dockerfile", "apt-test-update-image", *arch)
30- fmt.Println("**** RUN docker image *****")
31- runDockerContainer(t, "apt-test-update", "apt-test-update-image")
32- preUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
33- runDockerSystemUpdate(t, "apt-test-update")
34- postUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
35- runDockerCleanUp(t, "apt-test-update")
36- require.Equal(t, preUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
37- require.Equal(t, postUpdateVersion, "Arduino App CLI "+majorTag+"\n")
28+ // fmt.Println("**** BUILD docker image *****")
29+ // buildDockerImage(t, "test.Dockerfile", "apt-test-update-image", *arch)
30+ // fmt.Println("**** RUN docker image *****")
31+ // runDockerContainer(t, "apt-test-update", "apt-test-update-image")
32+ // preUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
33+ // runDockerSystemUpdate(t, "apt-test-update")
34+ // postUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
35+ // runDockerCleanUp(t, "apt-test-update")
36+ // require.Equal(t, preUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
37+ // require.Equal(t, postUpdateVersion, "Arduino App CLI "+majorTag+"\n")
3838}
3939
40- func TestClientUpdate (t *testing.T) {
40+ // func TestClientUpdateStU (t *testing.T) {
4141
42- fmt.Printf("***** ARCH %s ***** \n", *arch)
43- tagAppCli := FetchDebPackage(t, "arduino-app-cli", "latest", *arch)
44- FetchDebPackage(t, "arduino-router", "latest", *arch)
45- majorTag := majorTag(t, tagAppCli)
42+ // fmt.Printf("***** ARCH %s ***** \n", *arch)
43+ // tagAppCli := FetchDebPackage(t, "arduino-app-cli", "latest", *arch)
44+ // FetchDebPackage(t, "arduino-router", "latest", *arch)
45+ // majorTag := majorTag(t, tagAppCli)
4646
47- fmt.Println("**** RUN docker image *****")
48- runDockerContainer(t, "apt-test-update", "apt-test-update-image")
49- preUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
47+ // fmt.Println("**** RUN docker image *****")
48+ // runDockerContainer(t, "apt-test-update", "apt-test-update-image")
49+ // preUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
5050
51- runDockerDaemon(t, "apt-test-update")
52- time.Sleep(5 * time.Second) //wait for the daemon to be fully started
53- status := putUpdateRequest(t, "http://127.0.0.1:8800/v1/system/update/apply")
54- fmt.Printf("Response status: %s\n", status)
51+ // runDockerDaemon(t, "apt-test-update")
52+ // WaitForPort(t, "127.0.0.1", 8800, 5*time.Second)
5553
56- itr := NewSSEClient(context.Background(), "GET", "http://localhost:8800/v1/system/update/events")
54+ // status := putUpdateRequest(t, "http://127.0.0.1:8800/v1/system/update/apply")
55+ // fmt.Printf("Response status: %s\n", status)
5756
58- for event, err := range itr {
59- if err != nil {
60- log.Printf("Error receiving SSE event: %v", err)
61- }
62- fmt.Printf("Received event: ID=%s, Event=%s, Data=%s\n", event.ID, event.Event, string(event.Data))
63- if string(event.Data) == "Download complete" {
64- fmt.Println("✅ Download complete — exiting successfully.")
65- }
66- }
57+ // itr := NewSSEClient(context.Background(), "GET", "http://localhost:8800/v1/system/update/events")
6758
68- postUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
59+ // for event, err := range itr {
60+ // if err != nil {
61+ // log.Printf("Error receiving SSE event: %v", err)
62+ // }
63+ // fmt.Printf("Received event: ID=%s, Event=%s, Data=%s\n", event.ID, event.Event, string(event.Data))
64+ // if string(event.Data) == "Download complete" {
65+ // fmt.Println("✅ Download complete — exiting successfully.")
66+ // }
67+ // }
6968
70- require.Equal(t, preUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
71- require.Equal(t, postUpdateVersion, "Arduino App CLI "+majorTag+"\n")
72- runDockerCleanUp(t, "apt-test-update")
69+ // postUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
7370
74- }
71+ // require.Equal(t, preUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
72+ // require.Equal(t, postUpdateVersion, "Arduino App CLI "+majorTag+"\n")
73+ // runDockerCleanUp(t, "apt-test-update")
74+
75+ // }
7576
7677func TestUnstableToStable(t *testing.T) {
77- tagAppCli := FetchDebPackage(t, "arduino-app-cli", "latest", *arch)
78- FetchDebPackage(t, "arduino-router", "latest", *arch)
79- minorTag := minorTag(t, tagAppCli)
80- moveDeb(t, "build/stable", "build/", "arduino-app-cli", tagAppCli, *arch)
81-
82- fmt.Printf("Updating from unstable version %s to stable version %s \n", minorTag, tagAppCli)
83- fmt.Printf("Building local deb version %s \n", minorTag)
84- buildDebVersion(t, minorTag, *arch)
85- moveDeb(t, "build/", "build/stable", "arduino-app-cli", minorTag, *arch)
86-
87- fmt.Printf("Check folder structure and deb downloaded\n")
88- ls(t)
89-
90- fmt.Println("**** BUILD docker image *****")
91- buildDockerImage(t, "test.Dockerfile", "test-apt-update-unstable-image", *arch)
92- fmt.Println("**** RUN docker image *****")
93- runDockerContainer(t, "apt-test-update-unstable", "test-apt-update-unstable-image")
94- preUpdateVersion := runDockerSystemVersion(t, "apt-test-update-unstable")
95- runDockerSystemUpdate(t, "apt-test-update-unstable")
96- postUpdateVersion := runDockerSystemVersion(t, "apt-test-update-unstable")
97- runDockerCleanUp(t, "apt-test-update-unstable")
98- require.Equal(t, preUpdateVersion, "Arduino App CLI "+minorTag+"\n")
99- require.Equal(t, postUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
78+
79+ t.Run("CLI Update Testing", func(t *testing.T) {
80+ tagAppCli := FetchDebPackage(t, "arduino-app-cli", "latest", *arch)
81+ FetchDebPackage(t, "arduino-router", "latest", *arch)
82+ minorTag := minorTag(t, tagAppCli)
83+ //Move the stable package to the build (unstable) folder
84+ moveDeb(t, "build/stable", "build/", "arduino-app-cli", tagAppCli, *arch)
85+ fmt.Printf("Updating from unstable version %s to stable version %s \n", minorTag, tagAppCli)
86+ fmt.Printf("Building local deb version %s \n", minorTag)
87+ //Build unstable with a minor tag w.r.t stable
88+ buildDebVersion(t, minorTag, *arch)
89+ //Move the unstable package to the stable folder
90+ moveDeb(t, "build/", "build/stable", "arduino-app-cli", minorTag, *arch)
91+ fmt.Printf("Check folder structure and deb downloaded\n")
92+ ls(t)
93+ fmt.Println("**** BUILD docker image *****")
94+ buildDockerImage(t, "test.Dockerfile", "test-apt-update-unstable-image", *arch)
95+ fmt.Println("**** RUN docker image *****")
96+ runDockerContainer(t, "apt-test-update-unstable", "test-apt-update-unstable-image")
97+ preUpdateVersion := runDockerSystemVersion(t, "apt-test-update-unstable")
98+ runDockerSystemUpdate(t, "apt-test-update-unstable")
99+ postUpdateVersion := runDockerSystemVersion(t, "apt-test-update-unstable")
100+ runDockerCleanUp(t, "apt-test-update-unstable")
101+ require.Equal(t, preUpdateVersion, "Arduino App CLI "+minorTag+"\n")
102+ require.Equal(t, postUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
103+ })
104+
105+ t.Run("Client Daemon Request Testing", func(t *testing.T) {
106+ tagAppCli := FetchDebPackage(t, "arduino-app-cli", "latest", *arch)
107+ FetchDebPackage(t, "arduino-router", "latest", *arch)
108+ minorTag := minorTag(t, tagAppCli)
109+ //Move the stable package to the build (unstable) folder
110+ moveDeb(t, "build/stable", "build/", "arduino-app-cli", tagAppCli, *arch)
111+ fmt.Printf("Updating from unstable version %s to stable version %s \n", minorTag, tagAppCli)
112+ fmt.Printf("Building local deb version %s \n", minorTag)
113+ //Build unstable with a minor tag w.r.t stable
114+ buildDebVersion(t, minorTag, *arch)
115+ //Move the unstable package to the stable folder
116+ moveDeb(t, "build/", "build/stable", "arduino-app-cli", minorTag, *arch)
117+ fmt.Printf("Check folder structure and deb downloaded\n")
118+ fmt.Println("**** RUN docker image *****")
119+ runDockerContainer(t, "apt-test-update-unstable", "test-apt-update-unstable-image")
120+ preUpdateVersion := runDockerSystemVersion(t, "apt-test-update-unstable")
121+ runDockerDaemon(t, "apt-test-update-unstable ")
122+ WaitForPort(t, "127.0.0.1", 8800, 5*time.Second)
123+ status := putUpdateRequest(t, "http://127.0.0.1:8800/v1/system/update/apply")
124+ fmt.Printf("Response status: %s\n", status)
125+
126+ itr := NewSSEClient(context.Background(), "GET", "http://localhost:8800/v1/system/update/events")
127+
128+ for event, err := range itr {
129+ if err != nil {
130+ log.Printf("Error receiving SSE event: %v", err)
131+ }
132+ fmt.Printf("Received event: ID=%s, Event=%s, Data=%s\n", event.ID, event.Event, string(event.Data))
133+ if string(event.Data) == "Download complete" {
134+ fmt.Println("✅ Download complete — exiting successfully.")
135+ }
136+ }
137+
138+ postUpdateVersion := runDockerSystemVersion(t, "apt-test-update")
139+ runDockerCleanUp(t, "apt-test-update-unstable")
140+ require.Equal(t, preUpdateVersion, "Arduino App CLI "+tagAppCli+"\n")
141+ require.Equal(t, postUpdateVersion, "Arduino App CLI "+minorTag+"\n")
142+
143+ })
100144
101145}
0 commit comments