|
19 | 19 | defmodule Astarte.PopulateDBTest do |
20 | 20 | use ExUnit.Case |
21 | 21 | alias Astarte.Import.PopulateDB |
| 22 | + alias Astarte.DataAccess.DatabaseTestHelper |
22 | 23 |
|
23 | | - @realm "test" |
| 24 | + @realm "astartetest" |
24 | 25 |
|
25 | 26 | @xml """ |
26 | 27 | <?xml version="1.0" encoding="UTF-8"?> |
27 | 28 | <astarte> |
28 | | - <devices> |
29 | | - <device device_id="yKA3CMd07kWaDyj6aMP4Dg"> |
30 | | - <protocol revision="0" pending_empty_cache="false" /> |
31 | | - <registration |
32 | | - secret_bcrypt_hash="$2b$12$bKly9EEKmxfVyDeXjXu1vOebWgr34C8r4IHd9Cd.34Ozm0TWVo1Ve" |
33 | | - first_registration="2019-05-30T13:49:57.045000Z" /> |
34 | | - <credentials inhibit_request="false" |
35 | | - cert_serial="324725654494785828109237459525026742139358888604" |
36 | | - cert_aki="a8eaf08a797f0b10bb9e7b5dca027ec2571c5ea6" |
37 | | - first_credentials_request="2019-05-30T13:49:57.355000Z" |
38 | | - last_credentials_request_ip="198.51.100.1" /> |
39 | | - <stats total_received_msgs="64" total_received_bytes="3960" |
40 | | - last_connection="2019-05-30T13:49:57.561000Z" last_disconnection="2019-05-30T13:51:00.038000Z" |
41 | | - last_seen_ip="198.51.100.89"/> |
42 | | - <interfaces> |
43 | | - <interface name="org.astarteplatform.Values" major_version="0" minor_version="1" |
44 | | - active="true"> |
45 | | - <datastream path="/realValue"> |
46 | | - <value reception_timestamp="2019-05-31T09:12:42.789379Z">0.1</value> |
47 | | - <value reception_timestamp="2019-05-31T09:13:29.144111Z">0.2</value> |
48 | | - <value reception_timestamp="2019-05-31T09:13:52.040373Z">0.3</value> |
49 | | - </datastream> |
50 | | - </interface> |
51 | | - <interface name="org.astarteplatform.ValuesXYZ" major_version="0" minor_version="1" active="true"> |
52 | | - <datastream path="/realValues"> |
53 | | - <object reception_timestamp="2019-06-11T13:24:03.200820Z"> |
54 | | - <item name="/x">0.1</item> |
55 | | - <item name="/y">0.2</item> |
56 | | - <item name="/z">0.3</item> |
57 | | - </object> |
58 | | - <object reception_timestamp="2019-06-11T13:26:28.994144Z"> |
59 | | - <item name="/x">1.0</item> |
60 | | - <item name="/y">2.0</item> |
61 | | - <item name="/z">3.0</item> |
62 | | - </object> |
63 | | - <object reception_timestamp="2019-06-11T13:26:44.218092Z"> |
64 | | - <item name="/x">10</item> |
65 | | - <item name="/y">20</item> |
66 | | - <item name="/z">30</item> |
67 | | - </object> |
68 | | - </datastream> |
69 | | - </interface> |
70 | | - <interface name="org.astarteplatform.PropertyValue" major_version="0" minor_version="1" active="true"> |
71 | | - <property path="/realValue" reception_timestamp="2019-06-12T14:45:49.706034Z">4.2</property> |
72 | | - </interface> |
73 | | - </interfaces> |
74 | | - </device> |
75 | | - </devices> |
| 29 | + <devices> |
| 30 | + <device device_id="yKA3CMd07kWaDyj6aMP4Dg"> |
| 31 | + <protocol revision="0" pending_empty_cache="false"/> |
| 32 | + <registration secret_bcrypt_hash="null" first_registration="2019-05-30T13:49:57.045Z"/> |
| 33 | + <credentials inhibit_request="false" cert_serial="324725654494785828109237459525026742139358888604" cert_aki="a8eaf08a797f0b10bb9e7b5dca027ec2571c5ea6" first_credentials_request="2019-05-30T13:49:57.355Z" last_credentials_request_ip="198.51.100.1"/> |
| 34 | + <stats total_received_msgs="64" total_received_bytes="3960" last_connection="2019-05-30T13:49:57.561Z" last_disconnection="2019-05-30T13:51:00.038Z" last_seen_ip="198.51.100.89"/> |
| 35 | + <interfaces> |
| 36 | + <interface name="properties.org" major_version="0" minor_version="1" active="true"> |
| 37 | + <property reception_timestamp="2020-01-30T03:26:23.184Z" path="/properties1">42.0</property> |
| 38 | + <property reception_timestamp="2020-01-30T03:26:23.185Z" path="/properties2">This is property string</property> |
| 39 | + </interface> |
| 40 | + <interface name="org.individualdatastreams.values" major_version="0" minor_version="1" active="true"> |
| 41 | + <datastream path="/testinstall1"> |
| 42 | + <value reception_timestamp="2019-05-31T09:12:42.789Z">0.1</value> |
| 43 | + <value reception_timestamp="2019-05-31T09:13:29.144Z">0.2</value> |
| 44 | + <value reception_timestamp="2019-05-31T09:13:52.040Z">0.3</value> |
| 45 | + </datastream> |
| 46 | + <datastream path="/testinstall2"> |
| 47 | + <value reception_timestamp="2019-05-31T09:12:42.789Z">3</value> |
| 48 | + <value reception_timestamp="2019-05-31T09:13:52.040Z">4</value> |
| 49 | + </datastream> |
| 50 | + <datastream path="/testinstall3"> |
| 51 | + <value reception_timestamp="2019-05-31T09:12:42.789Z">true</value> |
| 52 | + <value reception_timestamp="2019-05-31T09:13:29.144Z">false</value> |
| 53 | + <value reception_timestamp="2019-05-31T09:13:52.040Z">true</value> |
| 54 | + </datastream> |
| 55 | + <datastream path="/testinstall4"> |
| 56 | + <value reception_timestamp="2019-05-31T09:12:42.789Z">This is the data1</value> |
| 57 | + <value reception_timestamp="2019-05-31T09:13:29.144Z">This is the data2</value> |
| 58 | + <value reception_timestamp="2019-05-31T09:13:52.040Z">This is the data3</value> |
| 59 | + </datastream> |
| 60 | + <datastream path="/testinstall5"> |
| 61 | + <value reception_timestamp="2019-05-31T09:12:42.789Z">3244325554</value> |
| 62 | + <value reception_timestamp="2019-05-31T09:13:29.144Z">4885959589</value> |
| 63 | + </datastream> |
| 64 | + </interface> |
| 65 | + <interface name="objectdatastreams.org" major_version="0" minor_version="1" active="true"> |
| 66 | + <datastream path="/objectendpoint1"> |
| 67 | + <object reception_timestamp="2019-06-11T13:24:03.200Z"> |
| 68 | + <item name="/y">2</item> |
| 69 | + <item name="/x">45.0</item> |
| 70 | + <item name="/d">78787985785</item> |
| 71 | + </object> |
| 72 | + <object reception_timestamp="2019-06-11T13:26:28.994Z"> |
| 73 | + <item name="/y">555</item> |
| 74 | + <item name="/x">1.0</item> |
| 75 | + <item name="/d">747989859</item> |
| 76 | + </object> |
| 77 | + <object reception_timestamp="2019-06-11T13:26:44.218Z"> |
| 78 | + <item name="/y">22</item> |
| 79 | + <item name="/x">488.0</item> |
| 80 | + <item name="/d">747847748</item> |
| 81 | + </object> |
| 82 | + </datastream> |
| 83 | + </interface> |
| 84 | + </interfaces> |
| 85 | + </device> |
| 86 | + </devices> |
76 | 87 | </astarte> |
77 | 88 | """ |
78 | 89 |
|
| 90 | + setup do |
| 91 | + Xandra.Cluster.run(:astarte_data_access_xandra, fn conn -> |
| 92 | + DatabaseTestHelper.seed_data(conn) |
| 93 | + end) |
| 94 | + end |
| 95 | + |
| 96 | + setup_all do |
| 97 | + Xandra.Cluster.run(:astarte_data_access_xandra, fn conn -> |
| 98 | + DatabaseTestHelper.create_test_keyspace(conn) |
| 99 | + end) |
| 100 | + |
| 101 | + on_exit(fn -> |
| 102 | + Xandra.Cluster.run(:astarte_data_access_xandra, fn conn -> |
| 103 | + DatabaseTestHelper.drop_test_keyspace(conn) |
| 104 | + end) |
| 105 | + end) |
| 106 | + |
| 107 | + :ok |
| 108 | + end |
| 109 | + |
79 | 110 | test "Test import into Cassandra database" do |
80 | 111 | PopulateDB.populate(@realm, @xml) |
81 | 112 | end |
|
0 commit comments