Skip to content

Commit

Permalink
fix: Add ssdb environment preparation
Browse files Browse the repository at this point in the history
Change-Id: I8534e66786021ce4384c92a2a8d14aa50839a4da
  • Loading branch information
hudeng-go committed Oct 12, 2022
1 parent a1bb3e7 commit 9a668fd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
41 changes: 41 additions & 0 deletions database/ssdb/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package ssdb_test

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"testing"

"github.com/aptly-dev/aptly/database"
Expand All @@ -15,6 +18,44 @@ func Test(t *testing.T) {
TestingT(t)
}

func setUpSsdb() error {
setUpStr := `
#!/bin/bash
if [ ! -e /tmp/ssdb-master/ssdb-master ]; then
mkdir -p /tmp/ssdb-master
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip -O /tmp/ssdb-master/master.zip
cd /tmp/ssdb-master && unzip master && cd ssdb-master && make all
fi
cd /tmp/ssdb-master/ssdb-master && ./ssdb-server -d ssdb.conf -s restart
sleep 2`

tmpShell, err := ioutil.TempFile("/tmp", "ssdbSetup")
if err != nil {
return err
}
defer os.Remove(tmpShell.Name())

_, err = tmpShell.WriteString(setUpStr)
if err != nil {
return err
}

cmd := exec.Command("/bin/bash", tmpShell.Name())
fmt.Println(cmd.String())
output, err := cmd.Output()
fmt.Println(string(output))
if err != nil {
return err
}

return nil
}

func TestMain(m *testing.M) {
setUpSsdb()
m.Run()
}

type SSDBSuite struct {
cfg *conf.Config
db database.Storage
Expand Down
7 changes: 6 additions & 1 deletion system/t02_config/ConfigShowTest_gold
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"SwiftPublishEndpoints": {},
"AzurePublishEndpoints": {},
"AsyncAPI": false,
"enableMetricsEndpoint": true
"enableMetricsEndpoint": true,
"databaseBackend": {
"type": "",
"url": "",
"dbPath": ""
}
}
7 changes: 6 additions & 1 deletion system/t02_config/CreateConfigTest_gold
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"SwiftPublishEndpoints": {},
"AzurePublishEndpoints": {},
"AsyncAPI": false,
"enableMetricsEndpoint": false
"enableMetricsEndpoint": false,
"databaseBackend": {
"type": "",
"url": "",
"dbPath": ""
}
}

0 comments on commit 9a668fd

Please sign in to comment.